| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "RecordTestUtils.h" | 9 #include "RecordTestUtils.h" |
| 10 | 10 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 DEF_TEST(RecordOpts_NoopSaveLayerDrawRestore, r) { | 133 DEF_TEST(RecordOpts_NoopSaveLayerDrawRestore, r) { |
| 134 SkRecord record; | 134 SkRecord record; |
| 135 SkRecorder recorder(&record, W, H); | 135 SkRecorder recorder(&record, W, H); |
| 136 | 136 |
| 137 SkRect bounds = SkRect::MakeWH(100, 200); | 137 SkRect bounds = SkRect::MakeWH(100, 200); |
| 138 SkRect draw = SkRect::MakeWH(50, 60); | 138 SkRect draw = SkRect::MakeWH(50, 60); |
| 139 | 139 |
| 140 SkPaint alphaOnlyLayerPaint, translucentLayerPaint, xfermodeLayerPaint; | 140 SkPaint alphaOnlyLayerPaint, translucentLayerPaint, xfermodeLayerPaint; |
| 141 alphaOnlyLayerPaint.setColor(0x03000000); // Only alpha. | 141 alphaOnlyLayerPaint.setColor(0x03000000); // Only alpha. |
| 142 translucentLayerPaint.setColor(0x03040506); // Not only alpha. | 142 translucentLayerPaint.setColor(0x03040506); // Not only alpha. |
| 143 xfermodeLayerPaint.setXfermodeMode(SkXfermode::kDstIn_Mode); // Any effect
will do. | 143 xfermodeLayerPaint.setBlendMode(SkBlendMode::kDstIn); // Any effect will do
. |
| 144 | 144 |
| 145 SkPaint opaqueDrawPaint, translucentDrawPaint; | 145 SkPaint opaqueDrawPaint, translucentDrawPaint; |
| 146 opaqueDrawPaint.setColor(0xFF020202); // Opaque. | 146 opaqueDrawPaint.setColor(0xFF020202); // Opaque. |
| 147 translucentDrawPaint.setColor(0x0F020202); // Not opaque. | 147 translucentDrawPaint.setColor(0x0F020202); // Not opaque. |
| 148 | 148 |
| 149 // SaveLayer/Restore removed: No paint = no point. | 149 // SaveLayer/Restore removed: No paint = no point. |
| 150 recorder.saveLayer(nullptr, nullptr); | 150 recorder.saveLayer(nullptr, nullptr); |
| 151 recorder.drawRect(draw, opaqueDrawPaint); | 151 recorder.drawRect(draw, opaqueDrawPaint); |
| 152 recorder.restore(); | 152 recorder.restore(); |
| 153 assert_savelayer_draw_restore(r, &record, 0, true); | 153 assert_savelayer_draw_restore(r, &record, 0, true); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 SkRecorder recorder(&record, W, H); | 215 SkRecorder recorder(&record, W, H); |
| 216 | 216 |
| 217 SkRect bounds = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(200)); | 217 SkRect bounds = SkRect::MakeWH(SkIntToScalar(100), SkIntToScalar(200)); |
| 218 SkRect clip = SkRect::MakeWH(SkIntToScalar(50), SkIntToScalar(60)); | 218 SkRect clip = SkRect::MakeWH(SkIntToScalar(50), SkIntToScalar(60)); |
| 219 | 219 |
| 220 SkPaint alphaOnlyLayerPaint; | 220 SkPaint alphaOnlyLayerPaint; |
| 221 alphaOnlyLayerPaint.setColor(0x03000000); // Only alpha. | 221 alphaOnlyLayerPaint.setColor(0x03000000); // Only alpha. |
| 222 SkPaint translucentLayerPaint; | 222 SkPaint translucentLayerPaint; |
| 223 translucentLayerPaint.setColor(0x03040506); // Not only alpha. | 223 translucentLayerPaint.setColor(0x03040506); // Not only alpha. |
| 224 SkPaint xfermodePaint; | 224 SkPaint xfermodePaint; |
| 225 xfermodePaint.setXfermodeMode(SkXfermode::kDstIn_Mode); | 225 xfermodePaint.setBlendMode(SkBlendMode::kDstIn); |
| 226 SkPaint colorFilterPaint; | 226 SkPaint colorFilterPaint; |
| 227 colorFilterPaint.setColorFilter( | 227 colorFilterPaint.setColorFilter( |
| 228 SkColorFilter::MakeModeFilter(SK_ColorLTGRAY, SkXfermode::kSrcIn_Mode)); | 228 SkColorFilter::MakeModeFilter(SK_ColorLTGRAY, SkBlendMode::kSrcIn)); |
| 229 | 229 |
| 230 SkPaint opaqueFilterLayerPaint; | 230 SkPaint opaqueFilterLayerPaint; |
| 231 opaqueFilterLayerPaint.setColor(0xFF020202); // Opaque. | 231 opaqueFilterLayerPaint.setColor(0xFF020202); // Opaque. |
| 232 SkPaint translucentFilterLayerPaint; | 232 SkPaint translucentFilterLayerPaint; |
| 233 translucentFilterLayerPaint.setColor(0x0F020202); // Not opaque. | 233 translucentFilterLayerPaint.setColor(0x0F020202); // Not opaque. |
| 234 sk_sp<SkPicture> shape; | 234 sk_sp<SkPicture> shape; |
| 235 { | 235 { |
| 236 SkPictureRecorder recorder; | 236 SkPictureRecorder recorder; |
| 237 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(100), SkIntToSc
alar(100)); | 237 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(100), SkIntToSc
alar(100)); |
| 238 SkPaint shapePaint; | 238 SkPaint shapePaint; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 346 } |
| 347 | 347 |
| 348 static void do_draw(SkCanvas* canvas, SkColor color, bool doLayer) { | 348 static void do_draw(SkCanvas* canvas, SkColor color, bool doLayer) { |
| 349 canvas->drawColor(SK_ColorWHITE); | 349 canvas->drawColor(SK_ColorWHITE); |
| 350 | 350 |
| 351 SkPaint p; | 351 SkPaint p; |
| 352 p.setColor(color); | 352 p.setColor(color); |
| 353 | 353 |
| 354 if (doLayer) { | 354 if (doLayer) { |
| 355 canvas->saveLayer(nullptr, nullptr); | 355 canvas->saveLayer(nullptr, nullptr); |
| 356 p.setXfermodeMode(SkXfermode::kSrc_Mode); | 356 p.setBlendMode(SkBlendMode::kSrc); |
| 357 canvas->drawPaint(p); | 357 canvas->drawPaint(p); |
| 358 canvas->restore(); | 358 canvas->restore(); |
| 359 } else { | 359 } else { |
| 360 canvas->drawPaint(p); | 360 canvas->drawPaint(p); |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 | 363 |
| 364 static bool is_equal(SkSurface* a, SkSurface* b) { | 364 static bool is_equal(SkSurface* a, SkSurface* b) { |
| 365 const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); | 365 const SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); |
| 366 SkPMColor ca, cb; | 366 SkPMColor ca, cb; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 405 } |
| 406 | 406 |
| 407 DEF_TEST(savelayer_srcmode_opaque, r) { | 407 DEF_TEST(savelayer_srcmode_opaque, r) { |
| 408 do_savelayer_srcmode(r, SK_ColorRED); | 408 do_savelayer_srcmode(r, SK_ColorRED); |
| 409 } | 409 } |
| 410 | 410 |
| 411 DEF_TEST(savelayer_srcmode_alpha, r) { | 411 DEF_TEST(savelayer_srcmode_alpha, r) { |
| 412 do_savelayer_srcmode(r, 0x80FF0000); | 412 do_savelayer_srcmode(r, 0x80FF0000); |
| 413 } | 413 } |
| 414 | 414 |
| OLD | NEW |