| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 canvas.clear(0x0); | 1047 canvas.clear(0x0); |
| 1048 canvas.drawPicture(outerPicture); | 1048 canvas.drawPicture(outerPicture); |
| 1049 uint32_t pixel = *bitmap.getAddr32(0, 0); | 1049 uint32_t pixel = *bitmap.getAddr32(0, 0); |
| 1050 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); | 1050 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); |
| 1051 | 1051 |
| 1052 // Check that, for now, SkPictureImageFilter does not serialize or | 1052 // Check that, for now, SkPictureImageFilter does not serialize or |
| 1053 // deserialize its contained picture when the filter is serialized | 1053 // deserialize its contained picture when the filter is serialized |
| 1054 // cross-process. Do this by "laundering" it through SkValidatingReadBuffer. | 1054 // cross-process. Do this by "laundering" it through SkValidatingReadBuffer. |
| 1055 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(imageFilter.get()
)); | 1055 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(imageFilter.get()
)); |
| 1056 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( | 1056 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( |
| 1057 data->data(), data->size(), SkImageFilter::GetFlattenableType())); | 1057 data->data(), data->size())); |
| 1058 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g
et()); | 1058 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g
et()); |
| 1059 | 1059 |
| 1060 redPaintWithFilter.setImageFilter(unflattenedFilter); | 1060 redPaintWithFilter.setImageFilter(unflattenedFilter); |
| 1061 SkPictureRecorder crossProcessRecorder; | 1061 SkPictureRecorder crossProcessRecorder; |
| 1062 SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &fa
ctory, 0); | 1062 SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &fa
ctory, 0); |
| 1063 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi
thFilter); | 1063 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi
thFilter); |
| 1064 sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsP
icture()); | 1064 sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsP
icture()); |
| 1065 | 1065 |
| 1066 canvas.clear(0x0); | 1066 canvas.clear(0x0); |
| 1067 canvas.drawPicture(crossProcessPicture); | 1067 canvas.drawPicture(crossProcessPicture); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 | 1492 |
| 1493 // Verify that SkImageSource survives serialization | 1493 // Verify that SkImageSource survives serialization |
| 1494 DEF_TEST(ImageFilterImageSourceSerialization, reporter) { | 1494 DEF_TEST(ImageFilterImageSourceSerialization, reporter) { |
| 1495 auto surface(SkSurface::MakeRasterN32Premul(10, 10)); | 1495 auto surface(SkSurface::MakeRasterN32Premul(10, 10)); |
| 1496 surface->getCanvas()->clear(SK_ColorGREEN); | 1496 surface->getCanvas()->clear(SK_ColorGREEN); |
| 1497 sk_sp<SkImage> image(surface->makeImageSnapshot()); | 1497 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
| 1498 SkAutoTUnref<SkImageFilter> filter(SkImageSource::Create(image.get())); | 1498 SkAutoTUnref<SkImageFilter> filter(SkImageSource::Create(image.get())); |
| 1499 | 1499 |
| 1500 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter)); | 1500 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter)); |
| 1501 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( | 1501 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( |
| 1502 data->data(), data->size(), SkImageFilter::GetFlattenableType())); | 1502 data->data(), data->size())); |
| 1503 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g
et()); | 1503 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g
et()); |
| 1504 REPORTER_ASSERT(reporter, unflattenedFilter); | 1504 REPORTER_ASSERT(reporter, unflattenedFilter); |
| 1505 | 1505 |
| 1506 SkBitmap bm; | 1506 SkBitmap bm; |
| 1507 bm.allocN32Pixels(10, 10); | 1507 bm.allocN32Pixels(10, 10); |
| 1508 bm.eraseColor(SK_ColorBLUE); | 1508 bm.eraseColor(SK_ColorBLUE); |
| 1509 SkPaint paint; | 1509 SkPaint paint; |
| 1510 paint.setColor(SK_ColorRED); | 1510 paint.setColor(SK_ColorRED); |
| 1511 paint.setImageFilter(unflattenedFilter); | 1511 paint.setImageFilter(unflattenedFilter); |
| 1512 | 1512 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1592 | 1592 |
| 1593 test_xfermode_cropped_input(&canvas, reporter); | 1593 test_xfermode_cropped_input(&canvas, reporter); |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { | 1596 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { |
| 1597 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, | 1597 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, |
| 1598 SkImageInfo::MakeN32Premul(100, 100
))); | 1598 SkImageInfo::MakeN32Premul(100, 100
))); |
| 1599 test_large_blur_input(reporter, surface->getCanvas()); | 1599 test_large_blur_input(reporter, surface->getCanvas()); |
| 1600 } | 1600 } |
| 1601 #endif | 1601 #endif |
| OLD | NEW |