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

Side by Side Diff: tests/ImageFilterTest.cpp

Issue 1834303003: Delete SkFlattenable::Type (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase 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 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 canvas.clear(0x0); 1146 canvas.clear(0x0);
1147 canvas.drawPicture(outerPicture); 1147 canvas.drawPicture(outerPicture);
1148 uint32_t pixel = *bitmap.getAddr32(0, 0); 1148 uint32_t pixel = *bitmap.getAddr32(0, 0);
1149 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); 1149 REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN);
1150 1150
1151 // Check that, for now, SkPictureImageFilter does not serialize or 1151 // Check that, for now, SkPictureImageFilter does not serialize or
1152 // deserialize its contained picture when the filter is serialized 1152 // deserialize its contained picture when the filter is serialized
1153 // cross-process. Do this by "laundering" it through SkValidatingReadBuffer. 1153 // cross-process. Do this by "laundering" it through SkValidatingReadBuffer.
1154 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(imageFilter.get() )); 1154 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(imageFilter.get() ));
1155 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( 1155 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable(
1156 data->data(), data->size(), SkImageFilter::GetFlattenableType())); 1156 data->data(), data->size()));
1157 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et()); 1157 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et());
1158 1158
1159 redPaintWithFilter.setImageFilter(unflattenedFilter); 1159 redPaintWithFilter.setImageFilter(unflattenedFilter);
1160 SkPictureRecorder crossProcessRecorder; 1160 SkPictureRecorder crossProcessRecorder;
1161 SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &fa ctory, 0); 1161 SkCanvas* crossProcessCanvas = crossProcessRecorder.beginRecording(1, 1, &fa ctory, 0);
1162 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi thFilter); 1162 crossProcessCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), redPaintWi thFilter);
1163 sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsP icture()); 1163 sk_sp<SkPicture> crossProcessPicture(crossProcessRecorder.finishRecordingAsP icture());
1164 1164
1165 canvas.clear(0x0); 1165 canvas.clear(0x0);
1166 canvas.drawPicture(crossProcessPicture); 1166 canvas.drawPicture(crossProcessPicture);
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 1593
1594 // Verify that SkImageSource survives serialization 1594 // Verify that SkImageSource survives serialization
1595 DEF_TEST(ImageFilterImageSourceSerialization, reporter) { 1595 DEF_TEST(ImageFilterImageSourceSerialization, reporter) {
1596 auto surface(SkSurface::MakeRasterN32Premul(10, 10)); 1596 auto surface(SkSurface::MakeRasterN32Premul(10, 10));
1597 surface->getCanvas()->clear(SK_ColorGREEN); 1597 surface->getCanvas()->clear(SK_ColorGREEN);
1598 sk_sp<SkImage> image(surface->makeImageSnapshot()); 1598 sk_sp<SkImage> image(surface->makeImageSnapshot());
1599 sk_sp<SkImageFilter> filter(SkImageSource::Make(std::move(image))); 1599 sk_sp<SkImageFilter> filter(SkImageSource::Make(std::move(image)));
1600 1600
1601 sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter.get())); 1601 sk_sp<SkData> data(SkValidatingSerializeFlattenable(filter.get()));
1602 sk_sp<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( 1602 sk_sp<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable(
1603 data->data(), data->size(), SkImageFilter::GetFlattenableType())); 1603 data->data(), data->size()));
1604 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et()); 1604 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g et());
1605 REPORTER_ASSERT(reporter, unflattenedFilter); 1605 REPORTER_ASSERT(reporter, unflattenedFilter);
1606 1606
1607 SkBitmap bm; 1607 SkBitmap bm;
1608 bm.allocN32Pixels(10, 10); 1608 bm.allocN32Pixels(10, 10);
1609 bm.eraseColor(SK_ColorBLUE); 1609 bm.eraseColor(SK_ColorBLUE);
1610 SkPaint paint; 1610 SkPaint paint;
1611 paint.setColor(SK_ColorRED); 1611 paint.setColor(SK_ColorRED);
1612 paint.setImageFilter(unflattenedFilter); 1612 paint.setImageFilter(unflattenedFilter);
1613 1613
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 1693
1694 test_xfermode_cropped_input(&canvas, reporter); 1694 test_xfermode_cropped_input(&canvas, reporter);
1695 } 1695 }
1696 1696
1697 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { 1697 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) {
1698 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, 1698 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes,
1699 SkImageInfo::MakeN32Premul(100, 100 ))); 1699 SkImageInfo::MakeN32Premul(100, 100 )));
1700 test_large_blur_input(reporter, surface->getCanvas()); 1700 test_large_blur_input(reporter, surface->getCanvas());
1701 } 1701 }
1702 #endif 1702 #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