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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 #ifndef SK_IGNORE_TO_STRING | 92 #ifndef SK_IGNORE_TO_STRING |
93 void MatrixTestImageFilter::toString(SkString* str) const { | 93 void MatrixTestImageFilter::toString(SkString* str) const { |
94 str->appendf("MatrixTestImageFilter: ("); | 94 str->appendf("MatrixTestImageFilter: ("); |
95 str->append(")"); | 95 str->append(")"); |
96 } | 96 } |
97 #endif | 97 #endif |
98 | 98 |
99 static sk_sp<SkImage> make_small_image() { | 99 static sk_sp<SkImage> make_small_image() { |
100 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kBitmapSize, k
BitmapSize)); | 100 auto surface(SkSurface::MakeRasterN32Premul(kBitmapSize, kBitmapSize)); |
101 SkCanvas* canvas = surface->getCanvas(); | 101 SkCanvas* canvas = surface->getCanvas(); |
102 canvas->clear(0x00000000); | 102 canvas->clear(0x00000000); |
103 SkPaint darkPaint; | 103 SkPaint darkPaint; |
104 darkPaint.setColor(0xFF804020); | 104 darkPaint.setColor(0xFF804020); |
105 SkPaint lightPaint; | 105 SkPaint lightPaint; |
106 lightPaint.setColor(0xFF244484); | 106 lightPaint.setColor(0xFF244484); |
107 const int i = kBitmapSize / 4; | 107 const int i = kBitmapSize / 4; |
108 for (int y = 0; y < kBitmapSize; y += i) { | 108 for (int y = 0; y < kBitmapSize; y += i) { |
109 for (int x = 0; x < kBitmapSize; x += i) { | 109 for (int x = 0; x < kBitmapSize; x += i) { |
110 canvas->save(); | 110 canvas->save(); |
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 REPORTER_ASSERT(reporter, identityFilter->canComputeFastBounds()); | 1485 REPORTER_ASSERT(reporter, identityFilter->canComputeFastBounds()); |
1486 | 1486 |
1487 auto forceOpaqueCF(SkTableColorFilter::MakeARGB(allOne, identity, identity,
identity)); | 1487 auto forceOpaqueCF(SkTableColorFilter::MakeARGB(allOne, identity, identity,
identity)); |
1488 SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(for
ceOpaqueCF.get())); | 1488 SkAutoTUnref<SkImageFilter> forceOpaque(SkColorFilterImageFilter::Create(for
ceOpaqueCF.get())); |
1489 REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack()); | 1489 REPORTER_ASSERT(reporter, forceOpaqueCF->affectsTransparentBlack()); |
1490 REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds()); | 1490 REPORTER_ASSERT(reporter, !forceOpaque->canComputeFastBounds()); |
1491 } | 1491 } |
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 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(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(), SkImageFilter::GetFlattenableType())); |
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 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 } | 1552 } |
1553 | 1553 |
1554 SkPaint paint; | 1554 SkPaint paint; |
1555 paint.setImageFilter(blur); | 1555 paint.setImageFilter(blur); |
1556 | 1556 |
1557 // This should not crash (http://crbug.com/570479). | 1557 // This should not crash (http://crbug.com/570479). |
1558 canvas->drawRect(SkRect::MakeIWH(largeW, largeH), paint); | 1558 canvas->drawRect(SkRect::MakeIWH(largeW, largeH), paint); |
1559 } | 1559 } |
1560 | 1560 |
1561 DEF_TEST(BlurLargeImage, reporter) { | 1561 DEF_TEST(BlurLargeImage, reporter) { |
1562 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(SkImageInfo::MakeN32Pre
mul(100, 100))); | 1562 auto surface(SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100))); |
1563 test_large_blur_input(reporter, surface->getCanvas()); | 1563 test_large_blur_input(reporter, surface->getCanvas()); |
1564 } | 1564 } |
1565 | 1565 |
1566 #if SK_SUPPORT_GPU | 1566 #if SK_SUPPORT_GPU |
1567 | 1567 |
1568 DEF_GPUTEST_FOR_NATIVE_CONTEXT(HugeBlurImageFilter_Gpu, reporter, context) { | 1568 DEF_GPUTEST_FOR_NATIVE_CONTEXT(HugeBlurImageFilter_Gpu, reporter, context) { |
1569 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); | 1569 const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); |
1570 | 1570 |
1571 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, | 1571 SkAutoTUnref<SkGpuDevice> device(SkGpuDevice::Create(context, |
1572 SkBudgeted::kNo, | 1572 SkBudgeted::kNo, |
(...skipping 14 matching lines...) Expand all Loading... |
1587 SkImageInfo::MakeN32Pre
mul(1, 1), | 1587 SkImageInfo::MakeN32Pre
mul(1, 1), |
1588 0, | 1588 0, |
1589 &props, | 1589 &props, |
1590 SkGpuDevice::kUninit_In
itContents)); | 1590 SkGpuDevice::kUninit_In
itContents)); |
1591 SkCanvas canvas(device); | 1591 SkCanvas canvas(device); |
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 SkAutoTUnref<SkSurface> surface( | 1597 auto surface(SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, |
1598 SkSurface::NewRenderTarget(context, SkBudgeted::kYes, | 1598 SkImageInfo::MakeN32Premul(100, 100
))); |
1599 SkImageInfo::MakeN32Premul(100, 100))); | |
1600 test_large_blur_input(reporter, surface->getCanvas()); | 1599 test_large_blur_input(reporter, surface->getCanvas()); |
1601 } | 1600 } |
1602 #endif | 1601 #endif |
OLD | NEW |