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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 const TextureDrawQuad* TextureDrawQuad::MaterialCast(const DrawQuad* quad) { | 59 const TextureDrawQuad* TextureDrawQuad::MaterialCast(const DrawQuad* quad) { |
60 DCHECK(quad->material == DrawQuad::TEXTURE_CONTENT); | 60 DCHECK(quad->material == DrawQuad::TEXTURE_CONTENT); |
61 return static_cast<const TextureDrawQuad*>(quad); | 61 return static_cast<const TextureDrawQuad*>(quad); |
62 } | 62 } |
63 | 63 |
64 bool TextureDrawQuad::PerformClipping() { | 64 bool TextureDrawQuad::PerformClipping() { |
65 // This only occurs if the rect is only scaled and translated (and thus still | 65 // This only occurs if the rect is only scaled and translated (and thus still |
66 // axis aligned). | 66 // axis aligned). |
67 if (!quadTransform().IsScaleOrTranslation()) | 67 if (!quadTransform().IsPositiveScaleOrTranslation()) |
68 return false; | 68 return false; |
69 | 69 |
70 // Grab our scale and make sure it's positive. | 70 // Grab our scale and make sure it's positive. |
71 float x_scale = quadTransform().matrix().getDouble(0, 0); | 71 float x_scale = static_cast<float>(quadTransform().matrix().getDouble(0, 0)); |
72 float y_scale = quadTransform().matrix().getDouble(1, 1); | 72 float y_scale = static_cast<float>(quadTransform().matrix().getDouble(1, 1)); |
73 if (x_scale <= 0.0f || y_scale <= 0.0f) | |
74 return false; | |
75 | 73 |
76 // Grab our offset. | 74 // Grab our offset. |
77 gfx::Vector2dF offset(quadTransform().matrix().getDouble(0, 3), | 75 gfx::Vector2dF offset( |
78 quadTransform().matrix().getDouble(1, 3)); | 76 static_cast<float>(quadTransform().matrix().getDouble(0, 3)), |
| 77 static_cast<float>(quadTransform().matrix().getDouble(1, 3))); |
79 | 78 |
80 // Transform the rect by the scale and offset. | 79 // Transform the rect by the scale and offset. |
81 gfx::RectF rectF = rect; | 80 gfx::RectF rectF = rect; |
82 rectF.Scale(x_scale, y_scale); | 81 rectF.Scale(x_scale, y_scale); |
83 rectF += offset; | 82 rectF += offset; |
84 | 83 |
85 // Perform clipping and check to see if the result is empty. | 84 // Perform clipping and check to see if the result is empty. |
86 gfx::RectF clippedRect = IntersectRects(rectF, clipRect()); | 85 gfx::RectF clippedRect = IntersectRects(rectF, clipRect()); |
87 if (clippedRect.IsEmpty()) { | 86 if (clippedRect.IsEmpty()) { |
88 rect = gfx::Rect(); | 87 rect = gfx::Rect(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 clippedRect -= offset; | 123 clippedRect -= offset; |
125 clippedRect.Scale(1.0f / x_scale, 1.0f / y_scale); | 124 clippedRect.Scale(1.0f / x_scale, 1.0f / y_scale); |
126 rect = gfx::Rect(static_cast<int>(clippedRect.x() + 0.5f), | 125 rect = gfx::Rect(static_cast<int>(clippedRect.x() + 0.5f), |
127 static_cast<int>(clippedRect.y() + 0.5f), | 126 static_cast<int>(clippedRect.y() + 0.5f), |
128 static_cast<int>(clippedRect.width() + 0.5f), | 127 static_cast<int>(clippedRect.width() + 0.5f), |
129 static_cast<int>(clippedRect.height() + 0.5f)); | 128 static_cast<int>(clippedRect.height() + 0.5f)); |
130 return true; | 129 return true; |
131 } | 130 } |
132 | 131 |
133 } // namespace cc | 132 } // namespace cc |
OLD | NEW |