| 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 #define SK_SUPPORT_LEGACY_IMAGEFACTORY | 31 #define SK_SUPPORT_LEGACY_IMAGEFACTORY |
| 31 | 32 |
| 32 /** | 33 /** |
| 33 * SkImage is an abstraction for drawing a rectagle of pixels, though the | 34 * SkImage is an abstraction for drawing a rectagle of pixels, though the |
| 34 * particular type of image could be actually storing its data on the GPU, or | 35 * particular type of image could be actually storing its data on the GPU, or |
| 35 * as drawing commands (picture or PDF or otherwise), ready to be played back | 36 * as drawing commands (picture or PDF or otherwise), ready to be played back |
| 36 * into another canvas. | 37 * into another canvas. |
| 37 * | 38 * |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 */ | 315 */ |
| 315 sk_sp<SkImage> makeSubset(const SkIRect& subset) const; | 316 sk_sp<SkImage> makeSubset(const SkIRect& subset) const; |
| 316 | 317 |
| 317 /** | 318 /** |
| 318 * Ensures that an image is backed by a texture (when GrContext is non-null
). If no | 319 * Ensures that an image is backed by a texture (when GrContext is non-null
). If no |
| 319 * transformation is required, the returned image may be the same as this i
mage. If the this | 320 * transformation is required, the returned image may be the same as this i
mage. If the this |
| 320 * image is from a different GrContext, this will fail. | 321 * image is from a different GrContext, this will fail. |
| 321 */ | 322 */ |
| 322 sk_sp<SkImage> makeTextureImage(GrContext*) const; | 323 sk_sp<SkImage> makeTextureImage(GrContext*) const; |
| 323 | 324 |
| 325 /** Drawing params for which a deferred texture image data should be optimiz
ed. */ |
| 326 struct DeferredTextureImageUsageParams { |
| 327 SkMatrix fMatrix; |
| 328 SkFilterQuality fQuality; |
| 329 }; |
| 330 |
| 331 /** |
| 332 * This method allows clients to capture the data necessary to turn a SkImag
e into a texture- |
| 333 * backed image. If the original image is codec-backed this will decode into
a format optimized |
| 334 * for the context represented by the proxy. This method is thread safe with
respect to the |
| 335 * GrContext whence the proxy came. Clients allocate and manage the storage
of the deferred |
| 336 * texture data and control its lifetime. No cleanup is required, thus it is
safe to simply free |
| 337 * the memory out from under the data. |
| 338 * |
| 339 * The same method is used both for getting the size necessary for pre-uploa
ded texture data |
| 340 * and for retrieving the data. The params array represents the set of draws
over which to |
| 341 * optimize the pre-upload data. |
| 342 * |
| 343 * When called with a null buffer this returns the size that the client must
allocate in order |
| 344 * to create deferred texture data for this image (or zero if this is an ina
ppropriate |
| 345 * candidate). The buffer allocated by the client should be 8 byte aligned. |
| 346 * |
| 347 * When buffer is not null this fills in the deferred texture data for this
image in the |
| 348 * provided buffer (assuming this is an appropriate candidate image and the
buffer is |
| 349 * appropriately aligned). Upon success the size written is returned, otherw
ise 0. |
| 350 */ |
| 351 size_t getDeferredTextureImageData(const GrContextThreadSafeProxy&, |
| 352 const DeferredTextureImageUsageParams[], |
| 353 int paramCnt, |
| 354 void* buffer) const; |
| 355 |
| 356 /** |
| 357 * Returns a texture-backed image from data produced in SkImage::getDeferred
TextureImageData. |
| 358 * The context must be the context that provided the proxy passed to |
| 359 * getDeferredTextureImageData. |
| 360 */ |
| 361 static sk_sp<SkImage> MakeFromDeferredTextureImageData(GrContext*, const voi
d*, SkBudgeted); |
| 362 |
| 324 // Helper functions to convert to SkBitmap | 363 // Helper functions to convert to SkBitmap |
| 325 | 364 |
| 326 enum LegacyBitmapMode { | 365 enum LegacyBitmapMode { |
| 327 kRO_LegacyBitmapMode, | 366 kRO_LegacyBitmapMode, |
| 328 kRW_LegacyBitmapMode, | 367 kRW_LegacyBitmapMode, |
| 329 }; | 368 }; |
| 330 | 369 |
| 331 /** | 370 /** |
| 332 * Attempt to create a bitmap with the same pixels as the image. The result
will always be | 371 * Attempt to create a bitmap with the same pixels as the image. The result
will always be |
| 333 * a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not s
upported here). | 372 * a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not s
upported here). |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 SkAlphaType = kPremul_SkAlphaType); | 407 SkAlphaType = kPremul_SkAlphaType); |
| 369 static SkImage* NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, | 408 static SkImage* NewFromTextureCopy(GrContext*, const GrBackendTextureDesc&, |
| 370 SkAlphaType = kPremul_SkAlphaType); | 409 SkAlphaType = kPremul_SkAlphaType); |
| 371 static SkImage* NewFromYUVTexturesCopy(GrContext*, SkYUVColorSpace, | 410 static SkImage* NewFromYUVTexturesCopy(GrContext*, SkYUVColorSpace, |
| 372 const GrBackendObject yuvTextureHandl
es[3], | 411 const GrBackendObject yuvTextureHandl
es[3], |
| 373 const SkISize yuvSizes[3], | 412 const SkISize yuvSizes[3], |
| 374 GrSurfaceOrigin); | 413 GrSurfaceOrigin); |
| 375 static SkImage* NewFromPicture(const SkPicture*, const SkISize& dimensions, | 414 static SkImage* NewFromPicture(const SkPicture*, const SkISize& dimensions, |
| 376 const SkMatrix*, const SkPaint*); | 415 const SkMatrix*, const SkPaint*); |
| 377 static SkImage* NewTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted
budgeted); | 416 static SkImage* NewTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted
budgeted); |
| 417 static SkImage* NewFromDeferredTextureImageData(GrContext*, const void*, SkB
udgeted); |
| 378 | 418 |
| 379 SkImage* newSubset(const SkIRect& subset) const { return this->makeSubset(su
bset).release(); } | 419 SkImage* newSubset(const SkIRect& subset) const { return this->makeSubset(su
bset).release(); } |
| 380 SkImage* newTextureImage(GrContext* ctx) const { return this->makeTextureIma
ge(ctx).release(); } | 420 SkImage* newTextureImage(GrContext* ctx) const { return this->makeTextureIma
ge(ctx).release(); } |
| 381 #endif | 421 #endif |
| 382 | 422 |
| 383 protected: | 423 protected: |
| 384 SkImage(int width, int height, uint32_t uniqueID); | 424 SkImage(int width, int height, uint32_t uniqueID); |
| 385 | 425 |
| 386 private: | 426 private: |
| 387 const int fWidth; | 427 const int fWidth; |
| 388 const int fHeight; | 428 const int fHeight; |
| 389 const uint32_t fUniqueID; | 429 const uint32_t fUniqueID; |
| 390 | 430 |
| 391 typedef SkRefCnt INHERITED; | 431 typedef SkRefCnt INHERITED; |
| 392 }; | 432 }; |
| 393 | 433 |
| 394 #endif | 434 #endif |
| OLD | NEW |