Chromium Code Reviews| Index: skia/ext/bitmap_platform_device_mac_unittest.cc |
| diff --git a/skia/ext/bitmap_platform_device_mac_unittest.cc b/skia/ext/bitmap_platform_device_mac_unittest.cc |
| index be70df3243f52cdfe28a09be3c2656536746808f..cb5d3ebd6d37b62d44f7a8368b42690b8c69d4c6 100644 |
| --- a/skia/ext/bitmap_platform_device_mac_unittest.cc |
| +++ b/skia/ext/bitmap_platform_device_mac_unittest.cc |
| @@ -6,11 +6,12 @@ |
| #include <memory> |
| +#include "skia/ext/platform_canvas.h" |
| #include "skia/ext/skia_utils_mac.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "third_party/skia/include/core/SkClipStack.h" |
| #include "third_party/skia/include/core/SkMatrix.h" |
| -#include "third_party/skia/include/core/SkRegion.h" |
| +#include "third_party/skia/include/core/SkRect.h" |
| namespace skia { |
| @@ -24,21 +25,19 @@ class BitmapPlatformDeviceMacTest : public testing::Test { |
| NULL, kWidth, kHeight, /*is_opaque=*/true)); |
| } |
| - std::unique_ptr<BitmapPlatformDevice> bitmap_; |
| + sk_sp<BitmapPlatformDevice> bitmap_; |
| }; |
| TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithTranslate) { |
| SkMatrix transform; |
| transform.setTranslate(50, 140); |
| - SkClipStack ignore; |
| - SkRegion clip_region; |
| - SkIRect rect; |
| - rect.set(0, 0, kWidth, kHeight); |
| - clip_region.setRect(rect); |
| - bitmap_->setMatrixClip(transform, clip_region, ignore); |
| + SkCanvas* canvas = skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE); |
|
f(malita)
2016/05/11 19:29:37
Looks like this will leak. sk_sp<SkCanvas> instea
tomhudson
2016/05/19 12:24:12
Done.
|
| + canvas->setMatrix(transform); |
| + |
| + ScopedPlatformPaint p(canvas); |
| + CGContextRef context = p.GetPlatformSurface(); |
| - CGContextRef context = bitmap_->GetBitmapContext(); |
| SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context)); |
| transform.mapRect(&clip_rect); |
| EXPECT_EQ(0, clip_rect.fLeft); |
| @@ -51,14 +50,12 @@ TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithScale) { |
| SkMatrix transform; |
| transform.setScale(0.5, 0.5); |
| - SkClipStack unused; |
| - SkRegion clip_region; |
| - SkIRect rect; |
| - rect.set(0, 0, kWidth, kHeight); |
| - clip_region.setRect(rect); |
| - bitmap_->setMatrixClip(transform, clip_region, unused); |
| + SkCanvas* canvas = skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE); |
|
f(malita)
2016/05/11 19:29:37
Ditto.
tomhudson
2016/05/19 12:24:12
Done.
|
| + canvas->setMatrix(transform); |
| + |
| + ScopedPlatformPaint p(canvas); |
| + CGContextRef context = p.GetPlatformSurface(); |
| - CGContextRef context = bitmap_->GetBitmapContext(); |
| SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context)); |
| transform.mapRect(&clip_rect); |
| EXPECT_EQ(0, clip_rect.fLeft); |