OLD | NEW |
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 #include "SkBitmapDevice.h" | 8 #include "SkBitmapDevice.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom); | 915 REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom); |
916 REPORTER_ASSERT(reporter, 8 == clipBounds.fRight); | 916 REPORTER_ASSERT(reporter, 8 == clipBounds.fRight); |
917 } | 917 } |
918 } | 918 } |
919 | 919 |
920 /** | 920 /** |
921 * A canvas that records the number of clip commands. | 921 * A canvas that records the number of clip commands. |
922 */ | 922 */ |
923 class ClipCountingCanvas : public SkCanvas { | 923 class ClipCountingCanvas : public SkCanvas { |
924 public: | 924 public: |
925 explicit ClipCountingCanvas(SkBaseDevice* device) | 925 explicit ClipCountingCanvas(int width, int height) |
926 : SkCanvas(device) | 926 : INHERITED(width, height) |
927 , fClipCount(0){ | 927 , fClipCount(0){ |
928 } | 928 } |
929 | 929 |
930 virtual bool clipRect(const SkRect& r, SkRegion::Op op, bool doAA) | 930 virtual bool clipRect(const SkRect& r, SkRegion::Op op, bool doAA) |
931 SK_OVERRIDE { | 931 SK_OVERRIDE { |
932 fClipCount += 1; | 932 fClipCount += 1; |
933 return this->INHERITED::clipRect(r, op, doAA); | 933 return this->INHERITED::clipRect(r, op, doAA); |
934 } | 934 } |
935 | 935 |
936 virtual bool clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) | 936 virtual bool clipRRect(const SkRRect& rrect, SkRegion::Op op, bool doAA) |
(...skipping 21 matching lines...) Expand all Loading... |
958 SkCanvas* canvas = picture.beginRecording(10, 10, 0); | 958 SkCanvas* canvas = picture.beginRecording(10, 10, 0); |
959 | 959 |
960 canvas->clipRect(SkRect::MakeEmpty(), SkRegion::kReplace_Op); | 960 canvas->clipRect(SkRect::MakeEmpty(), SkRegion::kReplace_Op); |
961 // The following expanding clip should not be skipped. | 961 // The following expanding clip should not be skipped. |
962 canvas->clipRect(SkRect::MakeXYWH(4, 4, 3, 3), SkRegion::kUnion_Op); | 962 canvas->clipRect(SkRect::MakeXYWH(4, 4, 3, 3), SkRegion::kUnion_Op); |
963 // Draw something so the optimizer doesn't just fold the world. | 963 // Draw something so the optimizer doesn't just fold the world. |
964 SkPaint p; | 964 SkPaint p; |
965 p.setColor(SK_ColorBLUE); | 965 p.setColor(SK_ColorBLUE); |
966 canvas->drawPaint(p); | 966 canvas->drawPaint(p); |
967 | 967 |
968 SkBitmapDevice testDevice(SkBitmap::kNo_Config, 10, 10); | 968 ClipCountingCanvas testCanvas(10, 10); |
969 ClipCountingCanvas testCanvas(&testDevice); | |
970 picture.draw(&testCanvas); | 969 picture.draw(&testCanvas); |
971 | 970 |
972 // Both clips should be present on playback. | 971 // Both clips should be present on playback. |
973 REPORTER_ASSERT(reporter, testCanvas.getClipCount() == 2); | 972 REPORTER_ASSERT(reporter, testCanvas.getClipCount() == 2); |
974 } | 973 } |
975 | 974 |
976 static void test_hierarchical(skiatest::Reporter* reporter) { | 975 static void test_hierarchical(skiatest::Reporter* reporter) { |
977 SkBitmap bm; | 976 SkBitmap bm; |
978 make_bm(&bm, 10, 10, SK_ColorRED, true); | 977 make_bm(&bm, 10, 10, SK_ColorRED, true); |
979 | 978 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 #endif | 1024 #endif |
1026 test_peephole(); | 1025 test_peephole(); |
1027 test_gatherpixelrefs(reporter); | 1026 test_gatherpixelrefs(reporter); |
1028 test_gatherpixelrefsandrects(reporter); | 1027 test_gatherpixelrefsandrects(reporter); |
1029 test_bitmap_with_encoded_data(reporter); | 1028 test_bitmap_with_encoded_data(reporter); |
1030 test_clone_empty(reporter); | 1029 test_clone_empty(reporter); |
1031 test_clip_bound_opt(reporter); | 1030 test_clip_bound_opt(reporter); |
1032 test_clip_expansion(reporter); | 1031 test_clip_expansion(reporter); |
1033 test_hierarchical(reporter); | 1032 test_hierarchical(reporter); |
1034 } | 1033 } |
OLD | NEW |