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

Side by Side Diff: tests/CanvasTest.cpp

Issue 2147963002: Revert "Added the framework for having canvas/recorder/picture record depth_set's." (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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/core/SkRecorder.cpp ('k') | tools/debugger/SkDebugCanvas.h » ('j') | 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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 canvas.save(); 772 canvas.save();
773 path.moveTo(5, 5); 773 path.moveTo(5, 5);
774 canvas.clipPath(path); 774 canvas.clipPath(path);
775 canvas.restore(); 775 canvas.restore();
776 canvas.save(); 776 canvas.save();
777 path.moveTo(7, 7); 777 path.moveTo(7, 7);
778 canvas.clipPath(path); // should not assert here 778 canvas.clipPath(path); // should not assert here
779 canvas.restore(); 779 canvas.restore();
780 } 780 }
781 781
782 class SkTestCanvas : public SkCanvas {
783 public:
784 void testUpdateDepth(skiatest::Reporter* reporter) {
785 // set some depths (with picture enabled), then check them as they get s et
786
787 REPORTER_ASSERT(reporter, this->getZ() == 0);
788 this->translateZ(-10);
789 REPORTER_ASSERT(reporter, this->getZ() == -10);
790
791 this->save();
792 this->translateZ(20);
793 REPORTER_ASSERT(reporter, this->getZ() == 10);
794
795 this->restore();
796 REPORTER_ASSERT(reporter, this->getZ() == -10);
797
798 this->translateZ(13.14f);
799 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(this->getZ(),3.14f));
800 }
801 };
802
803 namespace { 782 namespace {
804 783
805 class MockFilterCanvas : public SkPaintFilterCanvas { 784 class MockFilterCanvas : public SkPaintFilterCanvas {
806 public: 785 public:
807 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } 786 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { }
808 787
809 protected: 788 protected:
810 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; } 789 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; }
811 790
812 private: 791 private:
(...skipping 13 matching lines...) Expand all
826 MockFilterCanvas filterCanvas(&canvas); 805 MockFilterCanvas filterCanvas(&canvas);
827 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 806 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
828 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 807 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
829 REPORTER_ASSERT(reporter, clip1 == clip2); 808 REPORTER_ASSERT(reporter, clip1 == clip2);
830 809
831 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); 810 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100));
832 filterCanvas.scale(0.75f, 0.5f); 811 filterCanvas.scale(0.75f, 0.5f);
833 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 812 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
834 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 813 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
835 REPORTER_ASSERT(reporter, clip1 == clip2); 814 REPORTER_ASSERT(reporter, clip1 == clip2);
836
837 SkTestCanvas* tCanvas;
838
839 tCanvas = (SkTestCanvas*) new SkCanvas(100,100);
840 tCanvas->testUpdateDepth(reporter);
841 } 815 }
842 816
843 //////////////////////////////////////////////////////////////////////////////// /////////////////// 817 //////////////////////////////////////////////////////////////////////////////// ///////////////////
844 818
845 #include "SkDeferredCanvas.h" 819 #include "SkDeferredCanvas.h"
846 #include "SkDumpCanvas.h" 820 #include "SkDumpCanvas.h"
847 821
848 DEF_TEST(DeferredCanvas, r) { 822 DEF_TEST(DeferredCanvas, r) {
849 SkDebugfDumper dumper; 823 SkDebugfDumper dumper;
850 SkDumpCanvas dumpC(&dumper); 824 SkDumpCanvas dumpC(&dumper);
851 825
852 SkDeferredCanvas canvas(&dumpC); 826 SkDeferredCanvas canvas(&dumpC);
853 827
854 SkPaint paint; 828 SkPaint paint;
855 // paint.setShader(SkShader::MakeColorShader(SK_ColorRED)); 829 // paint.setShader(SkShader::MakeColorShader(SK_ColorRED));
856 830
857 canvas.save(); 831 canvas.save();
858 canvas.clipRect(SkRect::MakeWH(55, 55)); 832 canvas.clipRect(SkRect::MakeWH(55, 55));
859 canvas.translate(10, 20); 833 canvas.translate(10, 20);
860 canvas.drawRect(SkRect::MakeWH(50, 50), paint); 834 canvas.drawRect(SkRect::MakeWH(50, 50), paint);
861 canvas.restore(); 835 canvas.restore();
862 } 836 }
863 837
OLDNEW
« no previous file with comments | « src/core/SkRecorder.cpp ('k') | tools/debugger/SkDebugCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698