1 /* 2 * Copyright 2012 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkImagePriv_DEFINED 9 #define SkImagePriv_DEFINED 10 11 #include "SkBitmap.h" 12 #include "SkImage.h" 13 14 // Call this if you explicitly want to use/share this pixelRef in the image 15 extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*, 16 size_t rowBytes); 17 18 /** 19 * Examines the bitmap to decide if it can share the existing pixelRef, or 20 * if it needs to make a deep-copy of the pixels. The bitmap's pixelref will 21 * be shared if either the bitmap is marked as immutable, or canSharePixelRef 22 * is true. 23 * 24 * If the bitmap's colortype cannot be converted into a corresponding 25 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return 26 * NULL. 27 */ 28 extern SkImage* SkNewImageFromBitmap(const SkBitmap&, bool canSharePixelRef); 29 30 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { 31 return SkAlign4(info.minRowBytes()); 32 } 33 34 // Given an image created from SkNewImageFromBitmap, return its pixelref. This 35 // may be called to see if the surface and the image share the same pixelref, 36 // in which case the surface may need to perform a copy-on-write. 37 extern SkPixelRef* SkBitmapImageGetPixelRef(SkImage* rasterImage); 38 39 // Given an image created with NewTexture, return its GrTexture. This 40 // may be called to see if the surface and the image share the same GrTexture, 41 // in which case the surface may need to perform a copy-on-write. 42 extern GrTexture* SkTextureImageGetTexture(SkImage* textureImage); 43 44 // Update the texture wrapped by an image created with NewTexture. This 45 // is called when a surface and image share the same GrTexture and the 46 // surface needs to perform a copy-on-write 47 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); 48 49 #endif 50