OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
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 SkSpecialImage_DEFINED | 8 #ifndef SkSpecialImage_DEFINED |
9 #define SkSpecialImage_DEFINED | 9 #define SkSpecialImage_DEFINED |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 * Draw this SpecialImage into the canvas. | 66 * Draw this SpecialImage into the canvas. |
67 */ | 67 */ |
68 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; | 68 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) const; |
69 | 69 |
70 static sk_sp<SkSpecialImage> MakeFromImage(const SkIRect& subset, | 70 static sk_sp<SkSpecialImage> MakeFromImage(const SkIRect& subset, |
71 sk_sp<SkImage>, | 71 sk_sp<SkImage>, |
72 const SkSurfaceProps* = nullptr); | 72 const SkSurfaceProps* = nullptr); |
73 static sk_sp<SkSpecialImage> MakeFromRaster(const SkIRect& subset, | 73 static sk_sp<SkSpecialImage> MakeFromRaster(const SkIRect& subset, |
74 const SkBitmap&, | 74 const SkBitmap&, |
75 const SkSurfaceProps* = nullptr)
; | 75 const SkSurfaceProps* = nullptr)
; |
| 76 #if SK_SUPPORT_GPU |
76 static sk_sp<SkSpecialImage> MakeFromGpu(const SkIRect& subset, | 77 static sk_sp<SkSpecialImage> MakeFromGpu(const SkIRect& subset, |
77 uint32_t uniqueID, | 78 uint32_t uniqueID, |
78 GrTexture*, | 79 sk_sp<GrTexture>, |
79 const SkSurfaceProps* = nullptr, | 80 const SkSurfaceProps* = nullptr, |
80 SkAlphaType at = kPremul_SkAlphaTyp
e); | 81 SkAlphaType at = kPremul_SkAlphaTyp
e); |
| 82 #endif |
81 static sk_sp<SkSpecialImage> MakeFromPixmap(const SkIRect& subset, | 83 static sk_sp<SkSpecialImage> MakeFromPixmap(const SkIRect& subset, |
82 const SkPixmap&, | 84 const SkPixmap&, |
83 RasterReleaseProc, | 85 RasterReleaseProc, |
84 ReleaseContext, | 86 ReleaseContext, |
85 const SkSurfaceProps* = nullptr)
; | 87 const SkSurfaceProps* = nullptr)
; |
86 | 88 |
87 /** | 89 /** |
88 * Create a new special surface with a backend that is compatible with this
special image. | 90 * Create a new special surface with a backend that is compatible with this
special image. |
89 */ | 91 */ |
90 sk_sp<SkSpecialSurface> makeSurface(const SkImageInfo&) const; | 92 sk_sp<SkSpecialSurface> makeSurface(const SkImageInfo&) const; |
(...skipping 25 matching lines...) Expand all Loading... |
116 /** | 118 /** |
117 * If the SpecialImage is backed by a gpu texture, return true. | 119 * If the SpecialImage is backed by a gpu texture, return true. |
118 */ | 120 */ |
119 bool isTextureBacked() const; | 121 bool isTextureBacked() const; |
120 | 122 |
121 /** | 123 /** |
122 * Return the GrContext if the SkSpecialImage is GrTexture-backed | 124 * Return the GrContext if the SkSpecialImage is GrTexture-backed |
123 */ | 125 */ |
124 GrContext* getContext() const; | 126 GrContext* getContext() const; |
125 | 127 |
| 128 #if SK_SUPPORT_GPU |
126 /** | 129 /** |
127 * Regardless of the underlying backing store, return the contents as a GrT
exture. | 130 * Regardless of the underlying backing store, return the contents as a GrT
exture. |
128 * The active portion of the texture can be retrieved via 'subset'. | 131 * The active portion of the texture can be retrieved via 'subset'. |
129 */ | 132 */ |
130 GrTexture* asTextureRef(GrContext*) const; | 133 sk_sp<GrTexture> asTextureRef(GrContext*) const; |
| 134 #endif |
131 | 135 |
132 // TODO: hide this whe the imagefilter all have a consistent draw path (see
skbug.com/5063) | 136 // TODO: hide this whe the imagefilter all have a consistent draw path (see
skbug.com/5063) |
133 /** | 137 /** |
134 * Regardless of the underlying backing store, return the contents as an Sk
Bitmap | 138 * Regardless of the underlying backing store, return the contents as an Sk
Bitmap |
135 * | 139 * |
136 * The returned ImageInfo represents the backing memory. Use 'subset' | 140 * The returned ImageInfo represents the backing memory. Use 'subset' |
137 * to get the active portion's dimensions. | 141 * to get the active portion's dimensions. |
138 */ | 142 */ |
139 bool getROPixels(SkBitmap*) const; | 143 bool getROPixels(SkBitmap*) const; |
140 | 144 |
141 protected: | 145 protected: |
142 SkSpecialImage(const SkIRect& subset, uint32_t uniqueID, const SkSurfaceProp
s*); | 146 SkSpecialImage(const SkIRect& subset, uint32_t uniqueID, const SkSurfaceProp
s*); |
143 | 147 |
144 private: | 148 private: |
145 const SkSurfaceProps fProps; | 149 const SkSurfaceProps fProps; |
146 const SkIRect fSubset; | 150 const SkIRect fSubset; |
147 const uint32_t fUniqueID; | 151 const uint32_t fUniqueID; |
148 | 152 |
149 typedef SkRefCnt INHERITED; | 153 typedef SkRefCnt INHERITED; |
150 }; | 154 }; |
151 | 155 |
152 #endif | 156 #endif |
OLD | NEW |