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

Side by Side Diff: cc/nine_patch_layer_impl_unittest.cc

Issue 11783094: cc: Add point-based UV coordinate on TextureLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unittest for clipped texture quad Created 7 years, 11 months 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "cc/nine_patch_layer_impl.h" 7 #include "cc/nine_patch_layer_impl.h"
8 8
9 #include "cc/append_quads_data.h" 9 #include "cc/append_quads_data.h"
10 #include "cc/single_thread_proxy.h" 10 #include "cc/single_thread_proxy.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 EXPECT_RECT_EQ(scaledApertureNonUniform, remaining.bounds()); 75 EXPECT_RECT_EQ(scaledApertureNonUniform, remaining.bounds());
76 Region scaledApertureRegion(scaledApertureNonUniform); 76 Region scaledApertureRegion(scaledApertureNonUniform);
77 EXPECT_EQ(scaledApertureRegion, remaining); 77 EXPECT_EQ(scaledApertureRegion, remaining);
78 78
79 // Verify UV rects 79 // Verify UV rects
80 gfx::Rect bitmapRect(gfx::Point(), bitmapSize); 80 gfx::Rect bitmapRect(gfx::Point(), bitmapSize);
81 Region texRemaining(bitmapRect); 81 Region texRemaining(bitmapRect);
82 for (size_t i = 0; i < quads.size(); ++i) { 82 for (size_t i = 0; i < quads.size(); ++i) {
83 DrawQuad* quad = quads[i]; 83 DrawQuad* quad = quads[i];
84 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad); 84 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad);
85 gfx::RectF texRect = texQuad->uv_rect; 85 gfx::RectF texRect = BoundingRect(texQuad->uv_top_left, texQuad->uv_bott om_right);
danakj 2013/01/15 01:48:42 nit: gfx::BoundingRect
Jerome 2013/01/15 17:58:12 Done.
86 texRect.Scale(bitmapSize.width(), bitmapSize.height()); 86 texRect.Scale(bitmapSize.width(), bitmapSize.height());
87 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); 87 texRemaining.Subtract(Region(ToRoundedIntRect(texRect)));
88 } 88 }
89 EXPECT_RECT_EQ(apertureRect, texRemaining.bounds()); 89 EXPECT_RECT_EQ(apertureRect, texRemaining.bounds());
90 Region apertureRegion(apertureRect); 90 Region apertureRegion(apertureRect);
91 EXPECT_EQ(apertureRegion, texRemaining); 91 EXPECT_EQ(apertureRegion, texRemaining);
92 } 92 }
93 93
94 TEST(NinePatchLayerImplTest, verifyDrawQuadsForSqueezedLayer) 94 TEST(NinePatchLayerImplTest, verifyDrawQuadsForSqueezedLayer)
95 { 95 {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 Region expectedFull(visibleContentRect); 128 Region expectedFull(visibleContentRect);
129 EXPECT_EQ(expectedFull, filled); 129 EXPECT_EQ(expectedFull, filled);
130 130
131 // Verify UV rects cover the corners of the bitmap and the crop is weighted 131 // Verify UV rects cover the corners of the bitmap and the crop is weighted
132 // proportionately to the relative corner sizes (for uneven apertures). 132 // proportionately to the relative corner sizes (for uneven apertures).
133 gfx::Rect bitmapRect(gfx::Point(), bitmapSize); 133 gfx::Rect bitmapRect(gfx::Point(), bitmapSize);
134 Region texRemaining(bitmapRect); 134 Region texRemaining(bitmapRect);
135 for (size_t i = 0; i < quads.size(); ++i) { 135 for (size_t i = 0; i < quads.size(); ++i) {
136 DrawQuad* quad = quads[i]; 136 DrawQuad* quad = quads[i];
137 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad); 137 const TextureDrawQuad* texQuad = TextureDrawQuad::MaterialCast(quad);
138 gfx::RectF texRect = texQuad->uv_rect; 138 gfx::RectF texRect = BoundingRect(texQuad->uv_top_left, texQuad->uv_bott om_right);
danakj 2013/01/15 01:48:42 nit: gfx::BoundingRect
Jerome 2013/01/15 17:58:12 Done.
139 texRect.Scale(bitmapSize.width(), bitmapSize.height()); 139 texRect.Scale(bitmapSize.width(), bitmapSize.height());
140 texRemaining.Subtract(Region(ToRoundedIntRect(texRect))); 140 texRemaining.Subtract(Region(ToRoundedIntRect(texRect)));
141 } 141 }
142 Region expectedRemainingRegion = Region(gfx::Rect(bitmapSize)); 142 Region expectedRemainingRegion = Region(gfx::Rect(bitmapSize));
143 expectedRemainingRegion.Subtract(gfx::Rect(0, 0, 17, 28)); 143 expectedRemainingRegion.Subtract(gfx::Rect(0, 0, 17, 28));
144 expectedRemainingRegion.Subtract(gfx::Rect(67, 0, 34, 28)); 144 expectedRemainingRegion.Subtract(gfx::Rect(67, 0, 34, 28));
145 expectedRemainingRegion.Subtract(gfx::Rect(0, 78, 17, 23)); 145 expectedRemainingRegion.Subtract(gfx::Rect(0, 78, 17, 23));
146 expectedRemainingRegion.Subtract(gfx::Rect(67, 78, 34, 23)); 146 expectedRemainingRegion.Subtract(gfx::Rect(67, 78, 34, 23));
147 EXPECT_EQ(expectedRemainingRegion, texRemaining); 147 EXPECT_EQ(expectedRemainingRegion, texRemaining);
148 } 148 }
149 149
150 } // namespace 150 } // namespace
151 } // namespace cc 151 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698