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

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

Issue 1470563003: Revert[2] of "quick-accept clipRect calls" (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | tests/CanvasStateTest.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 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
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 "SkCanvasPriv.h" 10 #include "SkCanvasPriv.h"
(...skipping 1490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 if (this->quickReject(rect)) { 1501 if (this->quickReject(rect)) {
1502 fDeviceCMDirty = true; 1502 fDeviceCMDirty = true;
1503 fCachedLocalClipBoundsDirty = true; 1503 fCachedLocalClipBoundsDirty = true;
1504 1504
1505 fClipStack->clipEmpty(); 1505 fClipStack->clipEmpty();
1506 return fMCRec->fRasterClip.setEmpty(); 1506 return fMCRec->fRasterClip.setEmpty();
1507 } 1507 }
1508 } 1508 }
1509 #endif 1509 #endif
1510 1510
1511 if (!fAllowSoftClip) {
1512 edgeStyle = kHard_ClipEdgeStyle;
1513 }
1514
1515 const bool rectStaysRect = fMCRec->fMatrix.rectStaysRect();
1516 SkRect devR;
1517 if (rectStaysRect) {
1518 fMCRec->fMatrix.mapRect(&devR, rect);
1519 }
1520
1521 // Check if we can quick-accept the clip call (and do nothing)
1522 //
1523 // TODO: investigate if a (conservative) version of this could be done in :: clipRect,
1524 // so that subclasses (like PictureRecording) didn't see unnecessary c lips, which in turn
1525 // might allow lazy save/restores to eliminate entire save/restore blo cks.
1526 //
1527 if (SkRegion::kIntersect_Op == op &&
1528 kHard_ClipEdgeStyle == edgeStyle
1529 && rectStaysRect)
1530 {
1531 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) {
1532 #if 0
1533 SkDebugf("------- ignored clipRect [%g %g %g %g]\n",
1534 rect.left(), rect.top(), rect.right(), rect.bottom());
1535 #endif
1536 return;
1537 }
1538 }
1539
1511 AutoValidateClip avc(this); 1540 AutoValidateClip avc(this);
1512 1541
1513 fDeviceCMDirty = true; 1542 fDeviceCMDirty = true;
1514 fCachedLocalClipBoundsDirty = true; 1543 fCachedLocalClipBoundsDirty = true;
1515 if (!fAllowSoftClip) {
1516 edgeStyle = kHard_ClipEdgeStyle;
1517 }
1518 1544
1519 if (fMCRec->fMatrix.rectStaysRect()) { 1545 if (rectStaysRect) {
1520 // for these simpler matrices, we can stay a rect even after applying 1546 const bool isAA = kSoft_ClipEdgeStyle == edgeStyle;
1521 // the matrix. This means we don't have to a) make a path, and b) tell 1547 fClipStack->clipDevRect(devR, op, isAA);
1522 // the region code to scan-convert the path, only to discover that it 1548 fMCRec->fRasterClip.op(devR, this->getBaseLayerSize(), op, isAA);
1523 // is really just a rect.
1524 SkRect r;
1525
1526 fMCRec->fMatrix.mapRect(&r, rect);
1527 fClipStack->clipDevRect(r, op, kSoft_ClipEdgeStyle == edgeStyle);
1528 fMCRec->fRasterClip.op(r, this->getBaseLayerSize(), op, kSoft_ClipEdgeSt yle == edgeStyle);
1529 } else { 1549 } else {
1530 // since we're rotated or some such thing, we convert the rect to a path 1550 // since we're rotated or some such thing, we convert the rect to a path
1531 // and clip against that, since it can handle any matrix. However, to 1551 // and clip against that, since it can handle any matrix. However, to
1532 // avoid recursion in the case where we are subclassed (e.g. Pictures) 1552 // avoid recursion in the case where we are subclassed (e.g. Pictures)
1533 // we explicitly call "our" version of clipPath. 1553 // we explicitly call "our" version of clipPath.
1534 SkPath path; 1554 SkPath path;
1535 1555
1536 path.addRect(rect); 1556 path.addRect(rect);
1537 this->SkCanvas::onClipPath(path, op, edgeStyle); 1557 this->SkCanvas::onClipPath(path, op, edgeStyle);
1538 } 1558 }
(...skipping 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
2931 } 2951 }
2932 2952
2933 if (matrix) { 2953 if (matrix) {
2934 canvas->concat(*matrix); 2954 canvas->concat(*matrix);
2935 } 2955 }
2936 } 2956 }
2937 2957
2938 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 2958 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
2939 fCanvas->restoreToCount(fSaveCount); 2959 fCanvas->restoreToCount(fSaveCount);
2940 } 2960 }
OLDNEW
« no previous file with comments | « no previous file | tests/CanvasStateTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698