| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 224 } |
| 225 | 225 |
| 226 #ifndef SK_IGNORE_TO_STRING | 226 #ifndef SK_IGNORE_TO_STRING |
| 227 void MatrixTestImageFilter::toString(SkString* str) const { | 227 void MatrixTestImageFilter::toString(SkString* str) const { |
| 228 str->appendf("MatrixTestImageFilter: ("); | 228 str->appendf("MatrixTestImageFilter: ("); |
| 229 str->append(")"); | 229 str->append(")"); |
| 230 } | 230 } |
| 231 #endif | 231 #endif |
| 232 | 232 |
| 233 static sk_sp<SkImage> make_small_image() { | 233 static sk_sp<SkImage> make_small_image() { |
| 234 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kBitmapSize, k
BitmapSize)); | 234 auto surface(SkSurface::MakeRasterN32Premul(kBitmapSize, kBitmapSize)); |
| 235 SkCanvas* canvas = surface->getCanvas(); | 235 SkCanvas* canvas = surface->getCanvas(); |
| 236 canvas->clear(0x00000000); | 236 canvas->clear(0x00000000); |
| 237 SkPaint darkPaint; | 237 SkPaint darkPaint; |
| 238 darkPaint.setColor(0xFF804020); | 238 darkPaint.setColor(0xFF804020); |
| 239 SkPaint lightPaint; | 239 SkPaint lightPaint; |
| 240 lightPaint.setColor(0xFF244484); | 240 lightPaint.setColor(0xFF244484); |
| 241 const int i = kBitmapSize / 4; | 241 const int i = kBitmapSize / 4; |
| 242 for (int y = 0; y < kBitmapSize; y += i) { | 242 for (int y = 0; y < kBitmapSize; y += i) { |
| 243 for (int x = 0; x < kBitmapSize; x += i) { | 243 for (int x = 0; x < kBitmapSize; x += i) { |
| 244 canvas->save(); | 244 canvas->save(); |
| (...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 REPORTER_ASSERT(reporter, identityFilter->canComputeFastBounds()); | 1488 REPORTER_ASSERT(reporter, identityFilter->canComputeFastBounds()); |
| 1489 | 1489 |
| 1490 auto forceOpaqueCF(SkTableColorFilter::MakeARGB(allOne, identity, identity,
identity)); | 1490 auto forceOpaqueCF(SkTableColorFilter::MakeARGB(allOne, identity, identity,
identity)); |
| 1491 SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(for
ceOpaqueCF.get())); | 1491 SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(for
ceOpaqueCF.get())); |
| 1492 REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack()); | 1492 REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack()); |
| 1493 REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds()); | 1493 REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds()); |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 // Verify that SkImageSource survives serialization | 1496 // Verify that SkImageSource survives serialization |
| 1497 DEF_TEST(ImageFilterImageSourceSerialization, reporter) { | 1497 DEF_TEST(ImageFilterImageSourceSerialization, reporter) { |
| 1498 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(10, 10)); | 1498 auto surface(SkSurface::MakeRasterN32Premul(10, 10)); |
| 1499 surface->getCanvas()->clear(SK_ColorGREEN); | 1499 surface->getCanvas()->clear(SK_ColorGREEN); |
| 1500 sk_sp<SkImage> image(surface->makeImageSnapshot()); | 1500 sk_sp<SkImage> image(surface->makeImageSnapshot()); |
| 1501 SkAutoTUnref<SkImageFilter> filter(SkImageSource::Create(image.get())); | 1501 SkAutoTUnref<SkImageFilter> filter(SkImageSource::Create(image.get())); |
| 1502 | 1502 |
| 1503 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter)); | 1503 SkAutoTUnref<SkData> data(SkValidatingSerializeFlattenable(filter)); |
| 1504 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( | 1504 SkAutoTUnref<SkFlattenable> flattenable(SkValidatingDeserializeFlattenable( |
| 1505 data->data(), data->size(), SkImageFilter::GetFlattenableType())); | 1505 data->data(), data->size(), SkImageFilter::GetFlattenableType())); |
| 1506 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g
et()); | 1506 SkImageFilter* unflattenedFilter = static_cast<SkImageFilter*>(flattenable.g
et()); |
| 1507 REPORTER_ASSERT(reporter, unflattenedFilter); | 1507 REPORTER_ASSERT(reporter, unflattenedFilter); |
| 1508 | 1508 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 } | 1555 } |
| 1556 | 1556 |
| 1557 SkPaint paint; | 1557 SkPaint paint; |
| 1558 paint.setImageFilter(blur); | 1558 paint.setImageFilter(blur); |
| 1559 | 1559 |
| 1560 // This should not crash (http://crbug.com/570479). | 1560 // This should not crash (http://crbug.com/570479). |
| 1561 canvas->drawRect(SkRect::MakeIWH(largeW, largeH), paint); | 1561 canvas->drawRect(SkRect::MakeIWH(largeW, largeH), paint); |
| 1562 } | 1562 } |
| 1563 | 1563 |
| 1564 DEF_TEST(BlurLargeImage, reporter) { | 1564 DEF_TEST(BlurLargeImage, reporter) { |
| 1565 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(SkImageInfo::MakeN32Pre
mul(100, 100))); | 1565 auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100))); |
| 1566 test_large_blur_input(reporter, surface->getCanvas()); | 1566 test_large_blur_input(reporter, surface->getCanvas()); |
| 1567 } | 1567 } |
| 1568 | 1568 |
| 1569 #if SK_SUPPORT_GPU | 1569 #if SK_SUPPORT_GPU |
| 1570 | 1570 |
| 1571 DEF_GPUTEST_FOR_NATIVE_CONTEXT(HugeBlurImageFilter_Gpu, reporter, context) { | 1571 DEF_GPUTEST_FOR_NATIVE_CONTEXT(HugeBlurImageFilter_Gpu, reporter, context) { |
| 1572 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1572 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
| 1573 | 1573 |
| 1574 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1574 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
| 1575 SkBudgeted::kNo, | 1575 SkBudgeted::kNo, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1590 SkImageInfo::MakeN32Pre
mul(1, 1), | 1590 SkImageInfo::MakeN32Pre
mul(1, 1), |
| 1591 0, | 1591 0, |
| 1592 &props, | 1592 &props, |
| 1593 SkGpuDevice::kUninit_In
itContents)); | 1593 SkGpuDevice::kUninit_In
itContents)); |
| 1594 SkCanvas canvas(device); | 1594 SkCanvas canvas(device); |
| 1595 | 1595 |
| 1596 test_xfermode_cropped_input(&canvas, reporter); | 1596 test_xfermode_cropped_input(&canvas, reporter); |
| 1597 } | 1597 } |
| 1598 | 1598 |
| 1599 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { | 1599 DEF_GPUTEST_FOR_ALL_CONTEXTS(BlurLargeImage_Gpu, reporter, context) { |
| 1600 SkAutoTUnref<SkSurface> surface( | 1600 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, |
| 1601 SkSurface::NewRenderTarget(context, SkBudgeted::kYes, | 1601 SkImageInfo::MakeN32Premul(100, 100
))); |
| 1602 SkImageInfo::MakeN32Premul(100, 100))); | |
| 1603 test_large_blur_input(reporter, surface->getCanvas()); | 1602 test_large_blur_input(reporter, surface->getCanvas()); |
| 1604 } | 1603 } |
| 1605 #endif | 1604 #endif |
| OLD | NEW |