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

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

Issue 8383028: ui/gfx: Convert Canvas::ClipRectInt() to use gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 canvas.FillRectInt(SK_ColorRED, 20, 20, 100, 100); 213 canvas.FillRectInt(SK_ColorRED, 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.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500);
223 canvas.ClipRectInt(20, 20, 120, 120); 223 canvas.ClipRectInt(gfx::Rect(20, 20, 120, 120));
224 canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); 224 canvas.FillRectInt(SK_ColorBLUE, 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.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500);
236 canvas.ClipRectInt(20, 20, 120, 120); 236 canvas.ClipRectInt(gfx::Rect(20, 20, 120, 120));
237 canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); 237 canvas.FillRectInt(SK_ColorBLUE, 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.TranslateInt(150, 150); 242 canvas.TranslateInt(150, 150);
243 canvas.ClipRectInt(10, 10, 110, 110); 243 canvas.ClipRectInt(gfx::Rect(10, 10, 110, 110));
244 canvas.FillRectInt(SK_ColorRED, 0, 0, 500, 500); 244 canvas.FillRectInt(SK_ColorRED, 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.FillRectInt(SK_ColorGREEN, 0, 0, 500, 500);
257 canvas.ClipRectInt(20, 20, 120, 120); 257 canvas.ClipRectInt(gfx::Rect(20, 20, 120, 120));
258 canvas.FillRectInt(SK_ColorBLUE, 0, 0, 500, 500); 258 canvas.FillRectInt(SK_ColorBLUE, 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.TranslateInt(150, 150); 264 canvas.TranslateInt(150, 150);
265 canvas.ScaleInt(2, 2); 265 canvas.ScaleInt(2, 2);
266 canvas.ClipRectInt(10, 10, 110, 110); 266 canvas.ClipRectInt(gfx::Rect(10, 10, 110, 110));
267 canvas.FillRectInt(SK_ColorRED, 0, 0, 500, 500); 267 canvas.FillRectInt(SK_ColorRED, 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
(...skipping 46 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

Powered by Google App Engine
This is Rietveld 408576698