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

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: Add GM suppression 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.setConfig(SkBitmap::kARGB_8888_Config, WIDTH, HEIGHT);
reed1 2014/02/13 18:57:40 nit: try using the new pattern for this: bitmap.a
237 bitmap.allocPixels();
238
239 SkCanvas canvas(bitmap);
240
241 SkRect bounds = SkRect::MakeWH(SkIntToScalar(LAYER_WIDTH), SkIntToScalar(LAY ER_HEIGHT));
242 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(WIDTH), SkIntToScalar(HEIGHT))) ;
243
244 // Check that saveLayer without the kClipToLayer_SaveFlag leaves the
245 // clip stack unchanged.
246 canvas.saveLayer(&bounds, NULL, SkCanvas::kARGB_NoClipLayer_SaveFlag);
247 SkRect clipStackBounds;
248 SkClipStack::BoundsType boundsType;
249 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType);
250 REPORTER_ASSERT(reporter, clipStackBounds.width() == WIDTH);
251 REPORTER_ASSERT(reporter, clipStackBounds.height() == HEIGHT);
252 canvas.restore();
253
254 // Check that saveLayer without the kClipToLayer_SaveFlag sets the clip
255 // stack to the layer bounds.
256 canvas.saveLayer(&bounds, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag);
257 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType);
258 REPORTER_ASSERT(reporter, clipStackBounds.width() == LAYER_WIDTH);
259 REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT);
260
261 canvas.restore();
262 }
263
229 DEF_TEST(CanvasState, reporter) { 264 DEF_TEST(CanvasState, reporter) {
230 test_complex_layers(reporter); 265 test_complex_layers(reporter);
231 test_complex_clips(reporter); 266 test_complex_clips(reporter);
232 test_draw_filters(reporter); 267 test_draw_filters(reporter);
233 test_soft_clips(reporter); 268 test_soft_clips(reporter);
269 test_saveLayer_clip(reporter);
234 } 270 }
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