| 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 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 * its pixel memory is shareable, it may be shared instead of copied. | 66 * its pixel memory is shareable, it may be shared instead of copied. |
| 67 */ | 67 */ |
| 68 static sk_sp<SkImage> MakeFromBitmap(const SkBitmap&); | 68 static sk_sp<SkImage> MakeFromBitmap(const SkBitmap&); |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * Construct a new SkImage based on the given ImageGenerator. Returns NULL
on error. | 71 * Construct a new SkImage based on the given ImageGenerator. Returns NULL
on error. |
| 72 * This function will always take ownership of the passed generator. | 72 * This function will always take ownership of the passed generator. |
| 73 * | 73 * |
| 74 * If a subset is specified, it must be contained within the generator's bo
unds. | 74 * If a subset is specified, it must be contained within the generator's bo
unds. |
| 75 */ | 75 */ |
| 76 static sk_sp<SkImage> MakeFromGenerator(SkImageGenerator*, const SkIRect* su
bset = NULL); | 76 static sk_sp<SkImage> MakeFromGenerator(SkImageGenerator*, const SkIRect* su
bset = nullptr); |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Construct a new SkImage based on the specified encoded data. Returns NUL
L on failure, | 79 * Construct a new SkImage based on the specified encoded data. Returns NUL
L on failure, |
| 80 * which can mean that the format of the encoded data was not recognized/su
pported. | 80 * which can mean that the format of the encoded data was not recognized/su
pported. |
| 81 * | 81 * |
| 82 * If a subset is specified, it must be contained within the encoded data's
bounds. | 82 * If a subset is specified, it must be contained within the encoded data's
bounds. |
| 83 */ | 83 */ |
| 84 static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect*
subset = NULL); | 84 static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect*
subset = nullptr); |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * Create a new image from the specified descriptor. Note - the caller is r
esponsible for | 87 * Create a new image from the specified descriptor. Note - the caller is r
esponsible for |
| 88 * managing the lifetime of the underlying platform texture. | 88 * managing the lifetime of the underlying platform texture. |
| 89 * | 89 * |
| 90 * Will return NULL if the specified descriptor is unsupported. | 90 * Will return NULL if the specified descriptor is unsupported. |
| 91 */ | 91 */ |
| 92 static sk_sp<SkImage> MakeFromTexture(GrContext* ctx, const GrBackendTexture
Desc& desc) { | 92 static sk_sp<SkImage> MakeFromTexture(GrContext* ctx, const GrBackendTexture
Desc& desc) { |
| 93 return MakeFromTexture(ctx, desc, kPremul_SkAlphaType, NULL, NULL); | 93 return MakeFromTexture(ctx, desc, kPremul_SkAlphaType, nullptr, nullptr,
nullptr); |
| 94 } | 94 } |
| 95 | 95 |
| 96 static sk_sp<SkImage> MakeFromTexture(GrContext* ctx, const GrBackendTexture
Desc& de, | 96 static sk_sp<SkImage> MakeFromTexture(GrContext* ctx, const GrBackendTexture
Desc& de, |
| 97 SkAlphaType at) { | 97 SkAlphaType at) { |
| 98 return MakeFromTexture(ctx, de, at, NULL, NULL); | 98 return MakeFromTexture(ctx, de, at, nullptr, nullptr, nullptr); |
| 99 } | 99 } |
| 100 | 100 |
| 101 typedef void (*TextureReleaseProc)(ReleaseContext); | 101 typedef void (*TextureReleaseProc)(ReleaseContext); |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * Create a new image from the specified descriptor. The underlying platfor
m texture must stay | 104 * Create a new image from the specified descriptor. The underlying platfor
m texture must stay |
| 105 * valid and unaltered until the specified release-proc is invoked, indicat
ing that Skia | 105 * valid and unaltered until the specified release-proc is invoked, indicat
ing that Skia |
| 106 * no longer is holding a reference to it. | 106 * no longer is holding a reference to it. |
| 107 * | 107 * |
| 108 * Will return NULL if the specified descriptor is unsupported. | 108 * Will return NULL if the specified descriptor is unsupported. |
| 109 */ | 109 */ |
| 110 static sk_sp<SkImage> MakeFromTexture(GrContext* ctx, const GrBackendTexture
Desc& desc, |
| 111 SkAlphaType at, TextureReleaseProc trp
, |
| 112 ReleaseContext rc) { |
| 113 return MakeFromTexture(ctx, desc, at, nullptr, trp, rc); |
| 114 } |
| 115 |
| 116 /** |
| 117 * Create a new image from the specified descriptor. The underlying platform
texture must stay |
| 118 * valid and unaltered until the specified release-proc is invoked, indicati
ng that Skia |
| 119 * no longer is holding a reference to it. |
| 120 * |
| 121 * Will return NULL if the specified descriptor is unsupported. |
| 122 */ |
| 110 static sk_sp<SkImage> MakeFromTexture(GrContext*, const GrBackendTextureDesc
&, SkAlphaType, | 123 static sk_sp<SkImage> MakeFromTexture(GrContext*, const GrBackendTextureDesc
&, SkAlphaType, |
| 111 TextureReleaseProc, ReleaseContext); | 124 sk_sp<SkColorSpace>, TextureReleasePro
c, ReleaseContext); |
| 112 | 125 |
| 113 /** | 126 /** |
| 114 * Create a new image from the specified descriptor. Note - Skia will delet
e or recycle the | 127 * Create a new image from the specified descriptor. Note - Skia will delet
e or recycle the |
| 115 * texture when the image is released. | 128 * texture when the image is released. |
| 116 * | 129 * |
| 117 * Will return NULL if the specified descriptor is unsupported. | 130 * Will return NULL if the specified descriptor is unsupported. |
| 118 */ | 131 */ |
| 119 static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext*, const GrBackendText
ureDesc&, | 132 static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext*, const GrBackendText
ureDesc&, |
| 120 SkAlphaType = kPremul_SkAlphaTy
pe); | 133 SkAlphaType = kPremul_SkAlphaTy
pe, |
| 134 sk_sp<SkColorSpace> = nullptr); |
| 121 | 135 |
| 122 /** | 136 /** |
| 123 * Create a new image by copying the pixels from the specified y, u, v text
ures. The data | 137 * Create a new image by copying the pixels from the specified y, u, v text
ures. The data |
| 124 * from the textures is immediately ingested into the image and the texture
s can be modified or | 138 * from the textures is immediately ingested into the image and the texture
s can be modified or |
| 125 * 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. |
| 126 */ | 140 */ |
| 127 static sk_sp<SkImage> MakeFromYUVTexturesCopy(GrContext*, SkYUVColorSpace, | 141 static sk_sp<SkImage> MakeFromYUVTexturesCopy(GrContext*, SkYUVColorSpace, |
| 128 const GrBackendObject yuvTextu
reHandles[3], | 142 const GrBackendObject yuvTextu
reHandles[3], |
| 129 const SkISize yuvSizes[3], | 143 const SkISize yuvSizes[3], |
| 130 GrSurfaceOrigin); | 144 GrSurfaceOrigin, |
| 145 sk_sp<SkColorSpace> = nullptr)
; |
| 131 | 146 |
| 132 /** | 147 /** |
| 133 * Create a new image by copying the pixels from the specified y and uv tex
tures. The data | 148 * Create a new image by copying the pixels from the specified y and uv tex
tures. The data |
| 134 * from the textures is immediately ingested into the image and the texture
s can be modified or | 149 * from the textures is immediately ingested into the image and the texture
s can be modified or |
| 135 * deleted after the function returns. The image will have the dimensions o
f the y texture. | 150 * deleted after the function returns. The image will have the dimensions o
f the y texture. |
| 136 */ | 151 */ |
| 137 static sk_sp<SkImage> MakeFromNV12TexturesCopy(GrContext*, SkYUVColorSpace, | 152 static sk_sp<SkImage> MakeFromNV12TexturesCopy(GrContext*, SkYUVColorSpace, |
| 138 const GrBackendObject nv12Tex
tureHandles[2], | 153 const GrBackendObject nv12Tex
tureHandles[2], |
| 139 const SkISize nv12Sizes[2], G
rSurfaceOrigin); | 154 const SkISize nv12Sizes[2], G
rSurfaceOrigin, |
| 155 sk_sp<SkColorSpace> = nullptr
); |
| 140 | 156 |
| 141 static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture>, const SkISize& dimen
sions, | 157 static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture>, const SkISize& dimen
sions, |
| 142 const SkMatrix*, const SkPaint*); | 158 const SkMatrix*, const SkPaint*); |
| 143 | 159 |
| 144 static sk_sp<SkImage> MakeTextureFromPixmap(GrContext*, const SkPixmap&, SkB
udgeted budgeted); | 160 static sk_sp<SkImage> MakeTextureFromPixmap(GrContext*, const SkPixmap&, SkB
udgeted budgeted); |
| 145 | 161 |
| 146 ////////////////////////////////////////////////////////////////////////////
/////////////////// | 162 ////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 147 | 163 |
| 148 int width() const { return fWidth; } | 164 int width() const { return fWidth; } |
| 149 int height() const { return fHeight; } | 165 int height() const { return fHeight; } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 bool isLazyGenerated() const; | 430 bool isLazyGenerated() const; |
| 415 | 431 |
| 416 | 432 |
| 417 #ifdef SK_SUPPORT_LEGACY_IMAGEFACTORY | 433 #ifdef SK_SUPPORT_LEGACY_IMAGEFACTORY |
| 418 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt
es, | 434 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt
es, |
| 419 SkColorTable* ctable = nullptr); | 435 SkColorTable* ctable = nullptr); |
| 420 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); | 436 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); |
| 421 static SkImage* NewFromRaster(const Info&, const void* pixels, size_t rowByt
es, | 437 static SkImage* NewFromRaster(const Info&, const void* pixels, size_t rowByt
es, |
| 422 RasterReleaseProc, ReleaseContext); | 438 RasterReleaseProc, ReleaseContext); |
| 423 static SkImage* NewFromBitmap(const SkBitmap&); | 439 static SkImage* NewFromBitmap(const SkBitmap&); |
| 424 static SkImage* NewFromGenerator(SkImageGenerator*, const SkIRect* subset =
NULL); | 440 static SkImage* NewFromGenerator(SkImageGenerator*, const SkIRect* subset =
nullptr); |
| 425 static SkImage* NewFromEncoded(SkData* encoded, const SkIRect* subset = NULL
); | 441 static SkImage* NewFromEncoded(SkData* encoded, const SkIRect* subset = null
ptr); |
| 426 static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& d
esc) { | 442 static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& d
esc) { |
| 427 return NewFromTexture(ctx, desc, kPremul_SkAlphaType, NULL, NULL); | 443 return NewFromTexture(ctx, desc, kPremul_SkAlphaType, nullptr, nullptr); |
| 428 } | 444 } |
| 429 | 445 |
| 430 static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& d
e, SkAlphaType at) { | 446 static SkImage* NewFromTexture(GrContext* ctx, const GrBackendTextureDesc& d
e, SkAlphaType at) { |
| 431 return NewFromTexture(ctx, de, at, NULL, NULL); | 447 return NewFromTexture(ctx, de, at, nullptr, nullptr); |
| 432 } | 448 } |
| 433 static SkImage* NewFromTexture(GrContext*, const GrBackendTextureDesc&, SkAl
phaType, | 449 static SkImage* NewFromTexture(GrContext*, const GrBackendTextureDesc&, SkAl
phaType, |
| 434 TextureReleaseProc, ReleaseContext); | 450 TextureReleaseProc, ReleaseContext); |
| 435 static SkImage* NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc
&, | 451 static SkImage* NewFromAdoptedTexture(GrContext*, const GrBackendTextureDesc
&, |
| 436 SkAlphaType = kPremul_SkAlphaType); | 452 SkAlphaType = kPremul_SkAlphaType); |
| 437 static SkImage* NewFromYUVTexturesCopy(GrContext*, SkYUVColorSpace, | 453 static SkImage* NewFromYUVTexturesCopy(GrContext*, SkYUVColorSpace, |
| 438 const GrBackendObject yuvTextureHandl
es[3], | 454 const GrBackendObject yuvTextureHandl
es[3], |
| 439 const SkISize yuvSizes[3], | 455 const SkISize yuvSizes[3], |
| 440 GrSurfaceOrigin); | 456 GrSurfaceOrigin); |
| 441 static SkImage* NewFromPicture(const SkPicture*, const SkISize& dimensions, | 457 static SkImage* NewFromPicture(const SkPicture*, const SkISize& dimensions, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 456 SkBudgeted); | 472 SkBudgeted); |
| 457 | 473 |
| 458 const int fWidth; | 474 const int fWidth; |
| 459 const int fHeight; | 475 const int fHeight; |
| 460 const uint32_t fUniqueID; | 476 const uint32_t fUniqueID; |
| 461 | 477 |
| 462 typedef SkRefCnt INHERITED; | 478 typedef SkRefCnt INHERITED; |
| 463 }; | 479 }; |
| 464 | 480 |
| 465 #endif | 481 #endif |
| OLD | NEW |