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

Side by Side Diff: include/core/SkCanvas.h

Issue 1550583002: remove unused SkAutoROCanvasPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 12 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 | « gm/xfermodes3.cpp ('k') | src/core/SkCanvas.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 2006 The Android Open Source Project 2 * Copyright 2006 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 #ifndef SkCanvas_DEFINED 8 #ifndef SkCanvas_DEFINED
9 #define SkCanvas_DEFINED 9 #define SkCanvas_DEFINED
10 10
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 fCanvas = NULL; 1547 fCanvas = NULL;
1548 } 1548 }
1549 } 1549 }
1550 1550
1551 private: 1551 private:
1552 SkCanvas* fCanvas; 1552 SkCanvas* fCanvas;
1553 int fSaveCount; 1553 int fSaveCount;
1554 }; 1554 };
1555 #define SkAutoCanvasRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoCanvasRestore) 1555 #define SkAutoCanvasRestore(...) SK_REQUIRE_LOCAL_VAR(SkAutoCanvasRestore)
1556 1556
1557 /**
1558 * If the caller wants read-only access to the pixels in a canvas, it can just
1559 * call canvas->peekPixels(), since that is the fastest way to "peek" at the
1560 * pixels on a raster-backed canvas.
1561 *
1562 * If the canvas has pixels, but they are not readily available to the CPU
1563 * (e.g. gpu-backed), then peekPixels() will fail, but readPixels() will
1564 * succeed (though be slower, since it will return a copy of the pixels).
1565 *
1566 * SkAutoROCanvasPixels encapsulates these two techniques, trying first to call
1567 * peekPixels() (for performance), but if that fails, calling readPixels() and
1568 * storing the copy locally.
1569 *
1570 * The caller must respect the restrictions associated with peekPixels(), since
1571 * that may have been called: The returned information is invalidated if...
1572 * - any API is called on the canvas (or its parent surface if present)
1573 * - the canvas goes out of scope
1574 */
1575 class SkAutoROCanvasPixels : SkNoncopyable {
1576 public:
1577 SkAutoROCanvasPixels(SkCanvas* canvas);
1578
1579 // returns NULL on failure
1580 const void* addr() const { return fAddr; }
1581
1582 // undefined if addr() == NULL
1583 size_t rowBytes() const { return fRowBytes; }
1584
1585 // undefined if addr() == NULL
1586 const SkImageInfo& info() const { return fInfo; }
1587
1588 // helper that, if returns true, installs the pixels into the bitmap. Note
1589 // that the bitmap may reference the address returned by peekPixels(), so
1590 // the caller must respect the restrictions associated with peekPixels().
1591 bool asROBitmap(SkBitmap*) const;
1592
1593 private:
1594 SkBitmap fBitmap; // used if peekPixels() fails
1595 const void* fAddr; // NULL on failure
1596 SkImageInfo fInfo;
1597 size_t fRowBytes;
1598 };
1599
1600 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS 1557 #ifdef SK_SUPPORT_LEGACY_SAVEFLAGS
1601 static inline SkCanvas::SaveFlags operator|(const SkCanvas::SaveFlags lhs, 1558 static inline SkCanvas::SaveFlags operator|(const SkCanvas::SaveFlags lhs,
1602 const SkCanvas::SaveFlags rhs) { 1559 const SkCanvas::SaveFlags rhs) {
1603 return static_cast<SkCanvas::SaveFlags>(static_cast<int>(lhs) | static_cast< int>(rhs)); 1560 return static_cast<SkCanvas::SaveFlags>(static_cast<int>(lhs) | static_cast< int>(rhs));
1604 } 1561 }
1605 1562
1606 static inline SkCanvas::SaveFlags& operator|=(SkCanvas::SaveFlags& lhs, 1563 static inline SkCanvas::SaveFlags& operator|=(SkCanvas::SaveFlags& lhs,
1607 const SkCanvas::SaveFlags rhs) { 1564 const SkCanvas::SaveFlags rhs) {
1608 lhs = lhs | rhs; 1565 lhs = lhs | rhs;
1609 return lhs; 1566 return lhs;
1610 } 1567 }
1611 #endif 1568 #endif
1612 1569
1613 class SkCanvasClipVisitor { 1570 class SkCanvasClipVisitor {
1614 public: 1571 public:
1615 virtual ~SkCanvasClipVisitor(); 1572 virtual ~SkCanvasClipVisitor();
1616 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; 1573 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0;
1617 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; 1574 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0;
1618 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; 1575 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0;
1619 }; 1576 };
1620 1577
1621 #endif 1578 #endif
OLDNEW
« no previous file with comments | « gm/xfermodes3.cpp ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698