OLD | NEW |
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 18 matching lines...) Expand all Loading... |
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 sk_sp<SkCanvas> canvas(skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE)); |
36 canvas->setMatrix(transform); | 36 canvas->setMatrix(transform); |
37 | 37 |
38 ScopedPlatformPaint p(canvas.get()); | 38 ScopedPlatformPaint p(canvas.get()); |
39 CGContextRef context = p.GetPlatformSurface(); | 39 CGContextRef context = p.GetNativeDrawingContext(); |
40 | 40 |
41 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context)); | 41 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context)); |
42 transform.mapRect(&clip_rect); | 42 transform.mapRect(&clip_rect); |
43 EXPECT_EQ(0, clip_rect.fLeft); | 43 EXPECT_EQ(0, clip_rect.fLeft); |
44 EXPECT_EQ(0, clip_rect.fTop); | 44 EXPECT_EQ(0, clip_rect.fTop); |
45 EXPECT_EQ(kWidth, clip_rect.width()); | 45 EXPECT_EQ(kWidth, clip_rect.width()); |
46 EXPECT_EQ(kHeight, clip_rect.height()); | 46 EXPECT_EQ(kHeight, clip_rect.height()); |
47 } | 47 } |
48 | 48 |
49 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithScale) { | 49 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithScale) { |
50 SkMatrix transform; | 50 SkMatrix transform; |
51 transform.setScale(0.5, 0.5); | 51 transform.setScale(0.5, 0.5); |
52 | 52 |
53 sk_sp<SkCanvas> canvas(skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE)); | 53 sk_sp<SkCanvas> canvas(skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE)); |
54 canvas->setMatrix(transform); | 54 canvas->setMatrix(transform); |
55 | 55 |
56 ScopedPlatformPaint p(canvas.get()); | 56 ScopedPlatformPaint p(canvas.get()); |
57 CGContextRef context = p.GetPlatformSurface(); | 57 CGContextRef context = p.GetNativeDrawingContext(); |
58 | 58 |
59 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context)); | 59 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context)); |
60 transform.mapRect(&clip_rect); | 60 transform.mapRect(&clip_rect); |
61 EXPECT_EQ(0, clip_rect.fLeft); | 61 EXPECT_EQ(0, clip_rect.fLeft); |
62 EXPECT_EQ(0, clip_rect.fTop); | 62 EXPECT_EQ(0, clip_rect.fTop); |
63 EXPECT_EQ(kWidth, clip_rect.width()); | 63 EXPECT_EQ(kWidth, clip_rect.width()); |
64 EXPECT_EQ(kHeight, clip_rect.height()); | 64 EXPECT_EQ(kHeight, clip_rect.height()); |
65 } | 65 } |
66 | 66 |
67 } // namespace skia | 67 } // namespace skia |
OLD | NEW |