diff options
author | Mike Reed <reed@google.com> | 2017-01-23 11:39:45 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-01-23 17:14:53 +0000 |
commit | 918e144408ba218df919528f8b48c544f4767883 (patch) | |
tree | af398e3c3a1f779024a0d60d6db43aadb58e29ac | |
parent | 9adfef8680c22ce8980031b4bcb9f1fadd066a80 (diff) |
change clip-bounds getters to always return the rect
(actually fixes undefined result in getClipBounds)
future CLs
- update all callers to new apis
- move/rename virtuals
BUG=skia:
DOCS_PREVIEW= https://skia.org/?cl=7400
Change-Id: I45b93014e915c0d1c36d97d948c9ac8931f23258
Reviewed-on: https://skia-review.googlesource.com/7400
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Mike Reed <reed@google.com>
-rw-r--r-- | bench/ChromeBench.cpp | 5 | ||||
-rw-r--r-- | bench/SKPAnimationBench.cpp | 3 | ||||
-rw-r--r-- | bench/SKPBench.cpp | 4 | ||||
-rw-r--r-- | gm/complexclip_blur_tiled.cpp | 5 | ||||
-rw-r--r-- | gm/imageblurtiled.cpp | 5 | ||||
-rw-r--r-- | gm/imageresizetiled.cpp | 2 | ||||
-rw-r--r-- | include/core/SkCanvas.h | 29 | ||||
-rw-r--r-- | site/user/api/skpaint.md | 6 | ||||
-rw-r--r-- | src/core/SkBigPicture.cpp | 4 | ||||
-rw-r--r-- | src/core/SkCanvas.cpp | 13 | ||||
-rw-r--r-- | src/core/SkPicturePlayback.cpp | 9 | ||||
-rw-r--r-- | src/core/SkRecordDraw.cpp | 7 | ||||
-rw-r--r-- | src/core/SkRecordedDrawable.cpp | 3 | ||||
-rw-r--r-- | src/utils/SkPaintFilterCanvas.cpp | 4 | ||||
-rw-r--r-- | tests/CanvasStateTest.cpp | 4 | ||||
-rw-r--r-- | tests/CanvasTest.cpp | 27 | ||||
-rw-r--r-- | tests/PictureTest.cpp | 26 | ||||
-rw-r--r-- | tools/debugger/SkDebugCanvas.cpp | 5 | ||||
-rw-r--r-- | tools/skhello.cpp | 3 |
19 files changed, 80 insertions, 84 deletions
diff --git a/bench/ChromeBench.cpp b/bench/ChromeBench.cpp index 94c3f2587c..60d86f9a42 100644 --- a/bench/ChromeBench.cpp +++ b/bench/ChromeBench.cpp @@ -480,10 +480,11 @@ protected: SkIntToScalar(gmailScrollingRectSpec[i*3+1]), SkIntToScalar(gmailScrollingRectSpec[i*3+2])); } void validateBounds(SkCanvas* canvas) { - SkIRect bounds; - canvas->getClipDeviceBounds(&bounds); +#ifdef SK_DEBUG + SkIRect bounds = canvas->getDeviceClipBounds(); SkASSERT(bounds.right()-bounds.left() >= W); SkASSERT(bounds.bottom()-bounds.top() >= H); +#endif } diff --git a/bench/SKPAnimationBench.cpp b/bench/SKPAnimationBench.cpp index 1a1ca447e5..9aa7ba3ccf 100644 --- a/bench/SKPAnimationBench.cpp +++ b/bench/SKPAnimationBench.cpp @@ -23,7 +23,8 @@ const char* SKPAnimationBench::onGetUniqueName() { void SKPAnimationBench::onPerCanvasPreDraw(SkCanvas* canvas) { INHERITED::onPerCanvasPreDraw(canvas); - SkAssertResult(canvas->getClipDeviceBounds(&fDevBounds)); + fDevBounds = canvas->getDeviceClipBounds(); + SkAssertResult(!fDevBounds.isEmpty()); fAnimationTimer.start(); } diff --git a/bench/SKPBench.cpp b/bench/SKPBench.cpp index 9d4dcc5b1a..013ec53cda 100644 --- a/bench/SKPBench.cpp +++ b/bench/SKPBench.cpp @@ -50,8 +50,8 @@ const char* SKPBench::onGetUniqueName() { } void SKPBench::onPerCanvasPreDraw(SkCanvas* canvas) { - SkIRect bounds; - SkAssertResult(canvas->getClipDeviceBounds(&bounds)); + SkIRect bounds = canvas->getDeviceClipBounds(); + SkAssertResult(!bounds.isEmpty()); const bool gpu = canvas->getGrContext() != nullptr; int tileW = gpu ? FLAGS_GPUbenchTileW : FLAGS_CPUbenchTileW, diff --git a/gm/complexclip_blur_tiled.cpp b/gm/complexclip_blur_tiled.cpp index 611212d450..b2b206133e 100644 --- a/gm/complexclip_blur_tiled.cpp +++ b/gm/complexclip_blur_tiled.cpp @@ -34,10 +34,7 @@ protected: SkPaint blurPaint; blurPaint.setImageFilter(SkBlurImageFilter::Make(5.0f, 5.0f, nullptr)); const SkScalar tileSize = SkIntToScalar(128); - SkRect bounds; - if (!canvas->getClipBounds(&bounds)) { - bounds.setEmpty(); - } + SkRect bounds = canvas->getLocalClipBounds(); int ts = SkScalarCeilToInt(tileSize); SkImageInfo info = SkImageInfo::MakeN32Premul(ts, ts); auto tileSurface(canvas->makeSurface(info)); diff --git a/gm/imageblurtiled.cpp b/gm/imageblurtiled.cpp index 415fa7315a..bf5d3d1104 100644 --- a/gm/imageblurtiled.cpp +++ b/gm/imageblurtiled.cpp @@ -33,10 +33,7 @@ protected: SkPaint paint; paint.setImageFilter(SkBlurImageFilter::Make(fSigmaX, fSigmaY, nullptr)); const SkScalar tileSize = SkIntToScalar(128); - SkRect bounds; - if (!canvas->getClipBounds(&bounds)) { - bounds.setEmpty(); - } + SkRect bounds = canvas->getLocalClipBounds(); for (SkScalar y = bounds.top(); y < bounds.bottom(); y += tileSize) { for (SkScalar x = bounds.left(); x < bounds.right(); x += tileSize) { canvas->save(); diff --git a/gm/imageresizetiled.cpp b/gm/imageresizetiled.cpp index 3c70a2c585..fcbb7e43d1 100644 --- a/gm/imageresizetiled.cpp +++ b/gm/imageresizetiled.cpp @@ -22,8 +22,6 @@ DEF_SIMPLE_GM(imageresizetiled, canvas, WIDTH, HEIGHT) { kNone_SkFilterQuality, nullptr)); const SkScalar tile_size = SkIntToScalar(100); - SkRect bounds; - canvas->getClipBounds(&bounds); for (SkScalar y = 0; y < HEIGHT; y += tile_size) { for (SkScalar x = 0; x < WIDTH; x += tile_size) { canvas->save(); diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 6b3d6aa719..a52ad1230a 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -526,17 +526,28 @@ public: */ bool quickReject(const SkPath& path) const; - /** Return the bounds of the current clip (in local coordinates) in the - bounds parameter, and return true if it is non-empty. This can be useful - in a way similar to quickReject, in that it tells you that drawing - outside of these bounds will be clipped out. - */ + /** + * Return the bounds of the current clip in local coordinates. If the clip is empty, + * return { 0, 0, 0, 0 }. + */ + SkRect getLocalClipBounds() const { + SkRect bounds; + this->getClipBounds(&bounds); + return bounds; + } + // TODO: move this to protected and rename to onGetLocalClipBounds virtual bool getClipBounds(SkRect* bounds) const; - /** Return the bounds of the current clip, in device coordinates; returns - true if non-empty. Maybe faster than getting the clip explicitly and - then taking its bounds. - */ + /** + * Return the bounds of the current clip in device coordinates. If the clip is empty, + * return { 0, 0, 0, 0 }. + */ + SkIRect getDeviceClipBounds() const { + SkIRect bounds; + this->getClipDeviceBounds(&bounds); + return bounds; + } + // TODO: move this to protected and rename to onGetDeviceClipBounds virtual bool getClipDeviceBounds(SkIRect* bounds) const; /** Fill the entire canvas' bitmap (restricted to the current clip) with the diff --git a/site/user/api/skpaint.md b/site/user/api/skpaint.md index 48f84588e6..a1e17eed26 100644 --- a/site/user/api/skpaint.md +++ b/site/user/api/skpaint.md @@ -504,8 +504,7 @@ SkPathEffect paint.setPathEffect(SkPath2DPathEffect::Make(matrix, path)); paint.setAntiAlias(true); canvas->clear(SK_ColorWHITE); - SkRect bounds; - (void)canvas->getClipBounds(&bounds); + SkRect bounds = canvas->getLocalClipBounds(); bounds.outset(2 * scale, 2 * scale); canvas->drawRect(bounds, paint); } @@ -525,8 +524,7 @@ SkPathEffect lattice.preRotate(30.0f); paint.setPathEffect(SkLine2DPathEffect::Make(0.0f, lattice)); paint.setAntiAlias(true); - SkRect bounds; - (void)canvas->getClipBounds(&bounds); + SkRect bounds = canvas->getLocalClipBounds(); bounds.outset(8.0f, 8.0f); canvas->clear(SK_ColorWHITE); canvas->drawRect(bounds, paint); diff --git a/src/core/SkBigPicture.cpp b/src/core/SkBigPicture.cpp index 2a2e438fd6..1281b5bc9f 100644 --- a/src/core/SkBigPicture.cpp +++ b/src/core/SkBigPicture.cpp @@ -28,9 +28,7 @@ void SkBigPicture::playback(SkCanvas* canvas, AbortCallback* callback) const { SkASSERT(canvas); // If the query contains the whole picture, don't bother with the BBH. - SkRect clipBounds = { 0, 0, 0, 0 }; - (void)canvas->getClipBounds(&clipBounds); - const bool useBBH = !clipBounds.contains(this->cullRect()); + const bool useBBH = !canvas->getLocalClipBounds().contains(this->cullRect()); SkRecordDraw(*fRecord, canvas, diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp index 0375ab738d..d57b62fa99 100644 --- a/src/core/SkCanvas.cpp +++ b/src/core/SkCanvas.cpp @@ -1074,8 +1074,8 @@ bool SkCanvas::BoundsAffectsClip(SaveLayerFlags saveLayerFlags) { bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveLayerFlags saveLayerFlags, SkIRect* intersection, const SkImageFilter* imageFilter) { - SkIRect clipBounds; - if (!this->getClipDeviceBounds(&clipBounds)) { + SkIRect clipBounds = this->getDeviceClipBounds(); + if (clipBounds.isEmpty()) { return false; } @@ -1774,8 +1774,11 @@ bool SkCanvas::quickReject(const SkPath& path) const { } bool SkCanvas::getClipBounds(SkRect* bounds) const { - SkIRect ibounds; - if (!this->getClipDeviceBounds(&ibounds)) { + SkIRect ibounds = this->getDeviceClipBounds(); + if (ibounds.isEmpty()) { + if (bounds) { + bounds->setEmpty(); + } return false; } @@ -2070,7 +2073,7 @@ void SkCanvas::temporary_internal_describeTopLayer(SkMatrix* matrix, SkIRect* cl matrix->preTranslate(-layer_bounds.left(), -layer_bounds.top()); } if (clip_bounds) { - this->getClipDeviceBounds(clip_bounds); + *clip_bounds = this->getDeviceClipBounds(); clip_bounds->offset(-layer_bounds.left(), -layer_bounds.top()); } } diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp index c52233aca1..be2e5dbe04 100644 --- a/src/core/SkPicturePlayback.cpp +++ b/src/core/SkPicturePlayback.cpp @@ -506,8 +506,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader, const SkScalar bottom = reader->readScalar(); BREAK_ON_READ_ERROR(reader); - SkRect clip; - canvas->getClipBounds(&clip); + SkRect clip = canvas->getLocalClipBounds(); if (top < clip.fBottom && bottom > clip.fTop && paint && text.text()) { canvas->drawPosText(text.text(), text.length(), pos, *paint); } @@ -536,8 +535,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader, const SkScalar top = *xpos++; const SkScalar bottom = *xpos++; const SkScalar constY = *xpos++; - SkRect clip; - canvas->getClipBounds(&clip); + SkRect clip = canvas->getLocalClipBounds(); if (top < clip.fBottom && bottom > clip.fTop && paint && text.text()) { canvas->drawPosTextH(text.text(), text.length(), xpos, constY, *paint); } @@ -613,8 +611,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader, // ptr[1] == y // ptr[2] == top // ptr[3] == bottom - SkRect clip; - canvas->getClipBounds(&clip); + SkRect clip = canvas->getLocalClipBounds(); float top = ptr[2]; float bottom = ptr[3]; if (top < clip.fBottom && bottom > clip.fTop && paint && text.text()) { diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp index fe39cf2aeb..8ca3f06513 100644 --- a/src/core/SkRecordDraw.cpp +++ b/src/core/SkRecordDraw.cpp @@ -20,13 +20,10 @@ void SkRecordDraw(const SkRecord& record, if (bbh) { // Draw only ops that affect pixels in the canvas's current clip. // The SkRecord and BBH were recorded in identity space. This canvas - // is not necessarily in that same space. getClipBounds() returns us + // is not necessarily in that same space. getLocalClipBounds() returns us // this canvas' clip bounds transformed back into identity space, which // lets us query the BBH. - SkRect query; - if (!canvas->getClipBounds(&query)) { - query.setEmpty(); - } + SkRect query = canvas->getLocalClipBounds(); SkTDArray<int> ops; bbh->search(query, &ops); diff --git a/src/core/SkRecordedDrawable.cpp b/src/core/SkRecordedDrawable.cpp index 3e3116697b..e70dce7ce9 100644 --- a/src/core/SkRecordedDrawable.cpp +++ b/src/core/SkRecordedDrawable.cpp @@ -51,8 +51,7 @@ void SkRecordedDrawable::flatten(SkWriteBuffer& buffer) const { SkPictureRecord pictureRecord(SkISize::Make(fBounds.width(), fBounds.height()), 0); // If the query contains the whole picture, don't bother with the bounding box hierarchy. - SkRect clipBounds; - pictureRecord.getClipBounds(&clipBounds); + SkRect clipBounds = pictureRecord.getLocalClipBounds(); SkBBoxHierarchy* bbh; if (clipBounds.contains(fBounds)) { bbh = nullptr; diff --git a/src/utils/SkPaintFilterCanvas.cpp b/src/utils/SkPaintFilterCanvas.cpp index 7bf8a5ff6e..c6b28d0c5d 100644 --- a/src/utils/SkPaintFilterCanvas.cpp +++ b/src/utils/SkPaintFilterCanvas.cpp @@ -33,9 +33,7 @@ SkPaintFilterCanvas::SkPaintFilterCanvas(SkCanvas *canvas) : INHERITED(canvas->imageInfo().width(), canvas->imageInfo().height()) { // Transfer matrix & clip state before adding the target canvas. - SkIRect devClip; - canvas->getClipDeviceBounds(&devClip); - this->clipRect(SkRect::Make(devClip)); + this->clipRect(SkRect::Make(canvas->getDeviceClipBounds())); this->setMatrix(canvas->getTotalMatrix()); this->addCanvas(canvas); diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp index 38fb3fe8bc..19824fa68a 100644 --- a/tests/CanvasStateTest.cpp +++ b/tests/CanvasStateTest.cpp @@ -326,7 +326,7 @@ DEF_TEST(CanvasState_test_saveLayer_clip, reporter) { SkIRect devClip; // Check that saveLayer without the kClipToLayer_SaveFlag leaves the clip unchanged. canvas.saveLayer(SkCanvas::SaveLayerRec(&bounds, nullptr, dontSaveFlag)); - canvas.getClipDeviceBounds(&devClip); + devClip = canvas.getDeviceClipBounds(); REPORTER_ASSERT(reporter, canvas.isClipRect()); REPORTER_ASSERT(reporter, devClip.width() == WIDTH); REPORTER_ASSERT(reporter, devClip.height() == HEIGHT); @@ -335,7 +335,7 @@ DEF_TEST(CanvasState_test_saveLayer_clip, reporter) { // Check that saveLayer with the kClipToLayer_SaveFlag sets the clip // stack to the layer bounds. canvas.saveLayer(&bounds, nullptr); - canvas.getClipDeviceBounds(&devClip); + devClip = canvas.getDeviceClipBounds(); REPORTER_ASSERT(reporter, canvas.isClipRect()); REPORTER_ASSERT(reporter, devClip.width() == LAYER_WIDTH); REPORTER_ASSERT(reporter, devClip.height() == LAYER_HEIGHT); diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp index 8a619f8fad..6229e849fb 100644 --- a/tests/CanvasTest.cpp +++ b/tests/CanvasTest.cpp @@ -66,6 +66,25 @@ #include "SkTDArray.h" #include "Test.h" +DEF_TEST(canvas_clipbounds, reporter) { + SkCanvas canvas(10, 10); + SkIRect irect; + SkRect rect; + + irect = canvas.getDeviceClipBounds(); + REPORTER_ASSERT(reporter, irect == SkIRect::MakeWH(10, 10)); + // local bounds are always too big today -- can we trim them? + rect = canvas.getLocalClipBounds(); + REPORTER_ASSERT(reporter, rect.contains(SkRect::MakeWH(10, 10))); + + canvas.clipRect(SkRect::MakeEmpty()); + + irect = canvas.getDeviceClipBounds(); + REPORTER_ASSERT(reporter, irect == SkIRect::MakeEmpty()); + rect = canvas.getLocalClipBounds(); + REPORTER_ASSERT(reporter, rect == SkRect::MakeEmpty()); +} + static const int kWidth = 2, kHeight = 2; static void createBitmap(SkBitmap* bm, SkColor color) { @@ -669,18 +688,14 @@ DEF_TEST(PaintFilterCanvas_ConsistentState, reporter) { canvas.clipRect(SkRect::MakeXYWH(12.7f, 12.7f, 75, 75)); canvas.scale(0.5f, 0.75f); - SkRect clip1, clip2; - MockFilterCanvas filterCanvas(&canvas); REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMatrix()); - REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getClipBounds(&clip2)); - REPORTER_ASSERT(reporter, clip1 == clip2); + REPORTER_ASSERT(reporter, canvas.getLocalClipBounds() == filterCanvas.getLocalClipBounds()); filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); filterCanvas.scale(0.75f, 0.5f); REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMatrix()); - REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getClipBounds(&clip2)); - REPORTER_ASSERT(reporter, clip2.contains(clip1)); + REPORTER_ASSERT(reporter, filterCanvas.getLocalClipBounds().contains(canvas.getLocalClipBounds())); #ifdef SK_EXPERIMENTAL_SHADOWING SkShadowTestCanvas* tCanvas = new SkShadowTestCanvas(100,100, reporter); diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp index d47165eaf2..7179e70101 100644 --- a/tests/PictureTest.cpp +++ b/tests/PictureTest.cpp @@ -417,18 +417,14 @@ static void check_balance(skiatest::Reporter* reporter, SkPicture* picture) { SkMatrix beforeMatrix = canvas.getTotalMatrix(); - SkRect beforeClip; - - canvas.getClipBounds(&beforeClip); + SkRect beforeClip = canvas.getLocalClipBounds(); canvas.drawPicture(picture); REPORTER_ASSERT(reporter, beforeSaveCount == canvas.getSaveCount()); REPORTER_ASSERT(reporter, beforeMatrix == canvas.getTotalMatrix()); - SkRect afterClip; - - canvas.getClipBounds(&afterClip); + SkRect afterClip = canvas.getLocalClipBounds(); REPORTER_ASSERT(reporter, afterClip == beforeClip); } @@ -643,8 +639,7 @@ static void test_clip_bound_opt(skiatest::Reporter* reporter) { { SkCanvas* canvas = recorder.beginRecording(10, 10); canvas->clipPath(invPath); - bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds); - REPORTER_ASSERT(reporter, true == nonEmpty); + clipBounds = canvas->getDeviceClipBounds(); REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft); REPORTER_ASSERT(reporter, 0 == clipBounds.fTop); REPORTER_ASSERT(reporter, 10 == clipBounds.fBottom); @@ -654,8 +649,7 @@ static void test_clip_bound_opt(skiatest::Reporter* reporter) { SkCanvas* canvas = recorder.beginRecording(10, 10); canvas->clipPath(path); canvas->clipPath(invPath); - bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds); - REPORTER_ASSERT(reporter, true == nonEmpty); + clipBounds = canvas->getDeviceClipBounds(); REPORTER_ASSERT(reporter, 7 == clipBounds.fLeft); REPORTER_ASSERT(reporter, 7 == clipBounds.fTop); REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom); @@ -665,8 +659,7 @@ static void test_clip_bound_opt(skiatest::Reporter* reporter) { SkCanvas* canvas = recorder.beginRecording(10, 10); canvas->clipPath(path); canvas->clipPath(invPath, kUnion_SkClipOp); - bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds); - REPORTER_ASSERT(reporter, true == nonEmpty); + clipBounds = canvas->getDeviceClipBounds(); REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft); REPORTER_ASSERT(reporter, 0 == clipBounds.fTop); REPORTER_ASSERT(reporter, 10 == clipBounds.fBottom); @@ -675,8 +668,7 @@ static void test_clip_bound_opt(skiatest::Reporter* reporter) { { SkCanvas* canvas = recorder.beginRecording(10, 10); canvas->clipPath(path, kDifference_SkClipOp); - bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds); - REPORTER_ASSERT(reporter, true == nonEmpty); + clipBounds = canvas->getDeviceClipBounds(); REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft); REPORTER_ASSERT(reporter, 0 == clipBounds.fTop); REPORTER_ASSERT(reporter, 10 == clipBounds.fBottom); @@ -685,11 +677,10 @@ static void test_clip_bound_opt(skiatest::Reporter* reporter) { { SkCanvas* canvas = recorder.beginRecording(10, 10); canvas->clipPath(path, kReverseDifference_SkClipOp); - bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds); + clipBounds = canvas->getDeviceClipBounds(); // True clip is actually empty in this case, but the best // determination we can make using only bounds as input is that the // clip is included in the bounds of 'path'. - REPORTER_ASSERT(reporter, true == nonEmpty); REPORTER_ASSERT(reporter, 7 == clipBounds.fLeft); REPORTER_ASSERT(reporter, 7 == clipBounds.fTop); REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom); @@ -699,8 +690,7 @@ static void test_clip_bound_opt(skiatest::Reporter* reporter) { SkCanvas* canvas = recorder.beginRecording(10, 10); canvas->clipPath(path, kIntersect_SkClipOp); canvas->clipPath(path2, kXOR_SkClipOp); - bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds); - REPORTER_ASSERT(reporter, true == nonEmpty); + clipBounds = canvas->getDeviceClipBounds(); REPORTER_ASSERT(reporter, 6 == clipBounds.fLeft); REPORTER_ASSERT(reporter, 6 == clipBounds.fTop); REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom); diff --git a/tools/debugger/SkDebugCanvas.cpp b/tools/debugger/SkDebugCanvas.cpp index 04e8341f87..c9d18eeca4 100644 --- a/tools/debugger/SkDebugCanvas.cpp +++ b/tools/debugger/SkDebugCanvas.cpp @@ -328,10 +328,7 @@ void SkDebugCanvas::drawTo(SkCanvas* originalCanvas, int index, int m) { this->lastClipStackData(devPath); } fMatrix = filterCanvas.getTotalMatrix(); - if (!filterCanvas.getClipDeviceBounds(&fClip)) { - fClip.setEmpty(); - } - + fClip = filterCanvas.getDeviceClipBounds(); filterCanvas.restoreToCount(saveCount); #if SK_SUPPORT_GPU diff --git a/tools/skhello.cpp b/tools/skhello.cpp index d1f8cb8192..0411b398b8 100644 --- a/tools/skhello.cpp +++ b/tools/skhello.cpp @@ -19,8 +19,7 @@ DEFINE_string2(outFile, o, "skhello", "The filename to write the image."); DEFINE_string2(text, t, "Hello", "The string to write."); static void doDraw(SkCanvas* canvas, const SkPaint& paint, const char text[]) { - SkRect bounds; - canvas->getClipBounds(&bounds); + SkRect bounds = canvas->getLocalClipBounds(); canvas->drawColor(SK_ColorWHITE); canvas->drawText(text, strlen(text), |