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

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

Issue 2349383002: remove dead code around SK_ENABLE_CLIP_QUICKREJECT (Closed)
Patch Set: also kill SK_SUPPORT_PRECHECK_CLIPRECT Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 #if SK_SUPPORT_GPU 44 #if SK_SUPPORT_GPU
45 #include "GrContext.h" 45 #include "GrContext.h"
46 #include "GrRenderTarget.h" 46 #include "GrRenderTarget.h"
47 #include "SkGrPriv.h" 47 #include "SkGrPriv.h"
48 48
49 #endif 49 #endif
50 50
51 #define RETURN_ON_NULL(ptr) do { if (nullptr == (ptr)) return; } while (0) 51 #define RETURN_ON_NULL(ptr) do { if (nullptr == (ptr)) return; } while (0)
52 52
53 //#define SK_SUPPORT_PRECHECK_CLIPRECT
54
55 /* 53 /*
56 * Return true if the drawing this rect would hit every pixels in the canvas. 54 * Return true if the drawing this rect would hit every pixels in the canvas.
57 * 55 *
58 * Returns false if 56 * Returns false if
59 * - rect does not contain the canvas' bounds 57 * - rect does not contain the canvas' bounds
60 * - paint is not fill 58 * - paint is not fill
61 * - paint would blur or otherwise change the coverage of the rect 59 * - paint would blur or otherwise change the coverage of the rect
62 */ 60 */
63 bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa int, 61 bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa int,
64 ShaderOverrideOpacity overrideOpacity ) const { 62 ShaderOverrideOpacity overrideOpacity ) const {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 114
117 static bool gTreatSpriteAsBitmap; 115 static bool gTreatSpriteAsBitmap;
118 void SkCanvas::Internal_Private_SetTreatSpriteAsBitmap(bool spriteAsBitmap) { 116 void SkCanvas::Internal_Private_SetTreatSpriteAsBitmap(bool spriteAsBitmap) {
119 gTreatSpriteAsBitmap = spriteAsBitmap; 117 gTreatSpriteAsBitmap = spriteAsBitmap;
120 } 118 }
121 bool SkCanvas::Internal_Private_GetTreatSpriteAsBitmap() { 119 bool SkCanvas::Internal_Private_GetTreatSpriteAsBitmap() {
122 return gTreatSpriteAsBitmap; 120 return gTreatSpriteAsBitmap;
123 } 121 }
124 122
125 // experimental for faster tiled drawing... 123 // experimental for faster tiled drawing...
126 //#define SK_ENABLE_CLIP_QUICKREJECT
127 //#define SK_TRACE_SAVERESTORE 124 //#define SK_TRACE_SAVERESTORE
128 125
129 #ifdef SK_TRACE_SAVERESTORE 126 #ifdef SK_TRACE_SAVERESTORE
130 static int gLayerCounter; 127 static int gLayerCounter;
131 static void inc_layer() { ++gLayerCounter; printf("----- inc layer %d\n", gL ayerCounter); } 128 static void inc_layer() { ++gLayerCounter; printf("----- inc layer %d\n", gL ayerCounter); }
132 static void dec_layer() { --gLayerCounter; printf("----- dec layer %d\n", gL ayerCounter); } 129 static void dec_layer() { --gLayerCounter; printf("----- dec layer %d\n", gL ayerCounter); }
133 130
134 static int gRecCounter; 131 static int gRecCounter;
135 static void inc_rec() { ++gRecCounter; printf("----- inc rec %d\n", gRecCoun ter); } 132 static void inc_rec() { ++gRecCounter; printf("----- inc rec %d\n", gRecCoun ter); }
136 static void dec_rec() { --gRecCounter; printf("----- dec rec %d\n", gRecCoun ter); } 133 static void dec_rec() { --gRecCounter; printf("----- dec rec %d\n", gRecCoun ter); }
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 } 1538 }
1542 #endif 1539 #endif
1543 1540
1544 ////////////////////////////////////////////////////////////////////////////// 1541 //////////////////////////////////////////////////////////////////////////////
1545 1542
1546 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) { 1543 void SkCanvas::clipRect(const SkRect& rect, SkRegion::Op op, bool doAA) {
1547 if (!fAllowSoftClip) { 1544 if (!fAllowSoftClip) {
1548 doAA = false; 1545 doAA = false;
1549 } 1546 }
1550 1547
1551 #ifdef SK_SUPPORT_PRECHECK_CLIPRECT
1552 // Check if we can quick-accept the clip call (and do nothing)
1553 //
1554 if (SkRegion::kIntersect_Op == op && !doAA && fMCRec->fMatrix.isScaleTransla te()) {
1555 SkRect devR;
1556 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect);
1557 // NOTE: this check is CTM specific, since we might round differently wi th a different
1558 // CTM. Thus this is only 100% reliable if there is not global CTM scale to be
1559 // applied later (i.e. if this is going into a picture).
1560 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) {
1561 #if 0
1562 SkDebugf("ignored clipRect [%g %g %g %g]\n",
1563 rect.left(), rect.top(), rect.right(), rect.bottom());
1564 #endif
1565 return;
1566 }
1567 }
1568 #endif
1569
1570 this->checkForDeferredSave(); 1548 this->checkForDeferredSave();
1571 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle; 1549 ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
1572 this->onClipRect(rect, op, edgeStyle); 1550 this->onClipRect(rect, op, edgeStyle);
1573 } 1551 }
1574 1552
1575 void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg eStyle) { 1553 void SkCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, ClipEdgeStyle edg eStyle) {
1576 #ifdef SK_ENABLE_CLIP_QUICKREJECT
1577 if (SkRegion::kIntersect_Op == op) {
1578 if (fMCRec->fRasterClip.isEmpty()) {
1579 return;
1580 }
1581
1582 if (this->quickReject(rect)) {
1583 fDeviceCMDirty = true;
1584 fCachedLocalClipBoundsDirty = true;
1585
1586 fClipStack->clipEmpty();
1587 (void)fMCRec->fRasterClip.setEmpty();
1588 fDeviceClipBounds.setEmpty();
1589 return;
1590 }
1591 }
1592 #endif
1593
1594 const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate(); 1554 const bool isScaleTrans = fMCRec->fMatrix.isScaleTranslate();
1595 SkRect devR; 1555 SkRect devR;
1596 if (isScaleTrans) { 1556 if (isScaleTrans) {
1597 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect); 1557 fMCRec->fMatrix.mapRectScaleTranslate(&devR, rect);
1598 } 1558 }
1599 1559
1600 #ifndef SK_SUPPORT_PRECHECK_CLIPRECT
1601 if (SkRegion::kIntersect_Op == op && 1560 if (SkRegion::kIntersect_Op == op &&
1602 kHard_ClipEdgeStyle == edgeStyle 1561 kHard_ClipEdgeStyle == edgeStyle
1603 && isScaleTrans) 1562 && isScaleTrans)
1604 { 1563 {
1605 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) { 1564 if (devR.round().contains(fMCRec->fRasterClip.getBounds())) {
1606 #if 0 1565 #if 0
1607 SkDebugf("------- ignored clipRect [%g %g %g %g]\n", 1566 SkDebugf("------- ignored clipRect [%g %g %g %g]\n",
1608 rect.left(), rect.top(), rect.right(), rect.bottom()); 1567 rect.left(), rect.top(), rect.right(), rect.bottom());
1609 #endif 1568 #endif
1610 return; 1569 return;
1611 } 1570 }
1612 } 1571 }
1613 #endif
1614 1572
1615 AutoValidateClip avc(this); 1573 AutoValidateClip avc(this);
1616 1574
1617 fDeviceCMDirty = true; 1575 fDeviceCMDirty = true;
1618 1576
1619 if (isScaleTrans) { 1577 if (isScaleTrans) {
1620 const bool isAA = kSoft_ClipEdgeStyle == edgeStyle; 1578 const bool isAA = kSoft_ClipEdgeStyle == edgeStyle;
1621 fClipStack->clipDevRect(devR, op, isAA); 1579 fClipStack->clipDevRect(devR, op, isAA);
1622 fMCRec->fRasterClip.op(devR, this->getTopLayerBounds(), op, isAA); 1580 fMCRec->fRasterClip.op(devR, this->getTopLayerBounds(), op, isAA);
1623 } else { 1581 } else {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 if (path.isRRect(&rrect)) { 1647 if (path.isRRect(&rrect)) {
1690 this->onClipRRect(rrect, op, edgeStyle); 1648 this->onClipRRect(rrect, op, edgeStyle);
1691 return; 1649 return;
1692 } 1650 }
1693 } 1651 }
1694 1652
1695 this->onClipPath(path, op, edgeStyle); 1653 this->onClipPath(path, op, edgeStyle);
1696 } 1654 }
1697 1655
1698 void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg eStyle) { 1656 void SkCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ClipEdgeStyle edg eStyle) {
1699 #ifdef SK_ENABLE_CLIP_QUICKREJECT
1700 if (SkRegion::kIntersect_Op == op && !path.isInverseFillType()) {
1701 if (fMCRec->fRasterClip.isEmpty()) {
1702 return;
1703 }
1704
1705 if (this->quickReject(path.getBounds())) {
1706 fDeviceCMDirty = true;
1707 fCachedLocalClipBoundsDirty = true;
1708
1709 fClipStack->clipEmpty();
1710 (void)fMCRec->fRasterClip.setEmpty();
1711 fDeviceClipBounds.setEmpty();
1712 return;
1713 }
1714 }
1715 #endif
1716
1717 AutoValidateClip avc(this); 1657 AutoValidateClip avc(this);
1718 1658
1719 fDeviceCMDirty = true; 1659 fDeviceCMDirty = true;
1720 if (!fAllowSoftClip) { 1660 if (!fAllowSoftClip) {
1721 edgeStyle = kHard_ClipEdgeStyle; 1661 edgeStyle = kHard_ClipEdgeStyle;
1722 } 1662 }
1723 1663
1724 SkPath devPath; 1664 SkPath devPath;
1725 if (fMCRec->fMatrix.isIdentity()) { 1665 if (fMCRec->fMatrix.isIdentity()) {
1726 devPath = path; 1666 devPath = path;
(...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
3504 3444
3505 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() { 3445 SkAutoCanvasMatrixPaint::~SkAutoCanvasMatrixPaint() {
3506 fCanvas->restoreToCount(fSaveCount); 3446 fCanvas->restoreToCount(fSaveCount);
3507 } 3447 }
3508 3448
3509 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API 3449 #ifdef SK_SUPPORT_LEGACY_NEW_SURFACE_API
3510 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) { 3450 SkSurface* SkCanvas::newSurface(const SkImageInfo& info, const SkSurfaceProps* p rops) {
3511 return this->makeSurface(info, props).release(); 3451 return this->makeSurface(info, props).release();
3512 } 3452 }
3513 #endif 3453 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698