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

Side by Side Diff: tests/CanvasStateTest.cpp

Issue 164203002: Don't modify the clipstack in saveLayer() if the kClipToLayer_SaveFlag is (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Use allocN32Pixels() shortcut. Created 6 years, 10 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
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapDevice.h" 8 #include "SkBitmapDevice.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkCanvasStateUtils.h" 10 #include "SkCanvasStateUtils.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 SkSetErrorCallback(error_callback, NULL); 220 SkSetErrorCallback(error_callback, NULL);
221 221
222 SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas); 222 SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas);
223 REPORTER_ASSERT(reporter, !state); 223 REPORTER_ASSERT(reporter, !state);
224 224
225 REPORTER_ASSERT(reporter, kInvalidOperation_SkError == SkGetLastError()); 225 REPORTER_ASSERT(reporter, kInvalidOperation_SkError == SkGetLastError());
226 SkClearLastError(); 226 SkClearLastError();
227 } 227 }
228 228
229 static void test_saveLayer_clip(skiatest::Reporter* reporter) {
230 const int WIDTH = 100;
231 const int HEIGHT = 100;
232 const int LAYER_WIDTH = 50;
233 const int LAYER_HEIGHT = 50;
234
235 SkBitmap bitmap;
236 bitmap.allocN32Pixels(WIDTH, HEIGHT);
237 SkCanvas canvas(bitmap);
238
239 SkRect bounds = SkRect::MakeWH(SkIntToScalar(LAYER_WIDTH), SkIntToScalar(LAY ER_HEIGHT));
240 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(WIDTH), SkIntToScalar(HEIGHT))) ;
241
242 // Check that saveLayer without the kClipToLayer_SaveFlag leaves the
243 // clip stack unchanged.
244 canvas.saveLayer(&bounds, NULL, SkCanvas::kARGB_NoClipLayer_SaveFlag);
245 SkRect clipStackBounds;
246 SkClipStack::BoundsType boundsType;
247 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType);
248 REPORTER_ASSERT(reporter, clipStackBounds.width() == WIDTH);
249 REPORTER_ASSERT(reporter, clipStackBounds.height() == HEIGHT);
250 canvas.restore();
251
robertphillips 2014/02/13 19:12:34 without -> with in comment?
252 // Check that saveLayer without the kClipToLayer_SaveFlag sets the clip
253 // stack to the layer bounds.
254 canvas.saveLayer(&bounds, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag);
255 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType);
256 REPORTER_ASSERT(reporter, clipStackBounds.width() == LAYER_WIDTH);
257 REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT);
258
259 canvas.restore();
260 }
261
229 DEF_TEST(CanvasState, reporter) { 262 DEF_TEST(CanvasState, reporter) {
230 test_complex_layers(reporter); 263 test_complex_layers(reporter);
231 test_complex_clips(reporter); 264 test_complex_clips(reporter);
232 test_draw_filters(reporter); 265 test_draw_filters(reporter);
233 test_soft_clips(reporter); 266 test_soft_clips(reporter);
267 test_saveLayer_clip(reporter);
234 } 268 }
OLDNEW
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698