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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
317 */ | 318 */ |
318 SkImage* newSubset(const SkIRect& subset) const; | 319 SkImage* newSubset(const SkIRect& subset) const; |
319 | 320 |
320 /** | 321 /** |
321 * Ensures that an image is backed by a texture (when GrContext is non-null ). If no | 322 * Ensures that an image is backed by a texture (when GrContext is non-null ). If no |
322 * transformation is required, the returned image may be the same as this i mage. If the this | 323 * transformation is required, the returned image may be the same as this i mage. If the this |
323 * image is from a different GrContext, this will fail. | 324 * image is from a different GrContext, this will fail. |
324 */ | 325 */ |
325 SkImage* newTextureImage(GrContext*) const; | 326 SkImage* newTextureImage(GrContext*) const; |
326 | 327 |
328 /** Drawing params for which a deferred texture image data should be optimiz ed. */ | |
329 struct DeferredTextureImageUsageParams { | |
330 SkMatrix fMatrix; | |
331 SkFilterQuality fQuality; | |
332 }; | |
333 | |
334 /** | |
335 * This method allows clients to capture the data necessary to turn a SkImag e into a texture- | |
336 * backed image. If the original image is codec-backed this will decode into a format optimized | |
337 * for the context represented by the proxy. This method is thread safe with respect to the | |
338 * GrContext whence the proxy came. Clients allocate and manage the storage of the deferred | |
339 * texture data and control its lifetime. No cleanup is required, thus it is safe to simply free | |
340 * the memory out from under the data. | |
341 * | |
342 * The same method is used both for getting the size necessary for pre-uploa ded texture data | |
343 * and for retrieving the data. The params array represents the set of draws over which to | |
344 * optimize the pre-upload data. | |
345 * | |
346 * When called with a null buffer this returns the size that the client must allocate in order | |
347 * to create deferred texture data for this image (or zero if this is an ina ppropriate | |
348 * candidate). The buffer allocated by the client should be 8 byte aligned. | |
349 * | |
350 * When buffer is not null this fills in the deferred texture data for this image in the | |
351 * provided buffer (assuming this is an appropriate candidate image and the buffer is | |
352 * appropriately aligned). Upon success the size written is returned, otherw ise 0. | |
353 */ | |
354 size_t getDeferredTextureImageData(const GrContextThreadSafeProxy&, | |
355 const DeferredTextureImageUsageParams[], | |
356 int paramCnt, | |
357 void* buffer) const; | |
358 | |
359 /** | |
360 * Returns a texture-backed image from data produced in SkImage::getDeferred TextureImageData. | |
361 * The context must be the context that provided the proxy passed to | |
reed1
2016/03/10 21:34:12
btw -- can you assert that, by storing the GrCotne
bsalomon
2016/03/10 21:37:46
I don't assert but I do check it by storing the Gr
| |
362 * getDeferredTextureImageData. | |
363 */ | |
364 static SkImage* NewFromDeferredTextureImageData(GrContext*, const void*, SkB udgeted); | |
365 | |
327 // Helper functions to convert to SkBitmap | 366 // Helper functions to convert to SkBitmap |
328 | 367 |
329 enum LegacyBitmapMode { | 368 enum LegacyBitmapMode { |
330 kRO_LegacyBitmapMode, | 369 kRO_LegacyBitmapMode, |
331 kRW_LegacyBitmapMode, | 370 kRW_LegacyBitmapMode, |
332 }; | 371 }; |
333 | 372 |
334 /** | 373 /** |
335 * Attempt to create a bitmap with the same pixels as the image. The result will always be | 374 * Attempt to create a bitmap with the same pixels as the image. The result will always be |
336 * a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not s upported here). | 375 * a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not s upported here). |
(...skipping 16 matching lines...) Expand all Loading... | |
353 | 392 |
354 private: | 393 private: |
355 const int fWidth; | 394 const int fWidth; |
356 const int fHeight; | 395 const int fHeight; |
357 const uint32_t fUniqueID; | 396 const uint32_t fUniqueID; |
358 | 397 |
359 typedef SkRefCnt INHERITED; | 398 typedef SkRefCnt INHERITED; |
360 }; | 399 }; |
361 | 400 |
362 #endif | 401 #endif |
OLD | NEW |