Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: cc/texture_draw_quad.cc

Issue 11418297: Clipping textured quads explicitly without scissoring (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: using static cast Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 this->uv_rect = uv_rect; 51 this->uv_rect = uv_rect;
52 this->flipped = flipped; 52 this->flipped = flipped;
53 } 53 }
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 const TextureDrawQuad::PerformClipping()
62 {
jamesr 2012/12/05 23:19:45 { goes on the previous line
63 // This only occurs if the rect is only scaled and translated (and thus still axis alinged).
jamesr 2012/12/05 23:19:45 typo "alinged" -> "aligned"
64 if (quadTransform().IsScaleOrTranslation())
jamesr 2012/12/05 23:19:45 you'd have slightly less indentation if this was p
65 {
jamesr 2012/12/05 23:19:45 { goes on the previous line
66 // Grab our scale and offset.
67 float x_scale = quadTransform().matrix().getDouble(0,0);
68 float y_scale = quadTransform().matrix().getDouble(1,1);
69 gfx::Vector2dF offset(
70 quadTransform().matrix().getDouble(0,3),
jamesr 2012/12/05 23:19:45 continuations should have 4-space indents
71 quadTransform().matrix().getDouble(1,3));
72
73 // Transform the rect by the scale and offset.
74 gfx::RectF rectF = rect;
75 rectF.Scale(x_scale, y_scale);
76 rectF += offset;
77
78 // Perform clipping and check to see if the result is empty.
79 gfx::RectF clippedRect = IntersectRects(rectF, clipRect());
80 if (clippedRect.IsEmpty())
81 {
jamesr 2012/12/05 23:19:45 { on previous line
82 rect = gfx::Rect();
83 uv_rect = gfx::RectF();
84 return true;
85 }
86
87 // Create a new uv-rect by clipping the old one to the new bounds.
88 uv_rect = gfx::RectF(
89 uv_rect.x() + uv_rect.width () / rectF.width () * (clippedRect.x() - rectF .x()),
jamesr 2012/12/05 23:19:45 continuations should be indented 4 spaces from pre
90 uv_rect.y() + uv_rect.height() / rectF.height() * (clippedRect.y() - rectF .y()),
91 uv_rect.width () / rectF.width () * clippedRect.width (),
92 uv_rect.height() / rectF.height() * clippedRect.height());
93
94 // Move the clipped rectangle back into its space.
95 clippedRect -= offset;
96 clippedRect.Scale(1.0f / x_scale, 1.0f / y_scale);
97 rect = gfx::Rect(
98 static_cast<int>(clippedRect.x() + 0.5f),
jamesr 2012/12/05 23:19:45 4 space indent
99 static_cast<int>(clippedRect.y() + 0.5f),
100 static_cast<int>(clippedRect.width() + 0.5f),
101 static_cast<int>(clippedRect.height() + 0.5f));
102 return true;
103 }
104 return false;
105 }
106
61 } // namespace cc 107 } // namespace cc
OLDNEW
« cc/texture_draw_quad.h ('K') | « cc/texture_draw_quad.h ('k') | cc/texture_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698