OLD | NEW |
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 "CanvasStateHelpers.h" | 8 #include "CanvasStateHelpers.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkCanvasStateUtils.h" | 10 #include "SkCanvasStateUtils.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 315 |
316 SkRect bounds = SkRect::MakeWH(SkIntToScalar(LAYER_WIDTH), SkIntToScalar(LAY
ER_HEIGHT)); | 316 SkRect bounds = SkRect::MakeWH(SkIntToScalar(LAYER_WIDTH), SkIntToScalar(LAY
ER_HEIGHT)); |
317 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(WIDTH), SkIntToScalar(HEIGHT)))
; | 317 canvas.clipRect(SkRect::MakeWH(SkIntToScalar(WIDTH), SkIntToScalar(HEIGHT)))
; |
318 | 318 |
319 // Check that saveLayer without the kClipToLayer_SaveFlag leaves the | 319 // Check that saveLayer without the kClipToLayer_SaveFlag leaves the |
320 // clip stack unchanged. | 320 // clip stack unchanged. |
321 canvas.saveLayer(&bounds, nullptr, SkCanvas::kARGB_NoClipLayer_SaveFlag); | 321 canvas.saveLayer(&bounds, nullptr, SkCanvas::kARGB_NoClipLayer_SaveFlag); |
322 SkRect clipStackBounds; | 322 SkRect clipStackBounds; |
323 SkClipStack::BoundsType boundsType; | 323 SkClipStack::BoundsType boundsType; |
324 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType); | 324 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType); |
325 REPORTER_ASSERT(reporter, clipStackBounds.width() == WIDTH); | 325 // The clip stack will return its bounds, or it may be "full" : i.e. empty +
inside_out. |
326 REPORTER_ASSERT(reporter, clipStackBounds.height() == HEIGHT); | 326 // Either result is consistent with this test, since the canvas' size is WID
TH/HEIGHT |
| 327 if (SkClipStack::kInsideOut_BoundsType == boundsType) { |
| 328 REPORTER_ASSERT(reporter, clipStackBounds.isEmpty()); |
| 329 } else { |
| 330 REPORTER_ASSERT(reporter, clipStackBounds.width() == WIDTH); |
| 331 REPORTER_ASSERT(reporter, clipStackBounds.height() == HEIGHT); |
| 332 } |
327 canvas.restore(); | 333 canvas.restore(); |
328 | 334 |
329 // Check that saveLayer with the kClipToLayer_SaveFlag sets the clip | 335 // Check that saveLayer with the kClipToLayer_SaveFlag sets the clip |
330 // stack to the layer bounds. | 336 // stack to the layer bounds. |
331 canvas.saveLayer(&bounds, nullptr, SkCanvas::kARGB_ClipLayer_SaveFlag); | 337 canvas.saveLayer(&bounds, nullptr, SkCanvas::kARGB_ClipLayer_SaveFlag); |
332 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType); | 338 canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType); |
333 REPORTER_ASSERT(reporter, clipStackBounds.width() == LAYER_WIDTH); | 339 REPORTER_ASSERT(reporter, clipStackBounds.width() == LAYER_WIDTH); |
334 REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT); | 340 REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT); |
335 | 341 |
336 canvas.restore(); | 342 canvas.restore(); |
337 } | 343 } |
338 #endif | 344 #endif |
OLD | NEW |