diff options
author | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-08 16:43:27 +0000 |
---|---|---|
committer | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-08 16:43:27 +0000 |
commit | d2fec012063ade5737c7075758574137e4d18410 (patch) | |
tree | c146eeb0aa3306931c044a569d5905698d91fef4 /o3d/core/cross | |
parent | d1d12f3e73ab60a2bea0ad380cc227dbd165c3a6 (diff) | |
download | chromium_src-d2fec012063ade5737c7075758574137e4d18410.zip chromium_src-d2fec012063ade5737c7075758574137e4d18410.tar.gz chromium_src-d2fec012063ade5737c7075758574137e4d18410.tar.bz2 |
This fixes a bunch of warnings that are in our code, in order for the GYP build to succeed.
Review URL: http://codereview.chromium.org/118346
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/core/cross')
-rw-r--r-- | o3d/core/cross/bitmap.cc | 15 | ||||
-rw-r--r-- | o3d/core/cross/bitmap_png.cc | 2 | ||||
-rw-r--r-- | o3d/core/cross/buffer_test.cc | 8 | ||||
-rw-r--r-- | o3d/core/cross/canvas_shader.cc | 4 | ||||
-rw-r--r-- | o3d/core/cross/client.cc | 6 | ||||
-rw-r--r-- | o3d/core/cross/curve_test.cc | 18 | ||||
-rw-r--r-- | o3d/core/cross/effect_test.cc | 12 | ||||
-rw-r--r-- | o3d/core/cross/param.cc | 4 | ||||
-rw-r--r-- | o3d/core/cross/ray_intersection_info.cc | 2 | ||||
-rw-r--r-- | o3d/core/cross/renderer.cc | 2 | ||||
-rw-r--r-- | o3d/core/cross/skin.cc | 2 | ||||
-rw-r--r-- | o3d/core/cross/skin_test.cc | 2 |
12 files changed, 40 insertions, 37 deletions
diff --git a/o3d/core/cross/bitmap.cc b/o3d/core/cross/bitmap.cc index a5feafe..947d68ea 100644 --- a/o3d/core/cross/bitmap.cc +++ b/o3d/core/cross/bitmap.cc @@ -125,7 +125,7 @@ void Bitmap::Allocate(Texture::Format format, } DCHECK(!cube_map || (width == height)); DCHECK_LE(num_mipmaps, GetMipMapCount(width, height)); - DCHECK_GT(num_mipmaps, 0); + DCHECK_GT(num_mipmaps, 0u); format_ = format; width_ = width; @@ -223,7 +223,7 @@ bool Bitmap::LoadFromFile(const FilePath &filepath, DLOG(ERROR) << "bitmap file is too large \"" << filename << "\""; return false; } - size_t file_length = file_size64; + size_t file_length = static_cast<size_t>(file_size64); // Load the compressed image data into memory MemoryBuffer<uint8> file_contents(file_length); @@ -318,7 +318,7 @@ Bitmap::ImageFileType Bitmap::GetFileTypeFromMimeType(const char *mime_type) { void Bitmap::XYZToXYZA(unsigned char *image_data, int pixel_count) { // We do this pixel by pixel, starting from the end to avoid overlapping // problems. - for (unsigned int i = pixel_count - 1; i < pixel_count; --i) { + for (int i = pixel_count - 1; i >= 0; --i) { image_data[i*4+3] = 0xff; image_data[i*4+2] = image_data[i*3+2]; image_data[i*4+1] = image_data[i*3+1]; @@ -327,7 +327,7 @@ void Bitmap::XYZToXYZA(unsigned char *image_data, int pixel_count) { } void Bitmap::RGBAToBGRA(unsigned char *image_data, int pixel_count) { - for (unsigned int i = 0; i < pixel_count; ++i) { + for (int i = 0; i < pixel_count; ++i) { unsigned char c = image_data[i*4+0]; image_data[i*4+0] = image_data[i*4+2]; image_data[i*4+2] = c; @@ -384,7 +384,7 @@ static void FilterTexel(unsigned int x, // NOTE: all of our formats use at most 4 components per pixel. // Instead of dynamically allocating a buffer for each pixel on the heap, // just allocate the worst case on the stack. - DCHECK_LE(components, 4); + DCHECK_LE(components, 4u); uint64 accum[4] = {0}; for (unsigned int src_x = src_min_x; src_x <= src_max_x; ++src_x) { for (unsigned int src_y = src_min_y; src_y <= src_max_y; ++src_y) { @@ -429,7 +429,8 @@ static void FilterTexel(unsigned int x, for (unsigned int c = 0; c < components; ++c) { uint64 value = accum[c] / (src_height * src_width); DCHECK_LE(value, 255); - dst_data[(y * dst_width + x) * components + c] = value; + dst_data[(y * dst_width + x) * components + c] = + static_cast<unsigned char>(value); } } @@ -455,7 +456,7 @@ bool Bitmap::GenerateMipmaps(unsigned int base_width, DLOG(ERROR) << "Mip-map generation not supported for format: " << format; return false; } - DCHECK_GE(std::max(base_width, base_height) >> (num_mipmaps-1), 1); + DCHECK_GE(std::max(base_width, base_height) >> (num_mipmaps-1), 1u); unsigned char *mip_data = data; unsigned int mip_width = base_width; unsigned int mip_height = base_height; diff --git a/o3d/core/cross/bitmap_png.cc b/o3d/core/cross/bitmap_png.cc index a3e10b6..de86a5d 100644 --- a/o3d/core/cross/bitmap_png.cc +++ b/o3d/core/cross/bitmap_png.cc @@ -35,7 +35,6 @@ // precompiled header must appear before anything else. #include "core/cross/precompile.h" -#include <png.h> #include <fstream> #include "core/cross/bitmap.h" #include "core/cross/types.h" @@ -44,6 +43,7 @@ #include "base/file_util.h" #include "import/cross/memory_buffer.h" #include "import/cross/memory_stream.h" +#include "png.h" using file_util::OpenFile; using file_util::CloseFile; diff --git a/o3d/core/cross/buffer_test.cc b/o3d/core/cross/buffer_test.cc index fa11f46..002c955 100644 --- a/o3d/core/cross/buffer_test.cc +++ b/o3d/core/cross/buffer_test.cc @@ -482,10 +482,10 @@ TEST_F(BufferTest, TestVertexBufferFromRawData) { // Write out the data for each field float float_data[kNumElements * 3] = { - 1.2, 2.3, 4.7, - -4.1, 3.14, 17.8, - 17.3, -4.7, -1.1 , - -0.1, 0.123, 5.720 + 1.2f, 2.3f, 4.7f, + -4.1f, 3.14f, 17.8f, + 17.3f, -4.7f, -1.1f, + -0.1f, 0.123f, 5.720f }; uint32 int_data[kNumElements * 2] = { diff --git a/o3d/core/cross/canvas_shader.cc b/o3d/core/cross/canvas_shader.cc index 1ce3aa1..9a5cb93 100644 --- a/o3d/core/cross/canvas_shader.cc +++ b/o3d/core/cross/canvas_shader.cc @@ -105,7 +105,7 @@ SkShader* CanvasLinearGradient::MakeNativeShader() { return NULL; } scoped_ptr<SkColor> colors(new SkColor[colors_.size()]); - for (int ii = 0; ii < colors_.size(); ii++) { + for (std::vector<Float4>::size_type ii = 0; ii < colors_.size(); ii++) { (colors.get())[ii] = Float4ToSkColor(colors_[ii]); } scoped_ptr<SkScalar> positions; @@ -117,7 +117,7 @@ SkShader* CanvasLinearGradient::MakeNativeShader() { return NULL; } positions.reset(new SkScalar[positions_.size()]); - for (int ii = 0; ii < positions_.size(); ii++) { + for (std::vector<float>::size_type ii = 0; ii < positions_.size(); ii++) { (positions.get())[ii] = SkFloatToScalar(positions_[ii]); } } else { diff --git a/o3d/core/cross/client.cc b/o3d/core/cross/client.cc index daa4626..341ff915 100644 --- a/o3d/core/cross/client.cc +++ b/o3d/core/cross/client.cc @@ -224,7 +224,8 @@ void Client::RenderClient() { // If nothing was rendered and there are no render graph nodes then // clear the client area. if (!rendergraph_root || rendergraph_root->children().empty()) { - renderer_->Clear(Float4(0.4, 0.3, 0.3, 1), true, 1.0, true, 0, true); + renderer_->Clear(Float4(0.4f, 0.3f, 0.3f, 1.0f), + true, 1.0, true, 0, true); } else if (rendergraph_root) { RenderTree(rendergraph_root); } @@ -259,7 +260,8 @@ void Client::RenderClient() { // Update render metrics metric_render_elapsed_time.AddSample( // Convert to ms. static_cast<int>(1000 * render_event_.elapsed_time())); - metric_render_time_seconds += render_event_.render_time(); + metric_render_time_seconds += static_cast<uint64>( + render_event_.render_time()); metric_render_xforms_culled.AddSample(render_event_.transforms_culled()); metric_render_xforms_processed.AddSample( render_event_.transforms_processed()); diff --git a/o3d/core/cross/curve_test.cc b/o3d/core/cross/curve_test.cc index f258208..e1e25d6 100644 --- a/o3d/core/cross/curve_test.cc +++ b/o3d/core/cross/curve_test.cc @@ -635,15 +635,15 @@ struct KeyInfo { } // anonymous namespace static const BezierKey bezier_data_0[] = { - { 0.083333, 3, 0.013888, -2.66667, 0.152778, 8.66667, }, - { 0.291667, 20, 0.222222, -9.22377, 0.388889, 60.9133, }, - { 0.583333, -5, 0.486111, 3.33333, 0.680556, -13.3333, } + { 0.083333f, 3, 0.013888f, -2.66667f, 0.152778f, 8.66667f, }, + { 0.291667f, 20, 0.222222f, -9.22377f, 0.388889f, 60.9133f, }, + { 0.583333f, -5, 0.486111f, 3.33333f, 0.680556f, -13.3333f, } }; static const BezierKey bezier_data_1[] = { - { 0.083333, 3, 0.013888, -2.66667, 0.152778, 8.66667, }, - { 0.291667, 20, 0.222222, -9.22377, 0.740598, 19.9773, }, - { 0.583333, -5, 0.486111, 3.33333, 0.680556, -13.3333, }, + { 0.083333f, 3, 0.013888f, -2.66667f, 0.152778f, 8.66667f, }, + { 0.291667f, 20, 0.222222f, -9.22377f, 0.740598f, 19.9773f, }, + { 0.583333f, -5, 0.486111f, 3.33333f, 0.680556f, -13.3333f, }, }; static const ExpectedResult expected_results_0[] = { @@ -798,8 +798,8 @@ TEST_F(CurveTest, CurveRawDataIncomplete) { MemoryWriteStream write_stream(buffer, kDataLength); write_stream.WriteLittleEndianInt32(1); // version 1 write_stream.WriteByte(3); // bezier - write_stream.WriteLittleEndianFloat32(3.4); - write_stream.WriteLittleEndianFloat32(1.7); + write_stream.WriteLittleEndianFloat32(3.4f); + write_stream.WriteLittleEndianFloat32(1.7f); // but DON'T write the tangent data // make note of amount we've written @@ -834,7 +834,7 @@ TEST_F(CurveTest, CurveRawDataValid) { // Write out some bezier data (one that we tested above) size_t n = arraysize(bezier_data_0); - for (int i = 0; i < n; ++i) { + for (size_t i = 0; i < n; ++i) { const BezierKey &key = bezier_data_0[i]; write_stream.WriteByte(3); // bezier diff --git a/o3d/core/cross/effect_test.cc b/o3d/core/cross/effect_test.cc index 9913ffb..af028e6 100644 --- a/o3d/core/cross/effect_test.cc +++ b/o3d/core/cross/effect_test.cc @@ -285,22 +285,22 @@ TEST_F(EffectTest, CreateAndDestroyEffect) { ParamFloat3 *lightpos = shape->CreateParam<ParamFloat3>("lightworldPos"); EXPECT_TRUE(lightpos != NULL); - lightpos->set_value(Float3(0.2, 10.5, -3.14)); + lightpos->set_value(Float3(0.2f, 10.5f, -3.14f)); ParamFloat4 *lightcolor = shape->CreateParam<ParamFloat4>("lightColor"); EXPECT_TRUE(lightcolor != NULL); - lightcolor->set_value(Float4(0.8, 0.2, 0.655, 1.0)); + lightcolor->set_value(Float4(0.8f, 0.2f, 0.655f, 1.0f)); ParamFloat4 *emissive = shape->CreateParam<ParamFloat4>("emissive"); EXPECT_TRUE(emissive != NULL); - emissive->set_value(Float4(0.0, 0.0, 0.0, 1.0)); + emissive->set_value(Float4(0.0f, 0.0f, 0.0f, 1.0f)); ParamFloat4 *ambient = shape->CreateParam<ParamFloat4>("ambient"); EXPECT_TRUE(ambient != NULL); - ambient->set_value(Float4(0.25, 0.25, 0.35, 1.0)); + ambient->set_value(Float4(0.25f, 0.25f, 0.35f, 1.0f)); String filepath = *g_program_path + "/unittest_data/rock01.tga"; Texture *texture = pack->CreateTextureFromFile(filepath, @@ -332,7 +332,7 @@ TEST_F(EffectTest, GetEffectParameters) { fx->GetParameterInfo(&info); EXPECT_EQ(arraysize(expected_params), info.size()); - for (int ii = 0; ii < info.size(); ++ii) { + for (EffectParameterInfoArray::size_type ii = 0; ii < info.size(); ++ii) { EXPECT_TRUE(IsExpectedParam(info[ii])); } @@ -354,7 +354,7 @@ TEST_F(EffectTest, GetEffectStreams) { fx->GetStreamInfo(&info); EXPECT_EQ(arraysize(expected_streams), info.size()); - for (int ii = 0; ii < info.size(); ++ii) { + for (EffectStreamInfoArray::size_type ii = 0; ii < info.size(); ++ii) { EXPECT_TRUE(IsExpectedStream(info[ii])); } diff --git a/o3d/core/cross/param.cc b/o3d/core/cross/param.cc index 9e1e157..c5e7907 100644 --- a/o3d/core/cross/param.cc +++ b/o3d/core/cross/param.cc @@ -238,7 +238,7 @@ void Param::IncrementNotCachableCountOnParamChainForInput(Param* input) { ++not_cachable_count_; ParamVector params; GetOutputs(¶ms); - for (int ii = 0; ii < params.size(); ++ii) { + for (ParamVector::size_type ii = 0; ii < params.size(); ++ii) { ++params[ii]->not_cachable_count_; } } @@ -249,7 +249,7 @@ void Param::DecrementNotCachableCountOnParamChainForInput(Param* input) { --not_cachable_count_; ParamVector params; GetOutputs(¶ms); - for (int ii = 0; ii < params.size(); ++ii) { + for (ParamVector::size_type ii = 0; ii < params.size(); ++ii) { --params[ii]->not_cachable_count_; } } diff --git a/o3d/core/cross/ray_intersection_info.cc b/o3d/core/cross/ray_intersection_info.cc index 101fed7..42bd706 100644 --- a/o3d/core/cross/ray_intersection_info.cc +++ b/o3d/core/cross/ray_intersection_info.cc @@ -37,7 +37,7 @@ namespace o3d { -static const float kEpsilon = 0.000001; +static const float kEpsilon = 0.000001f; // TODO: Someone who is better at math, please optimize this. bool RayIntersectionInfo::IntersectTriangle(const Point3& start, diff --git a/o3d/core/cross/renderer.cc b/o3d/core/cross/renderer.cc index 7301945..43362f0 100644 --- a/o3d/core/cross/renderer.cc +++ b/o3d/core/cross/renderer.cc @@ -599,7 +599,7 @@ void Renderer::PushRenderStates(State *state) { // Pops rendering states to back to their previous settings. void Renderer::PopRenderStates() { - DCHECK_GT(state_stack_.size(), 1); + DCHECK_GT(state_stack_.size(), 1u); if (state_stack_.back() != state_stack_[state_stack_.size() - 2]) { State* state = state_stack_.back(); // restore the states the top state object set. diff --git a/o3d/core/cross/skin.cc b/o3d/core/cross/skin.cc index beb28c8..99387ca 100644 --- a/o3d/core/cross/skin.cc +++ b/o3d/core/cross/skin.cc @@ -594,7 +594,7 @@ bool Skin::LoadFromBinaryData(MemoryReadStream *stream) { if (num_influences > 0) { Skin::Influences influences(num_influences); - for (int i = 0; i < num_influences; ++i) { + for (Skin::Influences::size_type i = 0; i < num_influences; ++i) { uint32 matrix_index = stream->ReadLittleEndianInt32(); float weight = stream->ReadLittleEndianFloat32(); influences[i] = Skin::Influence(matrix_index, weight); diff --git a/o3d/core/cross/skin_test.cc b/o3d/core/cross/skin_test.cc index 2f67938..46a4358 100644 --- a/o3d/core/cross/skin_test.cc +++ b/o3d/core/cross/skin_test.cc @@ -692,7 +692,7 @@ TEST_F(SkinTest, SkinRawDataValid) { const Skin::Influences& influences = influences_array[0]; EXPECT_EQ(kNumInfluences, influences.size()); - for (int i = 0; i < influences.size(); ++i) { + for (Skin::Influences::size_type i = 0; i < influences.size(); ++i) { const Skin::Influence &influence = influences[i]; EXPECT_EQ(i, influence.matrix_index); float expected_weight = 1.0f + 0.2f * static_cast<float>(i); |