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

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

Issue 340453003: Add getCurrentClipPath() to SkCanvas. Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: add SkCanvas::getCurrentClipPath() Created 6 years, 6 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') | 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 8
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkBitmapDevice.h" 10 #include "SkBitmapDevice.h"
(...skipping 1775 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 void SkCanvas::internal_private_getTotalClipAsPath(SkPath* path) const { 1786 void SkCanvas::internal_private_getTotalClipAsPath(SkPath* path) const {
1787 path->reset(); 1787 path->reset();
1788 1788
1789 const SkRegion& rgn = fMCRec->fRasterClip->forceGetBW(); 1789 const SkRegion& rgn = fMCRec->fRasterClip->forceGetBW();
1790 if (rgn.isEmpty()) { 1790 if (rgn.isEmpty()) {
1791 return; 1791 return;
1792 } 1792 }
1793 (void)rgn.getBoundaryPath(path); 1793 (void)rgn.getBoundaryPath(path);
1794 } 1794 }
1795 1795
1796 void SkCanvas::getCurrentClipPath(SkPath* path) const {
1797
1798 if (!path)
1799 return;
1800
1801 const SkClipStack* clipStack = getClipStack();
1802 SkClipStack::Iter iter(*clipStack, SkClipStack::Iter::kBottom_IterStart);
1803 const SkClipStack::Element* element;
1804
1805 SkPath totalClipPath;
1806 totalClipPath.setFillType(SkPath::kInverseEvenOdd_FillType);
1807
1808 while ((element = iter.next())) {
1809
1810 SkClipStack::Element::Type type = element->getType();
1811 SkPath clipPath;
1812 if (type != SkClipStack::Element::kEmpty_Type)
1813 element->asPath(&clipPath);
1814
1815 SkRegion::Op elementOp = element->getOp();
1816 if (elementOp == SkRegion::kReplace_Op)
1817 totalClipPath = clipPath;
1818 else
1819 Op(totalClipPath, clipPath, (SkPathOp)elementOp, &totalClipPath);
1820 }
1821
1822 *path = totalClipPath;
1823 }
1824
1796 GrRenderTarget* SkCanvas::internal_private_accessTopLayerRenderTarget() { 1825 GrRenderTarget* SkCanvas::internal_private_accessTopLayerRenderTarget() {
1797 SkBaseDevice* dev = this->getTopDevice(); 1826 SkBaseDevice* dev = this->getTopDevice();
1798 return dev ? dev->accessRenderTarget() : NULL; 1827 return dev ? dev->accessRenderTarget() : NULL;
1799 } 1828 }
1800 1829
1801 SkBaseDevice* SkCanvas::createLayerDevice(const SkImageInfo& info) { 1830 SkBaseDevice* SkCanvas::createLayerDevice(const SkImageInfo& info) {
1802 SkBaseDevice* device = this->getTopDevice(); 1831 SkBaseDevice* device = this->getTopDevice();
1803 return device ? device->createCompatibleDeviceForSaveLayer(info) : NULL; 1832 return device ? device->createCompatibleDeviceForSaveLayer(info) : NULL;
1804 } 1833 }
1805 1834
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
2588 if (!supported_for_raster_canvas(info)) { 2617 if (!supported_for_raster_canvas(info)) {
2589 return NULL; 2618 return NULL;
2590 } 2619 }
2591 2620
2592 SkBitmap bitmap; 2621 SkBitmap bitmap;
2593 if (!bitmap.installPixels(info, pixels, rowBytes)) { 2622 if (!bitmap.installPixels(info, pixels, rowBytes)) {
2594 return NULL; 2623 return NULL;
2595 } 2624 }
2596 return SkNEW_ARGS(SkCanvas, (bitmap)); 2625 return SkNEW_ARGS(SkCanvas, (bitmap));
2597 } 2626 }
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698