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

Unified Diff: tests/ImageFilterTest.cpp

Issue 145723007: Fix a problem with hiDPI filters vs tiled SkPicture playback. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix nit Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkPictureStateTree.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageFilterTest.cpp
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 22f63b7c7016c37714ec2ee1bd16f5b1705eaa11..a1d7a50f05728cd34fcc53638465b29852e2df0c 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -16,11 +16,13 @@
#include "SkDeviceImageFilterProxy.h"
#include "SkDisplacementMapEffect.h"
#include "SkDropShadowImageFilter.h"
+#include "SkFlattenableBuffers.h"
#include "SkLightingImageFilter.h"
#include "SkMatrixConvolutionImageFilter.h"
#include "SkMergeImageFilter.h"
#include "SkMorphologyImageFilter.h"
#include "SkOffsetImageFilter.h"
+#include "SkPicture.h"
#include "SkRect.h"
#include "SkTileImageFilter.h"
#include "SkXfermodeImageFilter.h"
@@ -33,6 +35,40 @@
static const int kBitmapSize = 4;
+namespace {
+
+class MatrixTestImageFilter : public SkImageFilter {
+public:
+ MatrixTestImageFilter(skiatest::Reporter* reporter, const SkMatrix& expectedMatrix)
+ : SkImageFilter(0), fReporter(reporter), fExpectedMatrix(expectedMatrix) {
+ }
+
+ virtual bool onFilterImage(Proxy*, const SkBitmap& src, const SkMatrix& ctm,
+ SkBitmap* result, SkIPoint* offset) SK_OVERRIDE {
+ REPORTER_ASSERT(fReporter, ctm == fExpectedMatrix);
+ return true;
+ }
+
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter)
+
+protected:
+ explicit MatrixTestImageFilter(SkReadBuffer& buffer) : SkImageFilter(0) {
+ fReporter = static_cast<skiatest::Reporter*>(buffer.readFunctionPtr());
+ buffer.readMatrix(&fExpectedMatrix);
+ }
+
+ virtual void flatten(SkWriteBuffer& buffer) const SK_OVERRIDE {
+ buffer.writeFunctionPtr(fReporter);
+ buffer.writeMatrix(fExpectedMatrix);
+ }
+
+private:
+ skiatest::Reporter* fReporter;
+ SkMatrix fExpectedMatrix;
+};
+
+}
+
static void make_small_bitmap(SkBitmap& bitmap) {
bitmap.setConfig(SkBitmap::kARGB_8888_Config, kBitmapSize, kBitmapSize);
bitmap.allocPixels();
@@ -230,6 +266,39 @@ DEF_TEST(ImageFilterCropRect, reporter) {
test_crop_rects(&device, reporter);
}
+DEF_TEST(ImageFilterMatrixTest, reporter) {
+ SkBitmap temp;
+ temp.setConfig(SkBitmap::kARGB_8888_Config, 100, 100);
+ temp.allocPixels();
+ SkBitmapDevice device(temp);
+ SkCanvas canvas(&device);
+ canvas.scale(SkIntToScalar(2), SkIntToScalar(2));
+
+ SkMatrix expectedMatrix = canvas.getTotalMatrix();
+
+ SkPicture picture;
+ SkCanvas* recordingCanvas = picture.beginRecording(100, 100,
+ SkPicture::kOptimizeForClippedPlayback_RecordingFlag);
+
+ SkPaint paint;
+ SkAutoTUnref<MatrixTestImageFilter> imageFilter(
+ new MatrixTestImageFilter(reporter, expectedMatrix));
+ paint.setImageFilter(imageFilter.get());
+ SkCanvas::SaveFlags saveFlags = static_cast<SkCanvas::SaveFlags>(
+ SkCanvas::kHasAlphaLayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag);
+ recordingCanvas->saveLayer(NULL, &paint, saveFlags);
+ SkPaint solidPaint;
+ solidPaint.setColor(0xFFFFFFFF);
+ recordingCanvas->save();
+ recordingCanvas->scale(SkIntToScalar(10), SkIntToScalar(10));
+ recordingCanvas->drawRect(SkRect::Make(SkIRect::MakeWH(100, 100)), solidPaint);
+ recordingCanvas->restore(); // scale
+ recordingCanvas->restore(); // saveLayer
+ picture.endRecording();
+
+ canvas.drawPicture(picture);
+}
+
#if SK_SUPPORT_GPU
DEF_GPUTEST(ImageFilterCropRectGPU, reporter, factory) {
GrContext* context = factory->get(static_cast<GrContextFactory::GLContextType>(0));
« no previous file with comments | « src/core/SkPictureStateTree.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698