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

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: 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
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 properly nested in device space.
robertphillips 2014/03/20 12:23:56 I think this is a bad name since it conflates vali
f(malita) 2014/03/20 13:30:58 Renamed to validateAndTrack().
1167 void SkCanvas::validateCull(const SkRect& cull) {
1168 SkRect mappedCull;
1169 this->getTotalMatrix().mapRect(&mappedCull, cull);
1170
1171 // Take clipping into account.
1172 SkIRect devClip, devCull;
1173 this->getClipDeviceBounds(&devClip);
1174 mappedCull.roundOut(&devCull);
1175 if (!devCull.intersect(devClip))
robertphillips 2014/03/20 12:23:56 {} needed
f(malita) 2014/03/20 13:30:58 Done.
1176 devCull.setEmpty();
1177
1178 if (!fCullStack.isEmpty()
1179 && !devCull.isEmpty()
1180 && !fCullStack.top().contains(devCull)) {
1181 SkDEBUGF(("Invalid cull: [%d %d %d %d] (previous cull: [%d %d %d %d])\n" ,
1182 devCull.x(), devCull.y(), devCull.right(), devCull.bottom(),
1183 fCullStack.top().x(), fCullStack.top().y(),
1184 fCullStack.top().right(), fCullStack.top().bottom()));
1185
1186 #ifdef ASSERT_NESTED_CULLING
robertphillips 2014/03/20 12:23:56 This assert seems odd inside this code block.
f(malita) 2014/03/20 13:30:58 Hmm, the intention is to provide an easy way to se
1187 SkASSERT(fCullStack.top().contains(devCull));
1188 #endif
1189 }
1190
1191 fCullStack.push(devCull); // balanced in popCull
1192 }
1193 #endif
1194
1195 void SkCanvas::pushCull(const SkRect& cullRect) {
robertphillips 2014/03/20 12:23:56 this->
1196 SkDEBUGCODE(validateCull(cullRect));
1197
1198 ++fCullCount;
1199 this->onPushCull(cullRect);
1200 }
1201
1202 void SkCanvas::popCull() {
1203 SkASSERT(fCullStack.count() == fCullCount);
1204
1205 if (fCullCount > 0) {
1206 SkDEBUGCODE(fCullStack.pop());
1207 --fCullCount;
1208 this->onPopCull();
1209 }
1210 }
1211
1212 /////////////////////////////////////////////////////////////////////////////
1165 1213
1166 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap, 1214 void SkCanvas::internalDrawBitmap(const SkBitmap& bitmap,
1167 const SkMatrix& matrix, const SkPaint* paint) { 1215 const SkMatrix& matrix, const SkPaint* paint) {
1168 if (bitmap.drawsNothing()) { 1216 if (bitmap.drawsNothing()) {
1169 return; 1217 return;
1170 } 1218 }
1171 1219
1172 SkLazyPaint lazy; 1220 SkLazyPaint lazy;
1173 if (NULL == paint) { 1221 if (NULL == paint) {
1174 paint = lazy.init(); 1222 paint = lazy.init();
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 if (!bitmap.installPixels(info, pixels, rowBytes)) { 2668 if (!bitmap.installPixels(info, pixels, rowBytes)) {
2621 return NULL; 2669 return NULL;
2622 } 2670 }
2623 2671
2624 // should this functionality be moved into allocPixels()? 2672 // should this functionality be moved into allocPixels()?
2625 if (!bitmap.info().isOpaque()) { 2673 if (!bitmap.info().isOpaque()) {
2626 bitmap.eraseColor(0); 2674 bitmap.eraseColor(0);
2627 } 2675 }
2628 return SkNEW_ARGS(SkCanvas, (bitmap)); 2676 return SkNEW_ARGS(SkCanvas, (bitmap));
2629 } 2677 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698