Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkDeque.h" | 13 #include "SkDeque.h" |
| 14 #include "SkImage.h" | 14 #include "SkImage.h" |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 #include "SkRasterCanvasLayerAllocator.h" | |
| 16 #include "SkRefCnt.h" | 17 #include "SkRefCnt.h" |
| 17 #include "SkRegion.h" | 18 #include "SkRegion.h" |
| 18 #include "SkSurfaceProps.h" | 19 #include "SkSurfaceProps.h" |
| 19 #include "SkXfermode.h" | 20 #include "SkXfermode.h" |
| 20 #include "SkLights.h" | 21 #include "SkLights.h" |
| 21 #include "../private/SkShadowParams.h" | 22 #include "../private/SkShadowParams.h" |
| 22 | 23 |
| 23 class GrContext; | 24 class GrContext; |
| 24 class GrDrawContext; | 25 class GrDrawContext; |
| 25 class SkBaseDevice; | 26 class SkBaseDevice; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 @param device Specifies a device for the canvas to draw into. | 102 @param device Specifies a device for the canvas to draw into. |
| 102 */ | 103 */ |
| 103 explicit SkCanvas(SkBaseDevice* device); | 104 explicit SkCanvas(SkBaseDevice* device); |
| 104 | 105 |
| 105 /** Construct a canvas with the specified bitmap to draw into. | 106 /** Construct a canvas with the specified bitmap to draw into. |
| 106 @param bitmap Specifies a bitmap for the canvas to draw into. Its | 107 @param bitmap Specifies a bitmap for the canvas to draw into. Its |
| 107 structure are copied to the canvas. | 108 structure are copied to the canvas. |
| 108 */ | 109 */ |
| 109 explicit SkCanvas(const SkBitmap& bitmap); | 110 explicit SkCanvas(const SkBitmap& bitmap); |
| 110 | 111 |
| 112 SkCanvas(const SkBitmap& bitmap, SkRasterCanvasLayerAllocator*); | |
| 113 | |
| 111 /** Construct a canvas with the specified bitmap to draw into. | 114 /** Construct a canvas with the specified bitmap to draw into. |
| 112 @param bitmap Specifies a bitmap for the canvas to draw into. Its | 115 @param bitmap Specifies a bitmap for the canvas to draw into. Its |
| 113 structure are copied to the canvas. | 116 structure are copied to the canvas. |
| 114 @param props New canvas surface properties. | 117 @param props New canvas surface properties. |
| 115 */ | 118 */ |
| 116 SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props); | 119 SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props); |
| 117 | 120 |
| 118 virtual ~SkCanvas(); | 121 virtual ~SkCanvas(); |
| 119 | 122 |
| 120 SkMetaData& getMetaData(); | 123 SkMetaData& getMetaData(); |
| 121 | 124 |
| 122 /** | 125 /** |
| 123 * Return ImageInfo for this canvas. If the canvas is not backed by pixels | 126 * Return ImageInfo for this canvas. If the canvas is not backed by pixels |
| 124 * (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType. | 127 * (cpu or gpu), then the info's ColorType will be kUnknown_SkColorType. |
| 125 */ | 128 */ |
| 126 SkImageInfo imageInfo() const; | 129 SkImageInfo imageInfo() const; |
| 127 | 130 |
| 128 /** | 131 /** |
| 129 * If the canvas is backed by pixels (cpu or gpu), this writes a copy of th e SurfaceProps | 132 * If the canvas is backed by pixels (cpu or gpu), this writes a copy of th e SurfaceProps |
| 130 * for the canvas to the location supplied by the caller, and returns true. Otherwise, | 133 * for the canvas to the location supplied by the caller, and returns true. Otherwise, |
| 131 * return false and leave the supplied props unchanged. | 134 * return false and leave the supplied props unchanged. |
| 132 */ | 135 */ |
| 133 bool getProps(SkSurfaceProps*) const; | 136 bool getProps(SkSurfaceProps*) const; |
| 134 | 137 |
| 138 SkRasterCanvasLayerAllocator* getLayerAllocator() const { return fLayerAlloc ator.get(); } | |
| 139 | |
| 135 /////////////////////////////////////////////////////////////////////////// | 140 /////////////////////////////////////////////////////////////////////////// |
| 136 | 141 |
| 137 /** | 142 /** |
| 138 * Trigger the immediate execution of all pending draw operations. For the GPU | 143 * Trigger the immediate execution of all pending draw operations. For the GPU |
| 139 * backend this will resolve all rendering to the GPU surface backing the | 144 * backend this will resolve all rendering to the GPU surface backing the |
| 140 * SkSurface that owns this canvas. | 145 * SkSurface that owns this canvas. |
| 141 */ | 146 */ |
| 142 void flush(); | 147 void flush(); |
| 143 | 148 |
| 144 /** | 149 /** |
| (...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1682 private: | 1687 private: |
| 1683 const SkCanvas* fCanvas; | 1688 const SkCanvas* fCanvas; |
| 1684 }; | 1689 }; |
| 1685 | 1690 |
| 1686 #ifdef SK_DEBUG | 1691 #ifdef SK_DEBUG |
| 1687 void validateClip() const; | 1692 void validateClip() const; |
| 1688 #else | 1693 #else |
| 1689 void validateClip() const {} | 1694 void validateClip() const {} |
| 1690 #endif | 1695 #endif |
| 1691 | 1696 |
| 1697 std::unique_ptr<SkRasterCanvasLayerAllocator> fLayerAllocator; | |
|
reed1
2016/09/16 13:15:00
Why is the type SkRefCnt, but we have a unique_ptr
tomhudson
2016/09/28 21:23:57
Done.
| |
| 1698 | |
| 1692 typedef SkRefCnt INHERITED; | 1699 typedef SkRefCnt INHERITED; |
| 1693 }; | 1700 }; |
| 1694 | 1701 |
| 1695 /** Stack helper class to automatically call restoreToCount() on the canvas | 1702 /** Stack helper class to automatically call restoreToCount() on the canvas |
| 1696 when this object goes out of scope. Use this to guarantee that the canvas | 1703 when this object goes out of scope. Use this to guarantee that the canvas |
| 1697 is restored to a known state. | 1704 is restored to a known state. |
| 1698 */ | 1705 */ |
| 1699 class SkAutoCanvasRestore : SkNoncopyable { | 1706 class SkAutoCanvasRestore : SkNoncopyable { |
| 1700 public: | 1707 public: |
| 1701 SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas), fSaveC ount(0) { | 1708 SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas), fSaveC ount(0) { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1731 | 1738 |
| 1732 class SkCanvasClipVisitor { | 1739 class SkCanvasClipVisitor { |
| 1733 public: | 1740 public: |
| 1734 virtual ~SkCanvasClipVisitor(); | 1741 virtual ~SkCanvasClipVisitor(); |
| 1735 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; | 1742 virtual void clipRect(const SkRect&, SkRegion::Op, bool antialias) = 0; |
| 1736 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; | 1743 virtual void clipRRect(const SkRRect&, SkRegion::Op, bool antialias) = 0; |
| 1737 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; | 1744 virtual void clipPath(const SkPath&, SkRegion::Op, bool antialias) = 0; |
| 1738 }; | 1745 }; |
| 1739 | 1746 |
| 1740 #endif | 1747 #endif |
| OLD | NEW |