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

Side by Side Diff: tests/CanvasTest.cpp

Issue 2167223002: Revert of Creating framework for drawShadowedPicture (Closed) Base URL: https://skia.googlesource.com/skia@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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 #define SHADOW_TEST_CANVAS_CONST 10 782 #define SHADOW_TEST_CANVAS_CONST 10
783 #ifdef SK_EXPERIMENTAL_SHADOWING 783
784 class SkShadowTestCanvas : public SkPaintFilterCanvas { 784 class SkShadowTestCanvas : public SkPaintFilterCanvas {
785 public: 785 public:
786 786
787 SkShadowTestCanvas(int x, int y, skiatest::Reporter* reporter) 787 SkShadowTestCanvas(int x, int y, skiatest::Reporter* reporter)
788 : INHERITED(x,y) 788 : INHERITED(x,y)
789 , fReporter(reporter) {} 789 , fReporter(reporter) {}
790 790
791 bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type type) const { 791 bool onFilter(SkTCopyOnFirstWrite<SkPaint>* paint, Type type) const {
792 REPORTER_ASSERT(this->fReporter, this->getZ() == SHADOW_TEST_CANVAS_CONS T); 792 REPORTER_ASSERT(this->fReporter, this->getZ() == SHADOW_TEST_CANVAS_CONS T);
793 793
(...skipping 16 matching lines...) Expand all
810 810
811 this->translateZ(13.14f); 811 this->translateZ(13.14f);
812 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(this->getZ(), 3.14f)); 812 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(this->getZ(), 3.14f));
813 } 813 }
814 814
815 private: 815 private:
816 skiatest::Reporter* fReporter; 816 skiatest::Reporter* fReporter;
817 817
818 typedef SkPaintFilterCanvas INHERITED; 818 typedef SkPaintFilterCanvas INHERITED;
819 }; 819 };
820 #endif
821 820
822 namespace { 821 namespace {
823 822
824 class MockFilterCanvas : public SkPaintFilterCanvas { 823 class MockFilterCanvas : public SkPaintFilterCanvas {
825 public: 824 public:
826 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { } 825 MockFilterCanvas(SkCanvas* canvas) : INHERITED(canvas) { }
827 826
828 protected: 827 protected:
829 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; } 828 bool onFilter(SkTCopyOnFirstWrite<SkPaint>*, Type) const override { return t rue; }
830 829
(...skipping 15 matching lines...) Expand all
846 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 845 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
847 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 846 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
848 REPORTER_ASSERT(reporter, clip1 == clip2); 847 REPORTER_ASSERT(reporter, clip1 == clip2);
849 848
850 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100)); 849 filterCanvas.clipRect(SkRect::MakeXYWH(30.5f, 30.7f, 100, 100));
851 filterCanvas.scale(0.75f, 0.5f); 850 filterCanvas.scale(0.75f, 0.5f);
852 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix()); 851 REPORTER_ASSERT(reporter, canvas.getTotalMatrix() == filterCanvas.getTotalMa trix());
853 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2)); 852 REPORTER_ASSERT(reporter, canvas.getClipBounds(&clip1) == filterCanvas.getCl ipBounds(&clip2));
854 REPORTER_ASSERT(reporter, clip1 == clip2); 853 REPORTER_ASSERT(reporter, clip1 == clip2);
855 854
856 #ifdef SK_EXPERIMENTAL_SHADOWING
857 SkShadowTestCanvas* tCanvas = new SkShadowTestCanvas(100,100, reporter); 855 SkShadowTestCanvas* tCanvas = new SkShadowTestCanvas(100,100, reporter);
858 tCanvas->testUpdateDepth(reporter); 856 tCanvas->testUpdateDepth(reporter);
859 delete(tCanvas); 857 delete(tCanvas);
860 858
861 SkPictureRecorder recorder; 859 SkPictureRecorder recorder;
862 SkShadowTestCanvas *tSCanvas = new SkShadowTestCanvas(100, 100, reporter); 860 SkShadowTestCanvas *tSCanvas = new SkShadowTestCanvas(100, 100, reporter);
863 SkCanvas *tPCanvas = recorder.beginRecording(SkRect::MakeIWH(100, 100)); 861 SkCanvas *tPCanvas = recorder.beginRecording(SkRect::MakeIWH(100, 100));
864 862
865 tPCanvas->translateZ(SHADOW_TEST_CANVAS_CONST); 863 tPCanvas->translateZ(SHADOW_TEST_CANVAS_CONST);
866 sk_sp<SkPicture> pic = recorder.finishRecordingAsPicture(); 864 sk_sp<SkPicture> pic = recorder.finishRecordingAsPicture();
867 tSCanvas->drawPicture(pic); 865 tSCanvas->drawPicture(pic);
868 866
869 delete(tSCanvas); 867 delete(tSCanvas);
870 #endif
871 } 868 }
872 869
873 //////////////////////////////////////////////////////////////////////////////// /////////////////// 870 //////////////////////////////////////////////////////////////////////////////// ///////////////////
874 871
875 #include "SkDeferredCanvas.h" 872 #include "SkDeferredCanvas.h"
876 #include "SkDumpCanvas.h" 873 #include "SkDumpCanvas.h"
877 874
878 DEF_TEST(DeferredCanvas, r) { 875 DEF_TEST(DeferredCanvas, r) {
879 SkDebugfDumper dumper; 876 SkDebugfDumper dumper;
880 SkDumpCanvas dumpC(&dumper); 877 SkDumpCanvas dumpC(&dumper);
881 878
882 SkDeferredCanvas canvas(&dumpC); 879 SkDeferredCanvas canvas(&dumpC);
883 880
884 SkPaint paint; 881 SkPaint paint;
885 // paint.setShader(SkShader::MakeColorShader(SK_ColorRED)); 882 // paint.setShader(SkShader::MakeColorShader(SK_ColorRED));
886 883
887 canvas.save(); 884 canvas.save();
888 canvas.clipRect(SkRect::MakeWH(55, 55)); 885 canvas.clipRect(SkRect::MakeWH(55, 55));
889 canvas.translate(10, 20); 886 canvas.translate(10, 20);
890 canvas.drawRect(SkRect::MakeWH(50, 50), paint); 887 canvas.drawRect(SkRect::MakeWH(50, 50), paint);
891 canvas.restore(); 888 canvas.restore();
892 } 889 }
893 890
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