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

Side by Side Diff: tests/PictureTest.cpp

Issue 1178673007: Allow reset of the SkPictureRecorder cull rect before endRecording. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Removed bbhFactory Created 5 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/SkPictureRecorder.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 #include "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 canvas->clipPath(path2, SkRegion::kXOR_Op); 977 canvas->clipPath(path2, SkRegion::kXOR_Op);
978 bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds); 978 bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
979 REPORTER_ASSERT(reporter, true == nonEmpty); 979 REPORTER_ASSERT(reporter, true == nonEmpty);
980 REPORTER_ASSERT(reporter, 6 == clipBounds.fLeft); 980 REPORTER_ASSERT(reporter, 6 == clipBounds.fLeft);
981 REPORTER_ASSERT(reporter, 6 == clipBounds.fTop); 981 REPORTER_ASSERT(reporter, 6 == clipBounds.fTop);
982 REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom); 982 REPORTER_ASSERT(reporter, 8 == clipBounds.fBottom);
983 REPORTER_ASSERT(reporter, 8 == clipBounds.fRight); 983 REPORTER_ASSERT(reporter, 8 == clipBounds.fRight);
984 } 984 }
985 } 985 }
986 986
987 static void test_cull_rect_reset(skiatest::Reporter* reporter) {
988 SkPictureRecorder recorder;
989 SkRect bounds = SkRect::MakeWH(10, 10);
990 SkRTreeFactory factory;
991 SkCanvas* canvas = recorder.beginRecording(bounds, &factory);
992 bounds = SkRect::MakeWH(100, 100);
993 SkPaint paint;
994 canvas->drawRect(bounds, paint);
995 canvas->drawRect(bounds, paint);
996 const SkBigPicture* picture = recorder.endRecordingAsPicture(bounds)->asSkBi gPicture();
997 REPORTER_ASSERT(reporter, picture);
998
999 SkRect finalCullRect = picture->cullRect();
1000 REPORTER_ASSERT(reporter, 0 == finalCullRect.fLeft);
1001 REPORTER_ASSERT(reporter, 0 == finalCullRect.fTop);
1002 REPORTER_ASSERT(reporter, 100 == finalCullRect.fBottom);
1003 REPORTER_ASSERT(reporter, 100 == finalCullRect.fRight);
1004
1005 const SkBBoxHierarchy* pictureBBH = picture->bbh();
1006 SkRect bbhCullRect = pictureBBH->getRootBound();
1007 REPORTER_ASSERT(reporter, 0 == bbhCullRect.fLeft);
1008 REPORTER_ASSERT(reporter, 0 == bbhCullRect.fTop);
1009 REPORTER_ASSERT(reporter, 100 == bbhCullRect.fBottom);
1010 REPORTER_ASSERT(reporter, 100 == bbhCullRect.fRight);
1011 }
1012
1013
987 /** 1014 /**
988 * A canvas that records the number of clip commands. 1015 * A canvas that records the number of clip commands.
989 */ 1016 */
990 class ClipCountingCanvas : public SkCanvas { 1017 class ClipCountingCanvas : public SkCanvas {
991 public: 1018 public:
992 ClipCountingCanvas(int width, int height) 1019 ClipCountingCanvas(int width, int height)
993 : INHERITED(width, height) 1020 : INHERITED(width, height)
994 , fClipCount(0){ 1021 , fClipCount(0){
995 } 1022 }
996 1023
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 test_gpu_veto(reporter); 1149 test_gpu_veto(reporter);
1123 #endif 1150 #endif
1124 test_has_text(reporter); 1151 test_has_text(reporter);
1125 test_analysis(reporter); 1152 test_analysis(reporter);
1126 test_bitmap_with_encoded_data(reporter); 1153 test_bitmap_with_encoded_data(reporter);
1127 test_clip_bound_opt(reporter); 1154 test_clip_bound_opt(reporter);
1128 test_clip_expansion(reporter); 1155 test_clip_expansion(reporter);
1129 test_hierarchical(reporter); 1156 test_hierarchical(reporter);
1130 test_gen_id(reporter); 1157 test_gen_id(reporter);
1131 test_savelayer_extraction(reporter); 1158 test_savelayer_extraction(reporter);
1159 test_cull_rect_reset(reporter);
1132 } 1160 }
1133 1161
1134 static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) { 1162 static void draw_bitmaps(const SkBitmap bitmap, SkCanvas* canvas) {
1135 const SkPaint paint; 1163 const SkPaint paint;
1136 const SkRect rect = { 5.0f, 5.0f, 8.0f, 8.0f }; 1164 const SkRect rect = { 5.0f, 5.0f, 8.0f, 8.0f };
1137 const SkIRect irect = { 2, 2, 3, 3 }; 1165 const SkIRect irect = { 2, 2, 3, 3 };
1138 1166
1139 // Don't care what these record, as long as they're legal. 1167 // Don't care what these record, as long as they're legal.
1140 canvas->drawBitmap(bitmap, 0.0f, 0.0f, &paint); 1168 canvas->drawBitmap(bitmap, 0.0f, 0.0f, &paint);
1141 canvas->drawBitmapRectToRect(bitmap, &rect, rect, &paint, SkCanvas::kNone_Dr awBitmapRectFlag); 1169 canvas->drawBitmapRectToRect(bitmap, &rect, rect, &paint, SkCanvas::kNone_Dr awBitmapRectFlag);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 1334
1307 DEF_TEST(MiniRecorderLeftHanging, r) { 1335 DEF_TEST(MiniRecorderLeftHanging, r) {
1308 // Any shader or other ref-counted effect will do just fine here. 1336 // Any shader or other ref-counted effect will do just fine here.
1309 SkPaint paint; 1337 SkPaint paint;
1310 paint.setShader(SkShader::CreateColorShader(SK_ColorRED))->unref(); 1338 paint.setShader(SkShader::CreateColorShader(SK_ColorRED))->unref();
1311 1339
1312 SkMiniRecorder rec; 1340 SkMiniRecorder rec;
1313 REPORTER_ASSERT(r, rec.drawRect(SkRect::MakeWH(20,30), paint)); 1341 REPORTER_ASSERT(r, rec.drawRect(SkRect::MakeWH(20,30), paint));
1314 // Don't call rec.detachPicture(). Test succeeds by not asserting or leakin g the shader. 1342 // Don't call rec.detachPicture(). Test succeeds by not asserting or leakin g the shader.
1315 } 1343 }
OLDNEW
« no previous file with comments | « src/core/SkPictureRecorder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698