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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1853383002: Revert of Delete SkFlattenable::Type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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 | « src/utils/SkBitmapSourceDeserializer.h ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBitmapDevice.h" 9 #include "SkBitmapDevice.h"
10 #include "SkBlurImageFilter.h" 10 #include "SkBlurImageFilter.h"
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 canvas.clear(0x0); 1082 canvas.clear(0x0);
1083 canvas.drawPicture(outerPicture); 1083 canvas.drawPicture(outerPicture);
1084 uint32_t pixel = *bitmap.getAddr32(0, 0); 1084 uint32_t pixel = *bitmap.getAddr32(0, 0);
1085 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 1085 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
1086 1086
1087 // Check that, for now, SkPictureImageFilter does not serialize or 1087 // Check that, for now, SkPictureImageFilter does not serialize or
1088 // deserialize its contained picture when the filter is serialized 1088 // deserialize its contained picture when the filter is serialized
1089 // cross-process. Do this by "laundering" it through SkValidatingReadBuffer. 1089 // cross-process. Do this by "laundering" it through SkValidatingReadBuffer.
1090 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(imageFilter.get() )); 1090 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(imageFilter.get() ));
1091 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( 1091 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable(
1092 data->data(), data->size())); 1092 data->data(), data->size(), SkImageFilter::GetFlattenableType()));
1093 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et()); 1093 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et());
1094 1094
1095 redPaintWithFilter.setImageFilter(unflattenedFilter); 1095 redPaintWithFilter.setImageFilter(unflattenedFilter);
1096 SkPictureRecorder crossProcessRecorder; 1096 SkPictureRecorder crossProcessRecorder;
1097 SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &fa ctory, 0); 1097 SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &fa ctory, 0);
1098 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi thFilter); 1098 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi thFilter);
1099 sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsP icture()); 1099 sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsP icture());
1100 1100
1101 canvas.clear(0x0); 1101 canvas.clear(0x0);
1102 canvas.drawPicture(crossProcessPicture); 1102 canvas.drawPicture(crossProcessPicture);
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1529
1530 // Verify that SkImageSource survives serialization 1530 // Verify that SkImageSource survives serialization
1531 DEF_TEST(ImageFilterImageSourceSerialization, reporter) { 1531 DEF_TEST(ImageFilterImageSourceSerialization, reporter) {
1532 auto surface(SkSurface::MakeRasterN32Premul(10, 10)); 1532 auto surface(SkSurface::MakeRasterN32Premul(10, 10));
1533 surface->getCanvas()->clear(SK_ColorGREEN); 1533 surface->getCanvas()->clear(SK_ColorGREEN);
1534 sk_sp<SkImage> image(surface->makeImageSnapshot()); 1534 sk_sp<SkImage> image(surface->makeImageSnapshot());
1535 sk_sp<SkImageFilter> filter(SkImageSource::Make(std::move(image))); 1535 sk_sp<SkImageFilter> filter(SkImageSource::Make(std::move(image)));
1536 1536
1537 sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter.get())); 1537 sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter.get()));
1538 sk_sp<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( 1538 sk_sp<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable(
1539 data->data(), data->size())); 1539 data->data(), data->size(), SkImageFilter::GetFlattenableType()));
1540 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et()); 1540 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et());
1541 REPORTER_ASSERT(reporter, unflattenedFilter); 1541 REPORTER_ASSERT(reporter, unflattenedFilter);
1542 1542
1543 SkBitmap bm; 1543 SkBitmap bm;
1544 bm.allocN32Pixels(10, 10); 1544 bm.allocN32Pixels(10, 10);
1545 bm.eraseColor(SK_ColorBLUE); 1545 bm.eraseColor(SK_ColorBLUE);
1546 SkPaint paint; 1546 SkPaint paint;
1547 paint.setColor(SK_ColorRED); 1547 paint.setColor(SK_ColorRED);
1548 paint.setImageFilter(unflattenedFilter); 1548 paint.setImageFilter(unflattenedFilter);
1549 1549
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 1629
1630 test_xfermode_cropped_input(&canvas, reporter); 1630 test_xfermode_cropped_input(&canvas, reporter);
1631 } 1631 }
1632 1632
1633 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { 1633 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) {
1634 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, 1634 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes,
1635 SkImageInfo::MakeN32Premul(100, 100 ))); 1635 SkImageInfo::MakeN32Premul(100, 100 )));
1636 test_large_blur_input(reporter, surface->getCanvas()); 1636 test_large_blur_input(reporter, surface->getCanvas());
1637 } 1637 }
1638 #endif 1638 #endif
OLDNEW
« no previous file with comments | « src/utils/SkBitmapSourceDeserializer.h ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698