OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y |
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N |
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 */ | 23 */ |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 | 26 |
27 #include "platform/graphics/GraphicsContext.h" | 27 #include "platform/graphics/GraphicsContext.h" |
28 | 28 |
29 #include "platform/graphics/BitmapImage.h" | 29 #include "platform/graphics/BitmapImage.h" |
30 #include "platform/graphics/GraphicsContextClient.h" | |
31 #include "platform/graphics/ImageBuffer.h" | 30 #include "platform/graphics/ImageBuffer.h" |
32 #include "platform/graphics/skia/NativeImageSkia.h" | 31 #include "platform/graphics/skia/NativeImageSkia.h" |
33 #include "third_party/skia/include/core/SkBitmap.h" | 32 #include "third_party/skia/include/core/SkBitmap.h" |
34 #include "third_party/skia/include/core/SkCanvas.h" | 33 #include "third_party/skia/include/core/SkCanvas.h" |
35 #include "third_party/skia/include/core/SkPicture.h" | 34 #include "third_party/skia/include/core/SkPicture.h" |
36 #include "third_party/skia/include/core/SkShader.h" | 35 #include "third_party/skia/include/core/SkShader.h" |
37 #include "third_party/skia/include/effects/SkBlurDrawLooper.h" | 36 #include "third_party/skia/include/effects/SkBlurDrawLooper.h" |
38 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 37 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
39 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" | 38 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" |
40 | 39 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 context.drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); | 160 context.drawImageBuffer(alphaImage.get(), FloatRect(10, 10, 10, 10)); |
162 | 161 |
163 // We can't have an opaque mask actually, but we can pretend here like it wo uld look if we did. | 162 // We can't have an opaque mask actually, but we can pretend here like it wo uld look if we did. |
164 context.fillRect(FloatRect(12, 12, 3, 3), opaque, SkXfermode::kSrcOver_Mode) ; | 163 context.fillRect(FloatRect(12, 12, 3, 3), opaque, SkXfermode::kSrcOver_Mode) ; |
165 | 164 |
166 context.endLayer(); | 165 context.endLayer(); |
167 context.endLayer(); | 166 context.endLayer(); |
168 | 167 |
169 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(12, 12, 3, 3)); | 168 EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, IntRect(12, 12, 3, 3)); |
170 } | 169 } |
171 | 170 /* |
172 #define TEST_CLEAR_SETUP \ | 171 #define TEST_CLEAR_SETUP \ |
173 SkBitmap bitmap; \ | 172 SkBitmap bitmap; \ |
174 bitmap.allocN32Pixels(10, 10); \ | 173 bitmap.allocN32Pixels(10, 10); \ |
175 bitmap.eraseColor(0); \ | 174 bitmap.eraseColor(0); \ |
176 SkCanvas canvas(bitmap); \ | 175 SkCanvas canvas(bitmap); \ |
177 TestGraphicsContextClient gcClient; \ | 176 TestGraphicsContextClient gcClient; \ |
178 GraphicsContext context(&canvas, nullptr); \ | 177 GraphicsContext context(&canvas, nullptr); \ |
179 context.setClient(&gcClient); | 178 context.setClient(&gcClient); |
180 | 179 |
181 #define TEST_CLEAR_1(SHOULD_CLEAR, CALL1) \ | 180 #define TEST_CLEAR_1(SHOULD_CLEAR, CALL1) \ |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 SkPaint paint; | 386 SkPaint paint; |
388 SkAutoTUnref<SkDrawLooper> looper(SkBlurDrawLooper::Create(SK_ColorWHITE , 1, 1, 1)); | 387 SkAutoTUnref<SkDrawLooper> looper(SkBlurDrawLooper::Create(SK_ColorWHITE , 1, 1, 1)); |
389 paint.setLooper(looper.get()); | 388 paint.setLooper(looper.get()); |
390 TEST_CLEAR_1(false, drawRect(fullRect, paint)); | 389 TEST_CLEAR_1(false, drawRect(fullRect, paint)); |
391 } | 390 } |
392 { | 391 { |
393 SkPaint paint; | 392 SkPaint paint; |
394 TEST_CLEAR_3(false, beginLayer(1.0f, SkXfermode::kSrcOver_Mode), drawRec t(fullRect, paint), endLayer()); | 393 TEST_CLEAR_3(false, beginLayer(1.0f, SkXfermode::kSrcOver_Mode), drawRec t(fullRect, paint), endLayer()); |
395 } | 394 } |
396 } | 395 } |
397 | 396 */ |
dshwang
2015/02/06 19:10:37
why don't you delete code?
Justin Novosad
2015/02/06 19:37:31
I will. I am currently working on moving these tes
| |
398 TEST(GraphicsContextTest, UnboundedDrawsAreClipped) | 397 TEST(GraphicsContextTest, UnboundedDrawsAreClipped) |
399 { | 398 { |
400 SkBitmap bitmap; | 399 SkBitmap bitmap; |
401 bitmap.allocN32Pixels(400, 400); | 400 bitmap.allocN32Pixels(400, 400); |
402 bitmap.eraseColor(0); | 401 bitmap.eraseColor(0); |
403 SkCanvas canvas(bitmap); | 402 SkCanvas canvas(bitmap); |
404 | 403 |
405 GraphicsContext context(&canvas, nullptr); | 404 GraphicsContext context(&canvas, nullptr); |
406 | 405 |
407 Color opaque(1.0f, 0.0f, 0.0f, 1.0f); | 406 Color opaque(1.0f, 0.0f, 0.0f, 1.0f); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 | 498 |
500 // endRecording finally makes the picture accessible | 499 // endRecording finally makes the picture accessible |
501 RefPtr<const SkPicture> picture = context.endRecording(); | 500 RefPtr<const SkPicture> picture = context.endRecording(); |
502 EXPECT_TRUE(picture); | 501 EXPECT_TRUE(picture); |
503 EXPECT_TRUE(picture->unique()); | 502 EXPECT_TRUE(picture->unique()); |
504 | 503 |
505 context.endRecording(); | 504 context.endRecording(); |
506 } | 505 } |
507 | 506 |
508 } // namespace | 507 } // namespace |
OLD | NEW |