diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/DeferredCanvasTest.cpp | 14 | ||||
-rw-r--r-- | tests/ImageFilterTest.cpp | 104 | ||||
-rw-r--r-- | tests/LayerDrawLooperTest.cpp | 7 | ||||
-rw-r--r-- | tests/PremulAlphaRoundTripTest.cpp | 4 | ||||
-rw-r--r-- | tests/ReadPixelsTest.cpp | 1 | ||||
-rw-r--r-- | tests/SkImageTest.cpp | 8 | ||||
-rw-r--r-- | tests/WritePixelsTest.cpp | 1 |
7 files changed, 63 insertions, 76 deletions
diff --git a/tests/DeferredCanvasTest.cpp b/tests/DeferredCanvasTest.cpp index 60d7d0a038..fff213b607 100644 --- a/tests/DeferredCanvasTest.cpp +++ b/tests/DeferredCanvasTest.cpp @@ -8,7 +8,6 @@ #include "../src/image/SkImagePriv.h" #include "../src/image/SkSurface_Base.h" #include "SkBitmap.h" -#include "SkBitmapDevice.h" #include "SkBitmapProcShader.h" #include "SkDeferredCanvas.h" #include "SkGradientShader.h" @@ -440,19 +439,6 @@ static void TestDeferredCanvasFreshFrame(skiatest::Reporter* reporter) { } } -class MockDevice : public SkBitmapDevice { -public: - MockDevice(const SkBitmap& bm) : SkBitmapDevice(bm) { - fDrawBitmapCallCount = 0; - } - virtual void drawBitmap(const SkDraw&, const SkBitmap&, - const SkMatrix&, const SkPaint&) override { - fDrawBitmapCallCount++; - } - - int fDrawBitmapCallCount; -}; - class NotificationCounter : public SkDeferredCanvas::NotificationClient { public: NotificationCounter() { diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp index 20bf0aa6d3..63e3aaa6f0 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -264,14 +264,13 @@ DEF_TEST(ImageFilter, reporter) { } } -static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter) { +static void test_crop_rects(SkImageFilter::Proxy* proxy, skiatest::Reporter* reporter) { // Check that all filters offset to their absolute crop rect, // unaffected by the input crop rect. // Tests pass by not asserting. SkBitmap bitmap; bitmap.allocN32Pixels(100, 100); bitmap.eraseARGB(0, 0, 0, 0); - SkImageFilter::Proxy proxy(device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)); SkImageFilter::CropRect inputCropRect(SkRect::MakeXYWH(8, 13, 80, 80)); SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(20, 30, 60, 60)); @@ -316,7 +315,7 @@ static void test_crop_rects(SkBaseDevice* device, skiatest::Reporter* reporter) SkString str; str.printf("filter %d", static_cast<int>(i)); SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); - REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(&proxy, bitmap, ctx, + REPORTER_ASSERT_MESSAGE(reporter, filter->filterImage(proxy, bitmap, ctx, &result, &offset), str.c_str()); REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, str.c_str()); } @@ -347,11 +346,10 @@ static SkBitmap make_gradient_circle(int width, int height) { return bitmap; } -static void test_negative_blur_sigma(SkBaseDevice* device, skiatest::Reporter* reporter) { +static void test_negative_blur_sigma(SkImageFilter::Proxy* proxy, skiatest::Reporter* reporter) { // Check that SkBlurImageFilter will accept a negative sigma, either in // the given arguments or after CTM application. int width = 32, height = 32; - SkImageFilter::Proxy proxy(device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)); SkScalar five = SkIntToScalar(5); SkAutoTUnref<SkBlurImageFilter> positiveFilter( @@ -367,13 +365,13 @@ static void test_negative_blur_sigma(SkBaseDevice* device, skiatest::Reporter* r SkBitmap positiveResult2, negativeResult2; SkIPoint offset; SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeLargest(), NULL); - positiveFilter->filterImage(&proxy, gradient, ctx, &positiveResult1, &offset); - negativeFilter->filterImage(&proxy, gradient, ctx, &negativeResult1, &offset); + positiveFilter->filterImage(proxy, gradient, ctx, &positiveResult1, &offset); + negativeFilter->filterImage(proxy, gradient, ctx, &negativeResult1, &offset); SkMatrix negativeScale; negativeScale.setScale(-SK_Scalar1, SK_Scalar1); SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeLargest(), NULL); - positiveFilter->filterImage(&proxy, gradient, negativeCTX, &negativeResult2, &offset); - negativeFilter->filterImage(&proxy, gradient, negativeCTX, &positiveResult2, &offset); + positiveFilter->filterImage(proxy, gradient, negativeCTX, &negativeResult2, &offset); + negativeFilter->filterImage(proxy, gradient, negativeCTX, &positiveResult2, &offset); SkAutoLockPixels lockP1(positiveResult1); SkAutoLockPixels lockP2(positiveResult2); SkAutoLockPixels lockN1(negativeResult1); @@ -398,10 +396,13 @@ static void test_negative_blur_sigma(SkBaseDevice* device, skiatest::Reporter* r } DEF_TEST(TestNegativeBlurSigma, reporter) { - SkBitmap temp; - temp.allocN32Pixels(100, 100); - SkBitmapDevice device(temp); - test_negative_blur_sigma(&device, reporter); + const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); + const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); + + SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); + SkImageFilter::Proxy proxy(device, props); + + test_negative_blur_sigma(&proxy, reporter); } DEF_TEST(ImageFilterDrawTiled, reporter) { @@ -768,17 +769,19 @@ DEF_TEST(ImageFilterMatrixConvolutionBorder, reporter) { } DEF_TEST(ImageFilterCropRect, reporter) { - SkBitmap temp; - temp.allocN32Pixels(100, 100); - SkBitmapDevice device(temp); - test_crop_rects(&device, reporter); + const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); + const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); + + SkAutoTUnref<SkBaseDevice> device(SkBitmapDevice::Create(info, props)); + SkImageFilter::Proxy proxy(device, props); + + test_crop_rects(&proxy, reporter); } DEF_TEST(ImageFilterMatrix, reporter) { SkBitmap temp; temp.allocN32Pixels(100, 100); - SkBitmapDevice device(temp); - SkCanvas canvas(&device); + SkCanvas canvas(temp); canvas.scale(SkIntToScalar(2), SkIntToScalar(2)); SkMatrix expectedMatrix = canvas.getTotalMatrix(); @@ -833,8 +836,7 @@ DEF_TEST(ImageFilterCrossProcessPictureImageFilter, reporter) { SkBitmap bitmap; bitmap.allocN32Pixels(1, 1); - SkBitmapDevice device(bitmap); - SkCanvas canvas(&device); + SkCanvas canvas(bitmap); // The result here should be green, since the filter replaces the primitive's red interior. canvas.clear(0x0); @@ -876,15 +878,14 @@ DEF_TEST(ImageFilterClippedPictureImageFilter, reporter) { recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(1, 1)), greenPaint); SkAutoTUnref<SkPicture> picture(recorder.endRecording()); - SkAutoTUnref<SkImageFilter> imageFilter( - SkPictureImageFilter::Create(picture.get())); + SkAutoTUnref<SkImageFilter> imageFilter(SkPictureImageFilter::Create(picture.get())); SkBitmap result; SkIPoint offset; SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), NULL); SkBitmap bitmap; bitmap.allocN32Pixels(2, 2); - SkBitmapDevice device(bitmap); + SkBitmapDevice device(bitmap, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)); SkImageFilter::Proxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)); REPORTER_ASSERT(reporter, !imageFilter->filterImage(&proxy, bitmap, ctx, &result, &offset)); } @@ -895,8 +896,7 @@ DEF_TEST(ImageFilterEmptySaveLayer, reporter) { SkBitmap bitmap; bitmap.allocN32Pixels(10, 10); - SkBitmapDevice device(bitmap); - SkCanvas canvas(&device); + SkCanvas canvas(bitmap); SkRTreeFactory factory; SkPictureRecorder recorder; @@ -943,9 +943,7 @@ DEF_TEST(ImageFilterEmptySaveLayer, reporter) { REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); } -static void test_huge_blur(SkBaseDevice* device, skiatest::Reporter* reporter) { - SkCanvas canvas(device); - +static void test_huge_blur(SkCanvas* canvas, skiatest::Reporter* reporter) { SkBitmap bitmap; bitmap.allocN32Pixels(100, 100); bitmap.eraseARGB(0, 0, 0, 0); @@ -955,14 +953,14 @@ static void test_huge_blur(SkBaseDevice* device, skiatest::Reporter* reporter) { SkPaint paint; paint.setImageFilter(blur); - canvas.drawSprite(bitmap, 0, 0, &paint); + canvas->drawSprite(bitmap, 0, 0, &paint); } DEF_TEST(HugeBlurImageFilter, reporter) { SkBitmap temp; temp.allocN32Pixels(100, 100); - SkBitmapDevice device(temp); - test_huge_blur(&device, reporter); + SkCanvas canvas(temp); + test_huge_blur(&canvas, reporter); } DEF_TEST(MatrixConvolutionSanityTest, reporter) { @@ -1019,9 +1017,8 @@ DEF_TEST(MatrixConvolutionSanityTest, reporter) { REPORTER_ASSERT(reporter, NULL == conv.get()); } -static void test_xfermode_cropped_input(SkBaseDevice* device, skiatest::Reporter* reporter) { - SkCanvas canvas(device); - canvas.clear(0); +static void test_xfermode_cropped_input(SkCanvas* canvas, skiatest::Reporter* reporter) { + canvas->clear(0); SkBitmap bitmap; bitmap.allocN32Pixels(1, 1); @@ -1047,29 +1044,28 @@ static void test_xfermode_cropped_input(SkBaseDevice* device, skiatest::Reporter SkPaint paint; paint.setImageFilter(xfermodeNoFg); - canvas.drawSprite(bitmap, 0, 0, &paint); + canvas->drawSprite(bitmap, 0, 0, &paint); uint32_t pixel; SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul_SkAlphaType); - canvas.readPixels(info, &pixel, 4, 0, 0); + canvas->readPixels(info, &pixel, 4, 0, 0); REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); paint.setImageFilter(xfermodeNoBg); - canvas.drawSprite(bitmap, 0, 0, &paint); - canvas.readPixels(info, &pixel, 4, 0, 0); + canvas->drawSprite(bitmap, 0, 0, &paint); + canvas->readPixels(info, &pixel, 4, 0, 0); REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); paint.setImageFilter(xfermodeNoFgNoBg); - canvas.drawSprite(bitmap, 0, 0, &paint); - canvas.readPixels(info, &pixel, 4, 0, 0); + canvas->drawSprite(bitmap, 0, 0, &paint); + canvas->readPixels(info, &pixel, 4, 0, 0); REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); } DEF_TEST(ImageFilterNestedSaveLayer, reporter) { SkBitmap temp; temp.allocN32Pixels(50, 50); - SkBitmapDevice device(temp); - SkCanvas canvas(&device); + SkCanvas canvas(temp); canvas.clear(0x0); SkBitmap bitmap; @@ -1119,15 +1115,15 @@ DEF_TEST(ImageFilterNestedSaveLayer, reporter) { DEF_TEST(XfermodeImageFilterCroppedInput, reporter) { SkBitmap temp; temp.allocN32Pixels(100, 100); - SkBitmapDevice device(temp); - test_xfermode_cropped_input(&device, reporter); + SkCanvas canvas(temp); + test_xfermode_cropped_input(&canvas, reporter); } DEF_TEST(ComposedImageFilterOffset, reporter) { SkBitmap bitmap; bitmap.allocN32Pixels(100, 100); bitmap.eraseARGB(0, 0, 0, 0); - SkBitmapDevice device(bitmap); + SkBitmapDevice device(bitmap, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)); SkImageFilter::Proxy proxy(&device, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)); SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(1, 0, 20, 20)); @@ -1154,7 +1150,9 @@ DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) { SkImageInfo::MakeN32Premul(100, 100), 0, &gProps)); - test_crop_rects(device, reporter); + SkImageFilter::Proxy proxy(device, gProps); + + test_crop_rects(&proxy, reporter); } DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { @@ -1167,7 +1165,9 @@ DEF_GPUTEST(HugeBlurImageFilterGPU, reporter, factory) { SkImageInfo::MakeN32Premul(100, 100), 0, &gProps)); - test_huge_blur(device, reporter); + SkCanvas canvas(device); + + test_huge_blur(&canvas, reporter); } DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { @@ -1180,7 +1180,9 @@ DEF_GPUTEST(XfermodeImageFilterCroppedInputGPU, reporter, factory) { SkImageInfo::MakeN32Premul(1, 1), 0, &gProps)); - test_xfermode_cropped_input(device, reporter); + SkCanvas canvas(device); + + test_xfermode_cropped_input(&canvas, reporter); } DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { @@ -1193,6 +1195,8 @@ DEF_GPUTEST(TestNegativeBlurSigmaGPU, reporter, factory) { SkImageInfo::MakeN32Premul(1, 1), 0, &gProps)); - test_negative_blur_sigma(device, reporter); + SkImageFilter::Proxy proxy(device, gProps); + + test_negative_blur_sigma(&proxy, reporter); } #endif diff --git a/tests/LayerDrawLooperTest.cpp b/tests/LayerDrawLooperTest.cpp index 2c9b525aa2..391db7ce7f 100644 --- a/tests/LayerDrawLooperTest.cpp +++ b/tests/LayerDrawLooperTest.cpp @@ -25,12 +25,13 @@ static SkBitmap make_bm(int w, int h) { return bm; } +// TODO: can this be derived from SkBaseDevice? class FakeDevice : public SkBitmapDevice { public: - FakeDevice() : SkBitmapDevice(make_bm(100, 100)) { } + FakeDevice() : INHERITED(make_bm(100, 100), SkSurfaceProps(0, kUnknown_SkPixelGeometry)) { + } - virtual void drawRect(const SkDraw& draw, const SkRect& r, - const SkPaint& paint) override { + void drawRect(const SkDraw& draw, const SkRect& r, const SkPaint& paint) override { fLastMatrix = *draw.fMatrix; this->INHERITED::drawRect(draw, r, paint); } diff --git a/tests/PremulAlphaRoundTripTest.cpp b/tests/PremulAlphaRoundTripTest.cpp index 9f5d6ff338..e48885c930 100644 --- a/tests/PremulAlphaRoundTripTest.cpp +++ b/tests/PremulAlphaRoundTripTest.cpp @@ -74,10 +74,11 @@ DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) { glCtxTypeCnt = GrContextFactory::kGLContextTypeCnt; } #endif + SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); for (int glCtxType = 0; glCtxType < glCtxTypeCnt; ++glCtxType) { SkAutoTUnref<SkBaseDevice> device; if (0 == dtype) { - device.reset(SkBitmapDevice::Create(info)); + device.reset(SkBitmapDevice::Create(info, props)); } else { #if SK_SUPPORT_GPU GrContextFactory::GLContextType type = @@ -89,7 +90,6 @@ DEF_GPUTEST(PremulAlphaRoundTrip, reporter, factory) { if (NULL == ctx) { continue; } - SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); device.reset(SkGpuDevice::Create(ctx, SkSurface::kNo_Budgeted, info, 0, &props)); #else continue; diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp index a45e9ee9cd..59c826fbf0 100644 --- a/tests/ReadPixelsTest.cpp +++ b/tests/ReadPixelsTest.cpp @@ -5,7 +5,6 @@ * found in the LICENSE file. */ -#include "SkBitmapDevice.h" #include "SkCanvas.h" #include "SkColorPriv.h" #include "SkMathPriv.h" diff --git a/tests/SkImageTest.cpp b/tests/SkImageTest.cpp index 3ba63b4258..c058ef062b 100644 --- a/tests/SkImageTest.cpp +++ b/tests/SkImageTest.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ -#include "SkBitmapDevice.h" +#include "SkCanvas.h" #include "SkImagePriv.h" #include "Test.h" @@ -19,8 +19,7 @@ DEF_TEST(SkImageFromBitmap_extractSubset, reporter) { SkBitmap srcBitmap; srcBitmap.allocN32Pixels(gWidth, gHeight); srcBitmap.eraseColor(SK_ColorRED); - SkBitmapDevice dev(srcBitmap); - SkCanvas canvas(&dev); + SkCanvas canvas(srcBitmap); SkIRect r = SkIRect::MakeXYWH(5, 5, gWidth - 5, gWidth - 5); SkPaint p; p.setColor(SK_ColorGREEN); @@ -32,8 +31,7 @@ DEF_TEST(SkImageFromBitmap_extractSubset, reporter) { SkBitmap tgt; tgt.allocN32Pixels(gWidth, gHeight); - SkBitmapDevice dev(tgt); - SkCanvas canvas(&dev); + SkCanvas canvas(tgt); canvas.clear(SK_ColorTRANSPARENT); canvas.drawImage(image, 0, 0, NULL); diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp index d1c328e6ec..fa99d4c9ec 100644 --- a/tests/WritePixelsTest.cpp +++ b/tests/WritePixelsTest.cpp @@ -5,7 +5,6 @@ * found in the LICENSE file. */ -#include "SkBitmapDevice.h" #include "SkCanvas.h" #include "SkColorPriv.h" #include "SkMathPriv.h" |