From 45796dc81f2730136f3c0218cf611a339837b682 Mon Sep 17 00:00:00 2001 From: pkasting Date: Thu, 16 Oct 2014 21:18:32 -0700 Subject: Type conversion fixes, gpu/ edition. This is mostly to fix MSVC warnings about possible value truncation. BUG=81439 TEST=none Review URL: https://codereview.chromium.org/660093004 Cr-Commit-Position: refs/heads/master@{#300060} --- gpu/command_buffer/client/query_tracker.cc | 10 +++++----- gpu/command_buffer/service/gles2_cmd_decoder.cc | 8 ++++---- gpu/command_buffer/service/program_cache.cc | 6 +++--- gpu/command_buffer/service/program_manager.cc | 12 ++++++++---- gpu/command_buffer/service/texture_manager.cc | 2 +- 5 files changed, 21 insertions(+), 17 deletions(-) (limited to 'gpu/command_buffer') diff --git a/gpu/command_buffer/client/query_tracker.cc b/gpu/command_buffer/client/query_tracker.cc index c12d9753..e215c16 100644 --- a/gpu/command_buffer/client/query_tracker.cc +++ b/gpu/command_buffer/client/query_tracker.cc @@ -9,6 +9,7 @@ #include #include "base/atomicops.h" +#include "base/numerics/safe_conversions.h" #include "gpu/command_buffer/client/gles2_cmd_helper.h" #include "gpu/command_buffer/client/gles2_implementation.h" #include "gpu/command_buffer/client/mapped_memory.h" @@ -153,19 +154,18 @@ bool QueryTracker::Query::CheckResultsAvailable( helper->IsContextLost()) { switch (target()) { case GL_COMMANDS_ISSUED_CHROMIUM: - result_ = std::min(info_.sync->result, - static_cast(0xFFFFFFFFL)); + result_ = base::saturated_cast(info_.sync->result); break; case GL_LATENCY_QUERY_CHROMIUM: // Disabled DCHECK because of http://crbug.com/419236. //DCHECK(info_.sync->result >= client_begin_time_us_); - result_ = std::min(info_.sync->result - client_begin_time_us_, - static_cast(0xFFFFFFFFL)); + result_ = base::saturated_cast( + info_.sync->result - client_begin_time_us_); break; case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: default: - result_ = info_.sync->result; + result_ = static_cast(info_.sync->result); break; } state_ = kComplete; diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 5fc5feb..6253cc8 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -3128,7 +3128,7 @@ bool GLES2DecoderImpl::CheckFramebufferValid( return false; if (backbuffer_needs_clear_bits_) { glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( - offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); + offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1.f); state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glClearStencil(0); state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); @@ -3692,7 +3692,7 @@ bool GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) { { ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id()); glClearColor(0, 0, 0, (GLES2Util::GetChannelsForFormat( - offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1); + offscreen_target_color_format_) & 0x0008) != 0 ? 0 : 1.f); state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glClearStencil(0); state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); @@ -7254,7 +7254,7 @@ error::Error GLES2DecoderImpl::HandleVertexAttribPointer( GLuint indx = c.indx; GLint size = c.size; GLenum type = c.type; - GLboolean normalized = c.normalized; + GLboolean normalized = static_cast(c.normalized); GLsizei stride = c.stride; GLsizei offset = c.offset; const void* ptr = reinterpret_cast(offset); @@ -7496,7 +7496,7 @@ error::Error GLES2DecoderImpl::HandleReadPixels(uint32 immediate_data_size, GLsizei height = c.height; GLenum format = c.format; GLenum type = c.type; - GLboolean async = c.async; + GLboolean async = static_cast(c.async); if (width < 0 || height < 0) { LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "glReadPixels", "dimensions < 0"); return error::kNoError; diff --git a/gpu/command_buffer/service/program_cache.cc b/gpu/command_buffer/service/program_cache.cc index ad395c7..abdcfc0 100644 --- a/gpu/command_buffer/service/program_cache.cc +++ b/gpu/command_buffer/service/program_cache.cc @@ -123,9 +123,9 @@ void ProgramCache::ComputeProgramHash( current_pos += name_size; const GLint value = it->second; buffer[current_pos++] = value >> 24; - buffer[current_pos++] = value >> 16; - buffer[current_pos++] = value >> 8; - buffer[current_pos++] = value; + buffer[current_pos++] = static_cast(value >> 16); + buffer[current_pos++] = static_cast(value >> 8); + buffer[current_pos++] = static_cast(value); } } base::SHA1HashBytes(buffer.get(), diff --git a/gpu/command_buffer/service/program_manager.cc b/gpu/command_buffer/service/program_manager.cc index e8196f6..63a64b7 100644 --- a/gpu/command_buffer/service/program_manager.cc +++ b/gpu/command_buffer/service/program_manager.cc @@ -591,16 +591,20 @@ bool Program::Link(ShaderManager* manager, } UMA_HISTOGRAM_CUSTOM_COUNTS( "GPU.ProgramCache.BinaryCacheMissTime", - (TimeTicks::HighResNow() - before_time).InMicroseconds(), + static_cast( + (TimeTicks::HighResNow() - before_time).InMicroseconds()), 0, - TimeDelta::FromSeconds(10).InMicroseconds(), + static_cast( + TimeDelta::FromSeconds(10).InMicroseconds()), 50); } else { UMA_HISTOGRAM_CUSTOM_COUNTS( "GPU.ProgramCache.BinaryCacheHitTime", - (TimeTicks::HighResNow() - before_time).InMicroseconds(), + static_cast( + (TimeTicks::HighResNow() - before_time).InMicroseconds()), 0, - TimeDelta::FromSeconds(1).InMicroseconds(), + static_cast( + TimeDelta::FromSeconds(1).InMicroseconds()), 50); } } else { diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc index 45aaa65..4dbf528 100644 --- a/gpu/command_buffer/service/texture_manager.cc +++ b/gpu/command_buffer/service/texture_manager.cc @@ -1293,7 +1293,7 @@ void TextureManager::SetParameterf( if (result != GL_NO_ERROR) { if (result == GL_INVALID_ENUM) { ERRORSTATE_SET_GL_ERROR_INVALID_ENUM( - error_state, function_name, param, "param"); + error_state, function_name, pname, "pname"); } else { ERRORSTATE_SET_GL_ERROR_INVALID_PARAMF( error_state, result, function_name, pname, param); -- cgit v1.1