OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/texture_draw_quad.h" | 5 #include "cc/texture_draw_quad.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 namespace cc { | 9 namespace cc { |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 | 54 |
55 const TextureDrawQuad* TextureDrawQuad::MaterialCast( | 55 const TextureDrawQuad* TextureDrawQuad::MaterialCast( |
56 const DrawQuad* quad) { | 56 const DrawQuad* quad) { |
57 DCHECK(quad->material == DrawQuad::TEXTURE_CONTENT); | 57 DCHECK(quad->material == DrawQuad::TEXTURE_CONTENT); |
58 return static_cast<const TextureDrawQuad*>(quad); | 58 return static_cast<const TextureDrawQuad*>(quad); |
59 } | 59 } |
60 | 60 |
61 bool TextureDrawQuad::PerformClipping() { | 61 bool TextureDrawQuad::PerformClipping() { |
62 // This only occurs if the rect is only scaled and translated (and thus still | 62 // This only occurs if the rect is only scaled and translated (and thus still |
63 // axis aligned). | 63 // axis aligned). |
64 if (!quadTransform().IsScaleOrTranslation()) | 64 if (!quadTransform().IsPositiveScaleOrTranslation()) |
65 return false; | 65 return false; |
66 | 66 |
67 // Grab our scale and make sure it's positive. | 67 // Grab our scale and make sure it's positive. |
68 float x_scale = quadTransform().matrix().getDouble(0,0); | 68 float x_scale = static_cast<float>(quadTransform().matrix().getDouble(0, 0)); |
shawnsingh
2012/12/18 19:11:00
don't forget to make these variables double as jam
whunt
2012/12/18 19:48:15
This is a slightly different piece of code than Ja
| |
69 float y_scale = quadTransform().matrix().getDouble(1,1); | 69 float y_scale = static_cast<float>(quadTransform().matrix().getDouble(1, 1)); |
70 if (x_scale <= 0.0f || y_scale <= 0.0f) | |
71 return false; | |
72 | 70 |
73 // Grab our offset. | 71 // Grab our offset. |
74 gfx::Vector2dF offset( | 72 gfx::Vector2dF offset( |
75 quadTransform().matrix().getDouble(0,3), | 73 static_cast<float>(quadTransform().matrix().getDouble(0, 3)), |
76 quadTransform().matrix().getDouble(1,3)); | 74 static_cast<float>(quadTransform().matrix().getDouble(1, 3))); |
77 | 75 |
78 // Transform the rect by the scale and offset. | 76 // Transform the rect by the scale and offset. |
79 gfx::RectF rectF = rect; | 77 gfx::RectF rectF = rect; |
80 rectF.Scale(x_scale, y_scale); | 78 rectF.Scale(x_scale, y_scale); |
81 rectF += offset; | 79 rectF += offset; |
82 | 80 |
83 // Perform clipping and check to see if the result is empty. | 81 // Perform clipping and check to see if the result is empty. |
84 gfx::RectF clippedRect = IntersectRects(rectF, clipRect()); | 82 gfx::RectF clippedRect = IntersectRects(rectF, clipRect()); |
85 if (clippedRect.IsEmpty()) { | 83 if (clippedRect.IsEmpty()) { |
86 rect = gfx::Rect(); | 84 rect = gfx::Rect(); |
(...skipping 13 matching lines...) Expand all Loading... | |
100 clippedRect.Scale(1.0f / x_scale, 1.0f / y_scale); | 98 clippedRect.Scale(1.0f / x_scale, 1.0f / y_scale); |
101 rect = gfx::Rect( | 99 rect = gfx::Rect( |
102 static_cast<int>(clippedRect.x() + 0.5f), | 100 static_cast<int>(clippedRect.x() + 0.5f), |
103 static_cast<int>(clippedRect.y() + 0.5f), | 101 static_cast<int>(clippedRect.y() + 0.5f), |
104 static_cast<int>(clippedRect.width() + 0.5f), | 102 static_cast<int>(clippedRect.width() + 0.5f), |
105 static_cast<int>(clippedRect.height() + 0.5f)); | 103 static_cast<int>(clippedRect.height() + 0.5f)); |
106 return true; | 104 return true; |
107 } | 105 } |
108 | 106 |
109 } // namespace cc | 107 } // namespace cc |
OLD | NEW |