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