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

Side by Side Diff: skia/ext/bitmap_platform_device_mac_unittest.cc

Issue 2476113002: Change call-sites now that SkCanvas is not ref-counted (Closed)
Patch Set: try fixing win again Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "skia/ext/bitmap_platform_device_mac.h" 5 #include "skia/ext/bitmap_platform_device_mac.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "skia/ext/platform_canvas.h" 9 #include "skia/ext/platform_canvas.h"
10 #include "skia/ext/skia_utils_mac.h" 10 #include "skia/ext/skia_utils_mac.h"
(...skipping 14 matching lines...) Expand all
25 NULL, kWidth, kHeight, /*is_opaque=*/true)); 25 NULL, kWidth, kHeight, /*is_opaque=*/true));
26 } 26 }
27 27
28 sk_sp<BitmapPlatformDevice> bitmap_; 28 sk_sp<BitmapPlatformDevice> bitmap_;
29 }; 29 };
30 30
31 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithTranslate) { 31 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithTranslate) {
32 SkMatrix transform; 32 SkMatrix transform;
33 transform.setTranslate(50, 140); 33 transform.setTranslate(50, 140);
34 34
35 sk_sp<SkCanvas> canvas(skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE)); 35 std::unique_ptr<SkCanvas> canvas =
36 skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE);
36 canvas->setMatrix(transform); 37 canvas->setMatrix(transform);
37 38
38 ScopedPlatformPaint p(canvas.get()); 39 ScopedPlatformPaint p(canvas.get());
39 CGContextRef context = p.GetNativeDrawingContext(); 40 CGContextRef context = p.GetNativeDrawingContext();
40 41
41 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context)); 42 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context));
42 transform.mapRect(&clip_rect); 43 transform.mapRect(&clip_rect);
43 EXPECT_EQ(0, clip_rect.fLeft); 44 EXPECT_EQ(0, clip_rect.fLeft);
44 EXPECT_EQ(0, clip_rect.fTop); 45 EXPECT_EQ(0, clip_rect.fTop);
45 EXPECT_EQ(kWidth, clip_rect.width()); 46 EXPECT_EQ(kWidth, clip_rect.width());
46 EXPECT_EQ(kHeight, clip_rect.height()); 47 EXPECT_EQ(kHeight, clip_rect.height());
47 } 48 }
48 49
49 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithScale) { 50 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithScale) {
50 SkMatrix transform; 51 SkMatrix transform;
51 transform.setScale(0.5, 0.5); 52 transform.setScale(0.5, 0.5);
52 53
53 sk_sp<SkCanvas> canvas(skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE)); 54 std::unique_ptr<SkCanvas> canvas =
55 skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE);
54 canvas->setMatrix(transform); 56 canvas->setMatrix(transform);
55 57
56 ScopedPlatformPaint p(canvas.get()); 58 ScopedPlatformPaint p(canvas.get());
57 CGContextRef context = p.GetNativeDrawingContext(); 59 CGContextRef context = p.GetNativeDrawingContext();
58 60
59 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context)); 61 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context));
60 transform.mapRect(&clip_rect); 62 transform.mapRect(&clip_rect);
61 EXPECT_EQ(0, clip_rect.fLeft); 63 EXPECT_EQ(0, clip_rect.fLeft);
62 EXPECT_EQ(0, clip_rect.fTop); 64 EXPECT_EQ(0, clip_rect.fTop);
63 EXPECT_EQ(kWidth, clip_rect.width()); 65 EXPECT_EQ(kWidth, clip_rect.width());
64 EXPECT_EQ(kHeight, clip_rect.height()); 66 EXPECT_EQ(kHeight, clip_rect.height());
65 } 67 }
66 68
67 } // namespace skia 69 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698