OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkImage_DEFINED | 8 #ifndef SkImage_DEFINED |
9 #define SkImage_DEFINED | 9 #define SkImage_DEFINED |
10 | 10 |
11 #include "SkFilterQuality.h" | 11 #include "SkFilterQuality.h" |
12 #include "SkImageInfo.h" | 12 #include "SkImageInfo.h" |
13 #include "SkImageEncoder.h" | 13 #include "SkImageEncoder.h" |
14 #include "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
15 #include "SkScalar.h" | 15 #include "SkScalar.h" |
16 #include "SkShader.h" | 16 #include "SkShader.h" |
17 | 17 |
18 class SkData; | 18 class SkData; |
19 class SkCanvas; | 19 class SkCanvas; |
20 class SkColorTable; | 20 class SkColorTable; |
21 class SkImageGenerator; | 21 class SkImageGenerator; |
22 class SkPaint; | 22 class SkPaint; |
23 class SkPicture; | 23 class SkPicture; |
24 class SkPixelSerializer; | 24 class SkPixelSerializer; |
25 class SkString; | 25 class SkString; |
26 class SkSurface; | 26 class SkSurface; |
27 class GrContext; | 27 class GrContext; |
28 class GrContextThreadSafeProxy; | |
28 class GrTexture; | 29 class GrTexture; |
29 | 30 |
30 /** | 31 /** |
31 * SkImage is an abstraction for drawing a rectagle of pixels, though the | 32 * SkImage is an abstraction for drawing a rectagle of pixels, though the |
32 * particular type of image could be actually storing its data on the GPU, or | 33 * particular type of image could be actually storing its data on the GPU, or |
33 * as drawing commands (picture or PDF or otherwise), ready to be played back | 34 * as drawing commands (picture or PDF or otherwise), ready to be played back |
34 * into another canvas. | 35 * into another canvas. |
35 * | 36 * |
36 * The content of SkImage is always immutable, though the actual storage may | 37 * The content of SkImage is always immutable, though the actual storage may |
37 * change, if for example that image can be re-created via encoded data or | 38 * change, if for example that image can be re-created via encoded data or |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 * deleted after the function returns. The image will have the dimensions o f the y texture. | 139 * deleted after the function returns. The image will have the dimensions o f the y texture. |
139 */ | 140 */ |
140 static SkImage* NewFromYUVTexturesCopy(GrContext*, SkYUVColorSpace, | 141 static SkImage* NewFromYUVTexturesCopy(GrContext*, SkYUVColorSpace, |
141 const GrBackendObject yuvTextureHandl es[3], | 142 const GrBackendObject yuvTextureHandl es[3], |
142 const SkISize yuvSizes[3], | 143 const SkISize yuvSizes[3], |
143 GrSurfaceOrigin); | 144 GrSurfaceOrigin); |
144 | 145 |
145 static SkImage* NewFromPicture(const SkPicture*, const SkISize& dimensions, | 146 static SkImage* NewFromPicture(const SkPicture*, const SkISize& dimensions, |
146 const SkMatrix*, const SkPaint*); | 147 const SkMatrix*, const SkPaint*); |
147 | 148 |
149 static SkImage* NewTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted budgeted); | |
150 | |
148 //////////////////////////////////////////////////////////////////////////// /////////////////// | 151 //////////////////////////////////////////////////////////////////////////// /////////////////// |
149 | 152 |
150 int width() const { return fWidth; } | 153 int width() const { return fWidth; } |
151 int height() const { return fHeight; } | 154 int height() const { return fHeight; } |
152 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); } | 155 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); } |
153 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); } | 156 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); } |
154 uint32_t uniqueID() const { return fUniqueID; } | 157 uint32_t uniqueID() const { return fUniqueID; } |
155 virtual bool isOpaque() const { return false; } | 158 virtual bool isOpaque() const { return false; } |
156 | 159 |
157 /** | 160 /** |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 */ | 310 */ |
308 SkImage* newSubset(const SkIRect& subset) const; | 311 SkImage* newSubset(const SkIRect& subset) const; |
309 | 312 |
310 /** | 313 /** |
311 * Ensures that an image is backed by a texture (when GrContext is non-null ). If no | 314 * Ensures that an image is backed by a texture (when GrContext is non-null ). If no |
312 * transformation is required, the returned image may be the same as this i mage. If the this | 315 * transformation is required, the returned image may be the same as this i mage. If the this |
313 * image is from a different GrContext, this will fail. | 316 * image is from a different GrContext, this will fail. |
314 */ | 317 */ |
315 SkImage* newTextureImage(GrContext*) const; | 318 SkImage* newTextureImage(GrContext*) const; |
316 | 319 |
320 /** | |
321 * This captures the data necessary to turn a SkImage into a texture-backed image. If the image | |
322 * is codec-backed decoding into the format desired to create a texture-back ed image is | |
323 * performed. Constructing one of these does not make calls to the underlyin g 3D API | |
robertphillips
2016/03/08 18:43:10
the of - the ?
bsalomon
2016/03/08 19:49:31
Done.
| |
324 * (e.g. OpenGL). Clients allocate and manage the of storage for the Deferre dTextureImage and | |
325 * control its lifetime. No cleanup is required, thus it is safe to simply f ree the memory | |
326 * associated with a DeferredTextureImage. | |
327 */ | |
328 class DeferredTextureImage; | |
329 | |
330 /** Drawing params for which a DeferredTextureImage should be optimized. */ | |
331 struct DeferredTextureImageUsageParams { | |
332 SkMatrix fViewMatrix; | |
333 SkFilterQuality fQuality; | |
334 SkRect fSrcRect; | |
335 SkRect fDstRect; | |
336 }; | |
337 | |
robertphillips
2016/03/08 18:43:10
Are their any constraints on the proxy we hand to
bsalomon
2016/03/08 19:49:31
Added comment that the size of the buffer must be
| |
338 /** | |
339 * Computes the size that the client must allocate in order to create a Defe rredTextureImage | |
robertphillips
2016/03/08 18:43:10
tee -> te ?
bsalomon
2016/03/08 19:49:31
Done.
| |
340 * for this image (or zero if this is an inappropriatee candidate for a Defe rredTextureImage). | |
341 */ | |
342 size_t getDeferredTextureImageSize(const GrContextThreadSafeProxy&, | |
robertphillips
2016/03/08 18:43:10
Why an array of usage parameters?
bsalomon
2016/03/08 19:49:31
The client may have multiple draws with the same i
| |
343 const DeferredTextureImageUsageParams[], | |
344 int paramCnt) const; | |
345 | |
346 /** | |
347 * Creates a DeferredTextureImage for this image (or returns nullptr if this is an inappropriate | |
348 * candidate for a DeferredTextureImage or the provided buffer is too small) . | |
349 */ | |
350 const DeferredTextureImage* createDeferredTextureImageInClientStorage( | |
351 const GrContextThreadSafeProxy&, | |
352 const DeferredTextureImageUsageParams[], | |
353 int paramCnt, | |
354 void* imageTextureDataBuffer, | |
355 size_t imageTextureDataBufferSize) const; | |
356 | |
357 static SkImage* NewFromDeferredTextureImage(GrContext*, const DeferredTextur eImage&, | |
358 SkBudgeted); | |
359 | |
317 // Helper functions to convert to SkBitmap | 360 // Helper functions to convert to SkBitmap |
318 | 361 |
319 enum LegacyBitmapMode { | 362 enum LegacyBitmapMode { |
320 kRO_LegacyBitmapMode, | 363 kRO_LegacyBitmapMode, |
321 kRW_LegacyBitmapMode, | 364 kRW_LegacyBitmapMode, |
322 }; | 365 }; |
323 | 366 |
324 /** | 367 /** |
325 * Attempt to create a bitmap with the same pixels as the image. The result will always be | 368 * Attempt to create a bitmap with the same pixels as the image. The result will always be |
326 * a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not s upported here). | 369 * a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not s upported here). |
(...skipping 16 matching lines...) Expand all Loading... | |
343 | 386 |
344 private: | 387 private: |
345 const int fWidth; | 388 const int fWidth; |
346 const int fHeight; | 389 const int fHeight; |
347 const uint32_t fUniqueID; | 390 const uint32_t fUniqueID; |
348 | 391 |
349 typedef SkRefCnt INHERITED; | 392 typedef SkRefCnt INHERITED; |
350 }; | 393 }; |
351 | 394 |
352 #endif | 395 #endif |
OLD | NEW |