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

Side by Side Diff: src/core/SkCanvas.cpp

Issue 200923008: Fix cull nesting assertion. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Split validation method. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkCanvas.h ('k') | src/core/SkPictureRecord.cpp » ('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 /* 2 /*
3 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 1155
1156 void SkCanvas::onPushCull(const SkRect& cullRect) { 1156 void SkCanvas::onPushCull(const SkRect& cullRect) {
1157 // do nothing. Subclasses may do something 1157 // do nothing. Subclasses may do something
1158 } 1158 }
1159 1159
1160 void SkCanvas::onPopCull() { 1160 void SkCanvas::onPopCull() {
1161 // do nothing. Subclasses may do something 1161 // do nothing. Subclasses may do something
1162 } 1162 }
1163 1163
1164 ///////////////////////////////////////////////////////////////////////////// 1164 /////////////////////////////////////////////////////////////////////////////
1165 #ifdef SK_DEBUG
1166 // Ensure that cull rects are monotonically nested in device space.
1167 void SkCanvas::validateCull(const SkIRect& devCull) {
1168 if (fCullStack.isEmpty()
1169 || devCull.isEmpty()
1170 || fCullStack.top().contains(devCull)) {
1171 return;
1172 }
1173
1174 SkDEBUGF(("Invalid cull: [%d %d %d %d] (previous cull: [%d %d %d %d])\n",
1175 devCull.x(), devCull.y(), devCull.right(), devCull.bottom(),
1176 fCullStack.top().x(), fCullStack.top().y(),
1177 fCullStack.top().right(), fCullStack.top().bottom()));
1178
1179 #ifdef ASSERT_NESTED_CULLING
1180 SkDEBUGFAIL("Invalid cull.");
1181 #endif
1182 }
1183 #endif
1184
1185 void SkCanvas::pushCull(const SkRect& cullRect) {
1186 ++fCullCount;
1187 this->onPushCull(cullRect);
1188
1189 #ifdef SK_DEBUG
1190 // Map the cull rect into device space.
1191 SkRect mappedCull;
1192 this->getTotalMatrix().mapRect(&mappedCull, cullRect);
1193
1194 // Take clipping into account.
1195 SkIRect devClip, devCull;
1196 mappedCull.roundOut(&devCull);
1197 this->getClipDeviceBounds(&devClip);
1198 if (!devCull.intersect(devClip)) {
1199 devCull.setEmpty();
1200 }
1201
1202 this->validateCull(devCull);
1203 fCullStack.push(devCull); // balanced in popCull
1204 #endif
1205 }
1206
1207 void SkCanvas::popCull() {
1208 SkASSERT(fCullStack.count() == fCullCount);
1209
1210 if (fCullCount > 0) {
1211 --fCullCount;
1212 this->onPopCull();
1213
1214 SkDEBUGCODE(fCullStack.pop());
1215 }
1216 }
1217
1218 /////////////////////////////////////////////////////////////////////////////
1165 1219
1166 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap, 1220 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap,
1167 const SkMatrix& matrix, const SkPaint* paint) { 1221 const SkMatrix& matrix, const SkPaint* paint) {
1168 if (bitmap.drawsNothing()) { 1222 if (bitmap.drawsNothing()) {
1169 return; 1223 return;
1170 } 1224 }
1171 1225
1172 SkLazyPaint lazy; 1226 SkLazyPaint lazy;
1173 if (NULL == paint) { 1227 if (NULL == paint) {
1174 paint = lazy.init(); 1228 paint = lazy.init();
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 if (!bitmap.installPixels(info, pixels, rowBytes)) { 2674 if (!bitmap.installPixels(info, pixels, rowBytes)) {
2621 return NULL; 2675 return NULL;
2622 } 2676 }
2623 2677
2624 // should this functionality be moved into allocPixels()? 2678 // should this functionality be moved into allocPixels()?
2625 if (!bitmap.info().isOpaque()) { 2679 if (!bitmap.info().isOpaque()) {
2626 bitmap.eraseColor(0); 2680 bitmap.eraseColor(0);
2627 } 2681 }
2628 return SkNEW_ARGS(SkCanvas, (bitmap)); 2682 return SkNEW_ARGS(SkCanvas, (bitmap));
2629 } 2683 }
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | src/core/SkPictureRecord.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698