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

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

Issue 2612863002: Make skia::GetNativeDrawingContext Windows-only (Closed)
Patch Set: more guarding Created 3 years, 11 months 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
« no previous file with comments | « skia/BUILD.gn ('k') | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "skia/ext/bitmap_platform_device_mac.h"
6
7 #include <memory>
8
9 #include "skia/ext/platform_canvas.h"
10 #include "skia/ext/skia_utils_mac.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/skia/include/core/SkClipStack.h"
13 #include "third_party/skia/include/core/SkMatrix.h"
14 #include "third_party/skia/include/core/SkRect.h"
15
16 namespace skia {
17
18 const int kWidth = 400;
19 const int kHeight = 300;
20
21 class BitmapPlatformDeviceMacTest : public testing::Test {
22 public:
23 BitmapPlatformDeviceMacTest() {
24 bitmap_.reset(BitmapPlatformDevice::Create(
25 NULL, kWidth, kHeight, /*is_opaque=*/true));
26 }
27
28 sk_sp<BitmapPlatformDevice> bitmap_;
29 };
30
31 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithTranslate) {
32 SkMatrix transform;
33 transform.setTranslate(50, 140);
34
35 std::unique_ptr<SkCanvas> canvas =
36 skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE);
37 canvas->setMatrix(transform);
38
39 CGContextRef context = skia::GetNativeDrawingContext(canvas.get());
40
41 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context));
42 transform.mapRect(&clip_rect);
43 EXPECT_EQ(0, clip_rect.fLeft);
44 EXPECT_EQ(0, clip_rect.fTop);
45 EXPECT_EQ(kWidth, clip_rect.width());
46 EXPECT_EQ(kHeight, clip_rect.height());
47 }
48
49 TEST_F(BitmapPlatformDeviceMacTest, ClipRectTransformWithScale) {
50 SkMatrix transform;
51 transform.setScale(0.5, 0.5);
52
53 std::unique_ptr<SkCanvas> canvas =
54 skia::CreateCanvas(bitmap_, CRASH_ON_FAILURE);
55 canvas->setMatrix(transform);
56
57 CGContextRef context = skia::GetNativeDrawingContext(canvas.get());
58
59 SkRect clip_rect = skia::CGRectToSkRect(CGContextGetClipBoundingBox(context));
60 transform.mapRect(&clip_rect);
61 EXPECT_EQ(0, clip_rect.fLeft);
62 EXPECT_EQ(0, clip_rect.fTop);
63 EXPECT_EQ(kWidth, clip_rect.width());
64 EXPECT_EQ(kHeight, clip_rect.height());
65 }
66
67 } // namespace skia
OLDNEW
« no previous file with comments | « skia/BUILD.gn ('k') | skia/ext/bitmap_platform_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698