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

Side by Side Diff: tests/CanvasTest.cpp

Issue 1302173002: [M45] SkPaintFilterCanvas should inherit the target canvas state (Closed) Base URL: https://chromium.googlesource.com/skia.git@m45
Patch Set: Created 5 years, 4 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/SkPaintFilterCanvas.cpp ('k') | no next file » | 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 2012 Google Inc. 2 * Copyright 2012 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 /* Description: 8 /* Description:
9 * This test defines a series of elementatry test steps that perform 9 * This test defines a series of elementatry test steps that perform
10 * a single or a small group of canvas API calls. Each test step is 10 * a single or a small group of canvas API calls. Each test step is
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 */ 45 */
46 #include "SkBitmap.h" 46 #include "SkBitmap.h"
47 #include "SkCanvas.h" 47 #include "SkCanvas.h"
48 #include "SkClipStack.h" 48 #include "SkClipStack.h"
49 #include "SkDeferredCanvas.h" 49 #include "SkDeferredCanvas.h"
50 #include "SkDevice.h" 50 #include "SkDevice.h"
51 #include "SkDocument.h" 51 #include "SkDocument.h"
52 #include "SkMatrix.h" 52 #include "SkMatrix.h"
53 #include "SkNWayCanvas.h" 53 #include "SkNWayCanvas.h"
54 #include "SkPaint.h" 54 #include "SkPaint.h"
55 #include "SkPaintFilterCanvas.h"
55 #include "SkPath.h" 56 #include "SkPath.h"
56 #include "SkPicture.h" 57 #include "SkPicture.h"
57 #include "SkPictureRecord.h" 58 #include "SkPictureRecord.h"
58 #include "SkPictureRecorder.h" 59 #include "SkPictureRecorder.h"
59 #include "SkRect.h" 60 #include "SkRect.h"
60 #include "SkRegion.h" 61 #include "SkRegion.h"
61 #include "SkShader.h" 62 #include "SkShader.h"
62 #include "SkStream.h" 63 #include "SkStream.h"
63 #include "SkSurface.h" 64 #include "SkSurface.h"
64 #include "SkTDArray.h" 65 #include "SkTDArray.h"
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 canvas.restore(); 768 canvas.restore();
768 canvas.save(); 769 canvas.save();
769 path.moveTo(5, 5); 770 path.moveTo(5, 5);
770 canvas.clipPath(path); 771 canvas.clipPath(path);
771 canvas.restore(); 772 canvas.restore();
772 canvas.save(); 773 canvas.save();
773 path.moveTo(7, 7); 774 path.moveTo(7, 7);
774 canvas.clipPath(path); // should not assert here 775 canvas.clipPath(path); // should not assert here
775 canvas.restore(); 776 canvas.restore();
776 } 777 }
778
779 namespace {
780
781 class MockFilterCanvas : public SkPaintFilterCanvas {
782 public:
783 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { }
784
785 protected:
786 void onFilterPaint(SkPaint *paint, Type type) const override { }
787
788 private:
789 typedef SkPaintFilterCanvas INHERITED;
790 };
791
792 } // anonymous namespace
793
794 // SkPaintFilterCanvas should inherit the initial target canvas state.
795 DEF_TEST(PaintFilterCanvas_ConsistentState, reporter) {
796 SkCanvas canvas(100, 100);
797 canvas.clipRect(SkRect::MakeXYWH(12.7f, 12.7f, 75, 75));
798 canvas.scale(0.5f, 0.75f);
799
800 SkRect clip1, clip2;
801
802 MockFilterCanvas filterCanvas(&canvas);
803 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
804 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
805 REPORTER_ASSERT(reporter, clip1 == clip2);
806
807 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100));
808 filterCanvas.scale(0.75f, 0.5f);
809 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
810 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
811 REPORTER_ASSERT(reporter, clip1 == clip2);
812 }
OLDNEW
« no previous file with comments | « src/utils/SkPaintFilterCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698