Commit e844b9a6 authored by Kenneth Russell's avatar Kenneth Russell Committed by Commit Bot

Use base::saturated_cast to convert floating-point sampler parameter to int.

Allow direct use of base/numerics/safe_conversions.h in Blink.

Bug: 854710
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I43c664317beca77525fe65445a25da528c7747d5
Reviewed-on: https://chromium-review.googlesource.com/1109267
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569716}
parent a86f4b9a
...@@ -13,6 +13,7 @@ include_rules = [ ...@@ -13,6 +13,7 @@ include_rules = [
"+base/memory/weak_ptr.h", "+base/memory/weak_ptr.h",
"+base/metrics/histogram_macros.h", "+base/metrics/histogram_macros.h",
"+base/numerics/checked_math.h", "+base/numerics/checked_math.h",
"+base/numerics/safe_conversions.h",
"+base/optional.h", "+base/optional.h",
"+base/rand_util.h", "+base/rand_util.h",
"+base/sequenced_task_runner.h", "+base/sequenced_task_runner.h",
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <memory> #include <memory>
#include "base/numerics/checked_math.h" #include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h" #include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
#include "third_party/blink/renderer/bindings/modules/v8/webgl_any.h" #include "third_party/blink/renderer/bindings/modules/v8/webgl_any.h"
...@@ -4061,7 +4062,12 @@ void WebGL2RenderingContextBase::SamplerParameter(WebGLSampler* sampler, ...@@ -4061,7 +4062,12 @@ void WebGL2RenderingContextBase::SamplerParameter(WebGLSampler* sampler,
if (isContextLost() || !ValidateWebGLObject("samplerParameter", sampler)) if (isContextLost() || !ValidateWebGLObject("samplerParameter", sampler))
return; return;
GLint param = is_float ? static_cast<GLint>(paramf) : parami; GLint param;
if (is_float) {
param = base::saturated_cast<GLint>(paramf);
} else {
param = parami;
}
switch (pname) { switch (pname) {
case GL_TEXTURE_MAX_LOD: case GL_TEXTURE_MAX_LOD:
case GL_TEXTURE_MIN_LOD: case GL_TEXTURE_MIN_LOD:
......
...@@ -75,6 +75,19 @@ _CONFIG = [ ...@@ -75,6 +75,19 @@ _CONFIG = [
# //base/memory/ptr_util.h. # //base/memory/ptr_util.h.
'base::WrapUnique', 'base::WrapUnique',
# //base/numerics/safe_conversions.h.
'base::as_signed',
'base::as_unsigned',
'base::checked_cast',
'base::strict_cast',
'base::saturated_cast',
'base::SafeUnsignedAbs',
'base::StrictNumeric',
'base::MakeStrictNum',
'base::IsValueInRangeForNumericType',
'base::IsTypeInRangeForNumericType',
'base::IsValueNegative',
# //base/synchronization/waitable_event.h. # //base/synchronization/waitable_event.h.
'base::WaitableEvent', 'base::WaitableEvent',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment