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

Side by Side Diff: ui/gfx/canvas_direct2d_unittest.cc

Issue 8405002: ui/gfx: Convert Canvas::FillRectInt() to use gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: save some vertical space, interactive_ui_tests are fixed by Peter's fix Created 9 years, 1 month 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
« no previous file with comments | « ui/gfx/canvas_direct2d.cc ('k') | ui/gfx/canvas_skia.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <windows.h> 5 #include <windows.h>
6 #include <uxtheme.h> 6 #include <uxtheme.h>
7 #include <vsstyle.h> 7 #include <vsstyle.h>
8 #include <vssym32.h> 8 #include <vssym32.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 canvas.Restore(); 176 canvas.Restore();
177 } 177 }
178 178
179 TEST(CanvasDirect2D, SaveLayerAlpha) { 179 TEST(CanvasDirect2D, SaveLayerAlpha) {
180 if (!CheckForD2DCompatibility()) 180 if (!CheckForD2DCompatibility())
181 return; 181 return;
182 TestWindow window; 182 TestWindow window;
183 gfx::CanvasDirect2D canvas(window.rt()); 183 gfx::CanvasDirect2D canvas(window.rt());
184 184
185 canvas.Save(); 185 canvas.Save();
186 canvas.FillRectInt(SK_ColorBLUE, 20, 20, 100, 100); 186 canvas.FillRect(SK_ColorBLUE, gfx::Rect(20, 20, 100, 100));
187 canvas.SaveLayerAlpha(127); 187 canvas.SaveLayerAlpha(127);
188 canvas.FillRectInt(SK_ColorRED, 60, 60, 100, 100); 188 canvas.FillRect(SK_ColorRED, gfx::Rect(60, 60, 100, 100));
189 canvas.Restore(); 189 canvas.Restore();
190 canvas.Restore(); 190 canvas.Restore();
191 } 191 }
192 192
193 TEST(CanvasDirect2D, SaveLayerAlphaWithBounds) { 193 TEST(CanvasDirect2D, SaveLayerAlphaWithBounds) {
194 if (!CheckForD2DCompatibility()) 194 if (!CheckForD2DCompatibility())
195 return; 195 return;
196 TestWindow window; 196 TestWindow window;
197 gfx::CanvasDirect2D canvas(window.rt()); 197 gfx::CanvasDirect2D canvas(window.rt());
198 198
199 canvas.Save(); 199 canvas.Save();
200 canvas.FillRectInt(SK_ColorBLUE, 20, 20, 100, 100); 200 canvas.FillRect(SK_ColorBLUE, gfx::Rect(20, 20, 100, 100));
201 canvas.SaveLayerAlpha(127, gfx::Rect(60, 60, 50, 50)); 201 canvas.SaveLayerAlpha(127, gfx::Rect(60, 60, 50, 50));
202 canvas.FillRectInt(SK_ColorRED, 60, 60, 100, 100); 202 canvas.FillRect(SK_ColorRED, gfx::Rect(60, 60, 100, 100));
203 canvas.Restore(); 203 canvas.Restore();
204 canvas.Restore(); 204 canvas.Restore();
205 } 205 }
206 206
207 TEST(CanvasDirect2D, FillRect) { 207 TEST(CanvasDirect2D, FillRect) {
208 if (!CheckForD2DCompatibility()) 208 if (!CheckForD2DCompatibility())
209 return; 209 return;
210 TestWindow window; 210 TestWindow window;
211 gfx::CanvasDirect2D canvas(window.rt()); 211 gfx::CanvasDirect2D canvas(window.rt());
212 212
213 canvas.FillRectInt(SK_ColorRED, 20, 20, 100, 100); 213 canvas.FillRect(SK_ColorRED, gfx::Rect(20, 20, 100, 100));
214 } 214 }
215 215
216 TEST(CanvasDirect2D, ClipRect) { 216 TEST(CanvasDirect2D, ClipRect) {
217 if (!CheckForD2DCompatibility()) 217 if (!CheckForD2DCompatibility())
218 return; 218 return;
219 TestWindow window; 219 TestWindow window;
220 gfx::CanvasDirect2D canvas(window.rt()); 220 gfx::CanvasDirect2D canvas(window.rt());
221 221
222 canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500); 222 canvas.FillRect(SK_ColorGREEN, gfx::Rect(0, 0, 500, 500));
223 canvas.ClipRect(gfx::Rect(20, 20, 120, 120)); 223 canvas.ClipRect(gfx::Rect(20, 20, 120, 120));
224 canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); 224 canvas.FillRect(SK_ColorBLUE, gfx::Rect(0, 0, 500, 500));
225 } 225 }
226 226
227 TEST(CanvasDirect2D, ClipRectWithTranslate) { 227 TEST(CanvasDirect2D, ClipRectWithTranslate) {
228 if (!CheckForD2DCompatibility()) 228 if (!CheckForD2DCompatibility())
229 return; 229 return;
230 TestWindow window; 230 TestWindow window;
231 gfx::CanvasDirect2D canvas(window.rt()); 231 gfx::CanvasDirect2D canvas(window.rt());
232 232
233 // Repeat the same rendering as in ClipRect... 233 // Repeat the same rendering as in ClipRect...
234 canvas.Save(); 234 canvas.Save();
235 canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500); 235 canvas.FillRect(SK_ColorGREEN, gfx::Rect(0, 0, 500, 500));
236 canvas.ClipRect(gfx::Rect(20, 20, 120, 120)); 236 canvas.ClipRect(gfx::Rect(20, 20, 120, 120));
237 canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); 237 canvas.FillRect(SK_ColorBLUE, gfx::Rect(0, 0, 500, 500));
238 canvas.Restore(); 238 canvas.Restore();
239 239
240 // ... then translate, clip and fill again relative to the new origin. 240 // ... then translate, clip and fill again relative to the new origin.
241 canvas.Save(); 241 canvas.Save();
242 canvas.Translate(gfx::Point(150, 150)); 242 canvas.Translate(gfx::Point(150, 150));
243 canvas.ClipRect(gfx::Rect(10, 10, 110, 110)); 243 canvas.ClipRect(gfx::Rect(10, 10, 110, 110));
244 canvas.FillRectInt(SK_ColorRED, 0, 0, 500, 500); 244 canvas.FillRect(SK_ColorRED, gfx::Rect(0, 0, 500, 500));
245 canvas.Restore(); 245 canvas.Restore();
246 } 246 }
247 247
248 TEST(CanvasDirect2D, ClipRectWithScale) { 248 TEST(CanvasDirect2D, ClipRectWithScale) {
249 if (!CheckForD2DCompatibility()) 249 if (!CheckForD2DCompatibility())
250 return; 250 return;
251 TestWindow window; 251 TestWindow window;
252 gfx::CanvasDirect2D canvas(window.rt()); 252 gfx::CanvasDirect2D canvas(window.rt());
253 253
254 // Repeat the same rendering as in ClipRect... 254 // Repeat the same rendering as in ClipRect...
255 canvas.Save(); 255 canvas.Save();
256 canvas.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500); 256 canvas.FillRect(SK_ColorGREEN, gfx::Rect(0, 0, 500, 500));
257 canvas.ClipRect(gfx::Rect(20, 20, 120, 120)); 257 canvas.ClipRect(gfx::Rect(20, 20, 120, 120));
258 canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); 258 canvas.FillRect(SK_ColorBLUE, gfx::Rect(0, 0, 500, 500));
259 canvas.Restore(); 259 canvas.Restore();
260 260
261 // ... then translate and scale, clip and fill again relative to the new 261 // ... then translate and scale, clip and fill again relative to the new
262 // origin. 262 // origin.
263 canvas.Save(); 263 canvas.Save();
264 canvas.Translate(gfx::Point(150, 150)); 264 canvas.Translate(gfx::Point(150, 150));
265 canvas.Scale(2, 2); 265 canvas.Scale(2, 2);
266 canvas.ClipRect(gfx::Rect(10, 10, 110, 110)); 266 canvas.ClipRect(gfx::Rect(10, 10, 110, 110));
267 canvas.FillRectInt(SK_ColorRED, 0, 0, 500, 500); 267 canvas.FillRect(SK_ColorRED, gfx::Rect(0, 0, 500, 500));
268 canvas.Restore(); 268 canvas.Restore();
269 } 269 }
270 270
271 TEST(CanvasDirect2D, DrawRectInt) { 271 TEST(CanvasDirect2D, DrawRectInt) {
272 if (!CheckForD2DCompatibility()) 272 if (!CheckForD2DCompatibility())
273 return; 273 return;
274 TestWindow window; 274 TestWindow window;
275 gfx::CanvasDirect2D canvas(window.rt()); 275 gfx::CanvasDirect2D canvas(window.rt());
276 276
277 canvas.Save(); 277 canvas.Save();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 return; 323 return;
324 TestWindow window; 324 TestWindow window;
325 gfx::CanvasDirect2D canvas(window.rt()); 325 gfx::CanvasDirect2D canvas(window.rt());
326 326
327 SkBitmap bitmap = LoadBitmapFromResources(IDR_BITMAP_BRUSH_IMAGE); 327 SkBitmap bitmap = LoadBitmapFromResources(IDR_BITMAP_BRUSH_IMAGE);
328 328
329 canvas.Save(); 329 canvas.Save();
330 canvas.TileImageInt(bitmap, 10, 10, 300, 300); 330 canvas.TileImageInt(bitmap, 10, 10, 300, 300);
331 canvas.Restore(); 331 canvas.Restore();
332 } 332 }
OLDNEW
« no previous file with comments | « ui/gfx/canvas_direct2d.cc ('k') | ui/gfx/canvas_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698