OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 "platform/mac/GraphicsContextCanvas.h" | 5 #include "platform/mac/GraphicsContextCanvas.h" |
6 #include "skia/ext/skia_utils_mac.h" | 6 #include "skia/ext/skia_utils_mac.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 SkiaPaintCanvas canvas(bitmap); | 30 SkiaPaintCanvas canvas(bitmap); |
31 if (test & kTestTranslate) | 31 if (test & kTestTranslate) |
32 canvas.translate(kWidth / 2, 0); | 32 canvas.translate(kWidth / 2, 0); |
33 if (test & kTestClip) { | 33 if (test & kTestClip) { |
34 SkRect clip_rect = {0, kHeight / 2, kWidth, kHeight}; | 34 SkRect clip_rect = {0, kHeight / 2, kWidth, kHeight}; |
35 canvas.clipRect(clip_rect); | 35 canvas.clipRect(clip_rect); |
36 } | 36 } |
37 { | 37 { |
38 SkIRect clip = | 38 SkIRect clip = |
39 SkIRect::MakeSize(canvas.getBaseLayerSize()) | 39 SkIRect::MakeWH(kWidth, kHeight) |
40 .makeOffset( | 40 .makeOffset( |
41 (test & kTestTranslate) ? -(static_cast<int>(kWidth)) / 2 : 0, | 41 (test & kTestTranslate) ? -(static_cast<int>(kWidth)) / 2 : 0, |
42 0); | 42 0); |
43 GraphicsContextCanvas bit_locker(&canvas, clip); | 43 GraphicsContextCanvas bit_locker(&canvas, clip); |
44 CGContextRef cg_context = bit_locker.CgContext(); | 44 CGContextRef cg_context = bit_locker.CgContext(); |
45 CGColorRef test_color = CGColorGetConstantColor(kCGColorWhite); | 45 CGColorRef test_color = CGColorGetConstantColor(kCGColorWhite); |
46 CGContextSetFillColorWithColor(cg_context, test_color); | 46 CGContextSetFillColorWithColor(cg_context, test_color); |
47 CGRect cg_rect = {{0, 0}, {kWidth, kHeight}}; | 47 CGRect cg_rect = {{0, 0}, {kWidth, kHeight}}; |
48 CGContextFillRect(cg_context, cg_rect); | 48 CGContextFillRect(cg_context, cg_rect); |
49 } | 49 } |
(...skipping 17 matching lines...) Expand all Loading... |
67 | 67 |
68 TEST(GraphicsContextCanvasTest, Clip) { | 68 TEST(GraphicsContextCanvasTest, Clip) { |
69 RunTest(kTestClip); | 69 RunTest(kTestClip); |
70 } | 70 } |
71 | 71 |
72 TEST(GraphicsContextCanvasTest, XClip) { | 72 TEST(GraphicsContextCanvasTest, XClip) { |
73 RunTest(kTestXClip); | 73 RunTest(kTestXClip); |
74 } | 74 } |
75 | 75 |
76 } // namespace | 76 } // namespace |
OLD | NEW |