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

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

Issue 12545009: Adding option in SkPicture to record device-space bounds of draw commands. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 SkDevice* SkCanvas::init(SkDevice* device) { 507 SkDevice* SkCanvas::init(SkDevice* device) {
508 fBounder = NULL; 508 fBounder = NULL;
509 fLocalBoundsCompareType.setEmpty(); 509 fLocalBoundsCompareType.setEmpty();
510 fLocalBoundsCompareTypeDirty = true; 510 fLocalBoundsCompareTypeDirty = true;
511 fAllowSoftClip = true; 511 fAllowSoftClip = true;
512 fAllowSimplifyClip = false; 512 fAllowSimplifyClip = false;
513 fDeviceCMDirty = false; 513 fDeviceCMDirty = false;
514 fSaveLayerCount = 0; 514 fSaveLayerCount = 0;
515 fMetaData = NULL; 515 fMetaData = NULL;
516 fQuickRejectEnabled = true;
516 517
517 fMCRec = (MCRec*)fMCStack.push_back(); 518 fMCRec = (MCRec*)fMCStack.push_back();
518 new (fMCRec) MCRec(NULL, 0); 519 new (fMCRec) MCRec(NULL, 0);
519 520
520 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL)); 521 fMCRec->fLayer = SkNEW_ARGS(DeviceCM, (NULL, 0, 0, NULL, NULL));
521 fMCRec->fTopLayer = fMCRec->fLayer; 522 fMCRec->fTopLayer = fMCRec->fLayer;
522 fMCRec->fNext = NULL; 523 fMCRec->fNext = NULL;
523 524
524 fSurfaceBase = NULL; 525 fSurfaceBase = NULL;
525 526
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 fLocalBoundsCompareType.setEmpty(); 1364 fLocalBoundsCompareType.setEmpty();
1364 } else { 1365 } else {
1365 fLocalBoundsCompareType.set(SkScalarToCompareType(r.fLeft), 1366 fLocalBoundsCompareType.set(SkScalarToCompareType(r.fLeft),
1366 SkScalarToCompareType(r.fTop), 1367 SkScalarToCompareType(r.fTop),
1367 SkScalarToCompareType(r.fRight), 1368 SkScalarToCompareType(r.fRight),
1368 SkScalarToCompareType(r.fBottom)); 1369 SkScalarToCompareType(r.fBottom));
1369 } 1370 }
1370 } 1371 }
1371 1372
1372 bool SkCanvas::quickReject(const SkRect& rect) const { 1373 bool SkCanvas::quickReject(const SkRect& rect) const {
1374 if (fQuickRejectEnabled) {
1375 if (!rect.isFinite())
1376 return true;
1373 1377
1374 if (!rect.isFinite()) 1378 if (fMCRec->fRasterClip->isEmpty()) {
1375 return true;
1376
1377 if (fMCRec->fRasterClip->isEmpty()) {
1378 return true;
1379 }
1380
1381 if (fMCRec->fMatrix->hasPerspective()) {
1382 SkRect dst;
1383 fMCRec->fMatrix->mapRect(&dst, rect);
1384 SkIRect idst;
1385 dst.roundOut(&idst);
1386 return !SkIRect::Intersects(idst, fMCRec->fRasterClip->getBounds());
1387 } else {
1388 const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType();
1389
1390 // for speed, do the most likely reject compares first
1391 SkScalarCompareType userT = SkScalarToCompareType(rect.fTop);
1392 SkScalarCompareType userB = SkScalarToCompareType(rect.fBottom);
1393 if (userT >= clipR.fBottom || userB <= clipR.fTop) {
1394 return true; 1379 return true;
1395 } 1380 }
1396 SkScalarCompareType userL = SkScalarToCompareType(rect.fLeft); 1381
1397 SkScalarCompareType userR = SkScalarToCompareType(rect.fRight); 1382 if (fMCRec->fMatrix->hasPerspective()) {
1398 if (userL >= clipR.fRight || userR <= clipR.fLeft) { 1383 SkRect dst;
1399 return true; 1384 fMCRec->fMatrix->mapRect(&dst, rect);
1385 SkIRect idst;
1386 dst.roundOut(&idst);
1387 return !SkIRect::Intersects(idst, fMCRec->fRasterClip->getBounds());
1388 } else {
1389 const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType ();
1390
1391 // for speed, do the most likely reject compares first
1392 SkScalarCompareType userT = SkScalarToCompareType(rect.fTop);
1393 SkScalarCompareType userB = SkScalarToCompareType(rect.fBottom);
1394 if (userT >= clipR.fBottom || userB <= clipR.fTop) {
1395 return true;
1396 }
1397 SkScalarCompareType userL = SkScalarToCompareType(rect.fLeft);
1398 SkScalarCompareType userR = SkScalarToCompareType(rect.fRight);
1399 if (userL >= clipR.fRight || userR <= clipR.fLeft) {
1400 return true;
1401 }
1402 return false;
1400 } 1403 }
1404 } else {
1405 #ifdef SK_DEBUG
reed1 2013/05/14 13:31:11 Hmmm, not sure we always want to assert this. Seem
1406 // Validate that the decision to skip the test is well founded by
1407 // verifying that the test would have returned false.
1408 SkCanvas* nonConstThis = const_cast<SkCanvas*>(this);
1409 nonConstThis->fQuickRejectEnabled = true;
1410 SkASSERT(false == quickReject(rect));
1411 nonConstThis->fQuickRejectEnabled = false;
1412 #endif
1401 return false; 1413 return false;
1402 } 1414 }
1403 } 1415 }
1404 1416
1405 bool SkCanvas::quickReject(const SkPath& path) const { 1417 bool SkCanvas::quickReject(const SkPath& path) const {
1406 return path.isEmpty() || this->quickReject(path.getBounds()); 1418 return path.isEmpty() || this->quickReject(path.getBounds());
1407 } 1419 }
1408 1420
1409 static inline int pinIntForScalar(int x) { 1421 static inline int pinIntForScalar(int x) {
1410 #ifdef SK_SCALAR_IS_FIXED 1422 #ifdef SK_SCALAR_IS_FIXED
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 return *paint; 2183 return *paint;
2172 } 2184 }
2173 2185
2174 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); } 2186 const SkRegion& SkCanvas::LayerIter::clip() const { return fImpl->getClip(); }
2175 int SkCanvas::LayerIter::x() const { return fImpl->getX(); } 2187 int SkCanvas::LayerIter::x() const { return fImpl->getX(); }
2176 int SkCanvas::LayerIter::y() const { return fImpl->getY(); } 2188 int SkCanvas::LayerIter::y() const { return fImpl->getY(); }
2177 2189
2178 /////////////////////////////////////////////////////////////////////////////// 2190 ///////////////////////////////////////////////////////////////////////////////
2179 2191
2180 SkCanvas::ClipVisitor::~ClipVisitor() { } 2192 SkCanvas::ClipVisitor::~ClipVisitor() { }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698