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

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

Issue 2137853002: change mapRectScaleTranslate to pass args/ret by value (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 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
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 (int)kNotOpaque_ShaderOverrideOpacity, 68 (int)kNotOpaque_ShaderOverrideOpacity,
69 "need_matching_enums2"); 69 "need_matching_enums2");
70 70
71 const SkISize size = this->getBaseLayerSize(); 71 const SkISize size = this->getBaseLayerSize();
72 const SkRect bounds = SkRect::MakeIWH(size.width(), size.height()); 72 const SkRect bounds = SkRect::MakeIWH(size.width(), size.height());
73 if (!this->getClipStack()->quickContains(bounds)) { 73 if (!this->getClipStack()->quickContains(bounds)) {
74 return false; 74 return false;
75 } 75 }
76 76
77 if (rect) { 77 if (rect) {
78 if (!this->getTotalMatrix().isScaleTranslate()) { 78 const SkMatrix& ctm = this->getTotalMatrix();
79 if (!ctm.isScaleTranslate()) {
79 return false; // conservative 80 return false; // conservative
80 } 81 }
81 82 if (!ctm.mapRectScaleTranslate(*rect).contains(bounds)) {
82 SkRect devRect;
83 this->getTotalMatrix().mapRectScaleTranslate(&devRect, *rect);
84 if (!devRect.contains(bounds)) {
85 return false; 83 return false;
86 } 84 }
87 } 85 }
88 86
89 if (paint) { 87 if (paint) {
90 SkPaint::Style paintStyle = paint->getStyle(); 88 SkPaint::Style paintStyle = paint->getStyle();
91 if (!(paintStyle == SkPaint::kFill_Style || 89 if (!(paintStyle == SkPaint::kFill_Style ||
92 paintStyle == SkPaint::kStrokeAndFill_Style)) { 90 paintStyle == SkPaint::kStrokeAndFill_Style)) {
93 return false; 91 return false;
94 } 92 }
(...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 1535
1538 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { 1536 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
1539 if (!fAllowSoftClip) { 1537 if (!fAllowSoftClip) {
1540 doAA = false; 1538 doAA = false;
1541 } 1539 }
1542 1540
1543 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT 1541 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT
1544 // Check if we can quick-accept the clip call (and do nothing) 1542 // Check if we can quick-accept the clip call (and do nothing)
1545 // 1543 //
1546 if (SkRegion::kIntersect_Op == op && !doAA && fMCRec->fMatrix.isScaleTransla te()) { 1544 if (SkRegion::kIntersect_Op == op && !doAA && fMCRec->fMatrix.isScaleTransla te()) {
1547 SkRect devR; 1545 SkRect devR = fMCRec->fMatrix.mapRectScaleTranslate(rect);
1548 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect);
1549 // NOTE: this check is CTM specific, since we might round differently wi th a different 1546 // NOTE: this check is CTM specific, since we might round differently wi th a different
1550 // CTM. Thus this is only 100% reliable if there is not global CTM scale to be 1547 // CTM. Thus this is only 100% reliable if there is not global CTM scale to be
1551 // applied later (i.e. if this is going into a picture). 1548 // applied later (i.e. if this is going into a picture).
1552 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { 1549 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) {
1553 #if 0 1550 #if 0
1554 SkDebugf("ignored clipRect [%g %g %g %g]\n", 1551 SkDebugf("ignored clipRect [%g %g %g %g]\n",
1555 rect.left(), rect.top(), rect.right(), rect.bottom()); 1552 rect.left(), rect.top(), rect.right(), rect.bottom());
1556 #endif 1553 #endif
1557 return; 1554 return;
1558 } 1555 }
(...skipping 19 matching lines...) Expand all
1578 fClipStack->clipEmpty(); 1575 fClipStack->clipEmpty();
1579 (void)fMCRec->fRasterClip.setEmpty(); 1576 (void)fMCRec->fRasterClip.setEmpty();
1580 return; 1577 return;
1581 } 1578 }
1582 } 1579 }
1583 #endif 1580 #endif
1584 1581
1585 const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate(); 1582 const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate();
1586 SkRect devR; 1583 SkRect devR;
1587 if (isScaleTrans) { 1584 if (isScaleTrans) {
1588 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect); 1585 devR = fMCRec->fMatrix.mapRectScaleTranslate(rect);
1589 } 1586 }
1590 1587
1591 #ifndef SK_SUPPORT_PRECHECK_CLIPRECT 1588 #ifndef SK_SUPPORT_PRECHECK_CLIPRECT
1592 if (SkRegion::kIntersect_Op == op && 1589 if (SkRegion::kIntersect_Op == op &&
1593 kHard_ClipEdgeStyle == edgeStyle 1590 kHard_ClipEdgeStyle == edgeStyle
1594 && isScaleTrans) 1591 && isScaleTrans)
1595 { 1592 {
1596 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { 1593 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) {
1597 #if 0 1594 #if 0
1598 SkDebugf("------- ignored clipRect [%g %g %g %g]\n", 1595 SkDebugf("------- ignored clipRect [%g %g %g %g]\n",
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after
3122 3119
3123 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3120 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3124 fCanvas->restoreToCount(fSaveCount); 3121 fCanvas->restoreToCount(fSaveCount);
3125 } 3122 }
3126 3123
3127 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API 3124 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API
3128 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { 3125 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) {
3129 return this->makeSurface(info, props).release(); 3126 return this->makeSurface(info, props).release();
3130 } 3127 }
3131 #endif 3128 #endif
OLDNEW
« no previous file with comments | « include/core/SkMatrix.h ('k') | src/core/SkMatrix.cpp » ('j') | src/core/SkMatrix.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698