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

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

Issue 189883010: hide getTotalClip, so we can eventually remove it (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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
« no previous file with comments | « include/core/SkCanvas.h ('k') | src/utils/SkCanvasStateUtils.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 /* 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 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 fClipStack.clipDevRect(rgn.getBounds(), op); 1519 fClipStack.clipDevRect(rgn.getBounds(), op);
1520 1520
1521 fMCRec->fRasterClip->op(rgn, op); 1521 fMCRec->fRasterClip->op(rgn, op);
1522 } 1522 }
1523 1523
1524 #ifdef SK_DEBUG 1524 #ifdef SK_DEBUG
1525 void SkCanvas::validateClip() const { 1525 void SkCanvas::validateClip() const {
1526 // construct clipRgn from the clipstack 1526 // construct clipRgn from the clipstack
1527 const SkBaseDevice* device = this->getDevice(); 1527 const SkBaseDevice* device = this->getDevice();
1528 if (!device) { 1528 if (!device) {
1529 SkASSERT(this->getTotalClip().isEmpty()); 1529 SkASSERT(this->isClipEmpty());
1530 return; 1530 return;
1531 } 1531 }
1532 1532
1533 SkIRect ir; 1533 SkIRect ir;
1534 ir.set(0, 0, device->width(), device->height()); 1534 ir.set(0, 0, device->width(), device->height());
1535 SkRasterClip tmpClip(ir); 1535 SkRasterClip tmpClip(ir);
1536 1536
1537 SkClipStack::B2TIter iter(fClipStack); 1537 SkClipStack::B2TIter iter(fClipStack);
1538 const SkClipStack::Element* element; 1538 const SkClipStack::Element* element;
1539 while ((element = iter.next()) != NULL) { 1539 while ((element = iter.next()) != NULL) {
1540 switch (element->getType()) { 1540 switch (element->getType()) {
1541 case SkClipStack::Element::kRect_Type: 1541 case SkClipStack::Element::kRect_Type:
1542 element->getRect().round(&ir); 1542 element->getRect().round(&ir);
1543 tmpClip.op(ir, element->getOp()); 1543 tmpClip.op(ir, element->getOp());
1544 break; 1544 break;
1545 case SkClipStack::Element::kEmpty_Type: 1545 case SkClipStack::Element::kEmpty_Type:
1546 tmpClip.setEmpty(); 1546 tmpClip.setEmpty();
1547 break; 1547 break;
1548 default: { 1548 default: {
1549 SkPath path; 1549 SkPath path;
1550 element->asPath(&path); 1550 element->asPath(&path);
1551 clip_path_helper(this, &tmpClip, path, element->getOp(), element ->isAA()); 1551 clip_path_helper(this, &tmpClip, path, element->getOp(), element ->isAA());
1552 break; 1552 break;
1553 } 1553 }
1554 } 1554 }
1555 } 1555 }
1556
1557 #if 0 // enable this locally for testing
1558 // now compare against the current rgn
1559 const SkRegion& rgn = this->getTotalClip();
1560 SkASSERT(rgn == tmpClip);
1561 #endif
1562 } 1556 }
1563 #endif 1557 #endif
1564 1558
1565 void SkCanvas::replayClips(ClipVisitor* visitor) const { 1559 void SkCanvas::replayClips(ClipVisitor* visitor) const {
1566 SkClipStack::B2TIter iter(fClipStack); 1560 SkClipStack::B2TIter iter(fClipStack);
1567 const SkClipStack::Element* element; 1561 const SkClipStack::Element* element;
1568 1562
1569 static const SkRect kEmpty = { 0, 0, 0, 0 }; 1563 static const SkRect kEmpty = { 0, 0, 0, 0 };
1570 while ((element = iter.next()) != NULL) { 1564 while ((element = iter.next()) != NULL) {
1571 switch (element->getType()) { 1565 switch (element->getType()) {
(...skipping 12 matching lines...) Expand all
1584 } 1578 }
1585 } 1579 }
1586 } 1580 }
1587 1581
1588 /////////////////////////////////////////////////////////////////////////////// 1582 ///////////////////////////////////////////////////////////////////////////////
1589 1583
1590 bool SkCanvas::isClipEmpty() const { 1584 bool SkCanvas::isClipEmpty() const {
1591 return fMCRec->fRasterClip->isEmpty(); 1585 return fMCRec->fRasterClip->isEmpty();
1592 } 1586 }
1593 1587
1588 bool SkCanvas::isClipRect() const {
1589 return fMCRec->fRasterClip->isRect();
1590 }
1591
1594 bool SkCanvas::quickReject(const SkRect& rect) const { 1592 bool SkCanvas::quickReject(const SkRect& rect) const {
1595 1593
1596 if (!rect.isFinite()) 1594 if (!rect.isFinite())
1597 return true; 1595 return true;
1598 1596
1599 if (fMCRec->fRasterClip->isEmpty()) { 1597 if (fMCRec->fRasterClip->isEmpty()) {
1600 return true; 1598 return true;
1601 } 1599 }
1602 1600
1603 if (fMCRec->fMatrix->hasPerspective()) { 1601 if (fMCRec->fMatrix->hasPerspective()) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 if (NULL != bounds) { 1662 if (NULL != bounds) {
1665 *bounds = clip.getBounds(); 1663 *bounds = clip.getBounds();
1666 } 1664 }
1667 return true; 1665 return true;
1668 } 1666 }
1669 1667
1670 const SkMatrix& SkCanvas::getTotalMatrix() const { 1668 const SkMatrix& SkCanvas::getTotalMatrix() const {
1671 return *fMCRec->fMatrix; 1669 return *fMCRec->fMatrix;
1672 } 1670 }
1673 1671
1672 #ifdef SK_SUPPORT_LEGACY_GETCLIPTYPE
1674 SkCanvas::ClipType SkCanvas::getClipType() const { 1673 SkCanvas::ClipType SkCanvas::getClipType() const {
1675 if (fMCRec->fRasterClip->isEmpty()) { 1674 if (fMCRec->fRasterClip->isEmpty()) {
1676 return kEmpty_ClipType; 1675 return kEmpty_ClipType;
1677 } 1676 }
1678 if (fMCRec->fRasterClip->isRect()) { 1677 if (fMCRec->fRasterClip->isRect()) {
1679 return kRect_ClipType; 1678 return kRect_ClipType;
1680 } 1679 }
1681 return kComplex_ClipType; 1680 return kComplex_ClipType;
1682 } 1681 }
1682 #endif
1683 1683
1684 #ifdef SK_SUPPORT_LEGACY_GETTOTALCLIP
1684 const SkRegion& SkCanvas::getTotalClip() const { 1685 const SkRegion& SkCanvas::getTotalClip() const {
1685 return fMCRec->fRasterClip->forceGetBW(); 1686 return fMCRec->fRasterClip->forceGetBW();
1686 } 1687 }
1688 #endif
1689
1690 const SkRegion& SkCanvas::internal_private_getTotalClip() const {
1691 return fMCRec->fRasterClip->forceGetBW();
1692 }
1693
1694 void SkCanvas::internal_private_getTotalClipAsPath(SkPath* path) const {
1695 path->reset();
1696
1697 const SkRegion& rgn = fMCRec->fRasterClip->forceGetBW();
1698 if (rgn.isEmpty()) {
1699 return;
1700 }
1701 (void)rgn.getBoundaryPath(path);
1702 }
1687 1703
1688 SkBaseDevice* SkCanvas::createLayerDevice(const SkImageInfo& info) { 1704 SkBaseDevice* SkCanvas::createLayerDevice(const SkImageInfo& info) {
1689 SkBaseDevice* device = this->getTopDevice(); 1705 SkBaseDevice* device = this->getTopDevice();
1690 return device ? device->createCompatibleDeviceForSaveLayer(info) : NULL; 1706 return device ? device->createCompatibleDeviceForSaveLayer(info) : NULL;
1691 } 1707 }
1692 1708
1693 GrContext* SkCanvas::getGrContext() { 1709 GrContext* SkCanvas::getGrContext() {
1694 #if SK_SUPPORT_GPU 1710 #if SK_SUPPORT_GPU
1695 SkBaseDevice* device = this->getTopDevice(); 1711 SkBaseDevice* device = this->getTopDevice();
1696 if (NULL != device) { 1712 if (NULL != device) {
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
2435 if (!bitmap.allocPixels(info)) { 2451 if (!bitmap.allocPixels(info)) {
2436 return NULL; 2452 return NULL;
2437 } 2453 }
2438 2454
2439 // should this functionality be moved into allocPixels()? 2455 // should this functionality be moved into allocPixels()?
2440 if (!bitmap.info().isOpaque()) { 2456 if (!bitmap.info().isOpaque()) {
2441 bitmap.eraseColor(0); 2457 bitmap.eraseColor(0);
2442 } 2458 }
2443 return SkNEW_ARGS(SkCanvas, (bitmap)); 2459 return SkNEW_ARGS(SkCanvas, (bitmap));
2444 } 2460 }
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | src/utils/SkCanvasStateUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698