2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkImagePriv_DEFINED
9 #define SkImagePriv_DEFINED
16 extern SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo&);
18 // Call this if you explicitly want to use/share this pixelRef in the image
19 extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*,
23 * Examines the bitmap to decide if it can share the existing pixelRef, or
24 * if it needs to make a deep-copy of the pixels. The bitmap's pixelref will
25 * be shared if either the bitmap is marked as immutable, or canSharePixelRef
28 * If the bitmap's config cannot be converted into a corresponding
29 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return
32 extern SkImage* SkNewImageFromBitmap(const SkBitmap&, bool canSharePixelRef);
34 extern void SkImagePrivDrawPicture(SkCanvas*, SkPicture*,
35 SkScalar x, SkScalar y, const SkPaint*);
37 extern void SkImagePrivDrawPicture(SkCanvas*, SkPicture*,
38 const SkRect*, const SkRect&, const SkPaint*);
41 * Return an SkImage whose contents are those of the specified picture. Note:
42 * The picture itself is unmodified, and may continue to be used for recording
44 extern SkImage* SkNewImageFromPicture(const SkPicture*);
46 static inline size_t SkImageMinRowBytes(const SkImageInfo& info) {
47 return SkAlign4(info.minRowBytes());
50 // Given an image created from SkNewImageFromBitmap, return its pixelref. This
51 // may be called to see if the surface and the image share the same pixelref,
52 // in which case the surface may need to perform a copy-on-write.
53 extern SkPixelRef* SkBitmapImageGetPixelRef(SkImage* rasterImage);
55 // Given an image created with NewPicture, return its SkPicture.
56 extern SkPicture* SkPictureImageGetPicture(SkImage* pictureImage);
58 // Given an image created with NewTexture, return its GrTexture. This
59 // may be called to see if the surface and the image share the same GrTexture,
60 // in which case the surface may need to perform a copy-on-write.
61 extern GrTexture* SkTextureImageGetTexture(SkImage* textureImage);
63 // Update the texture wrapped by an image created with NewTexture. This
64 // is called when a surface and image share the same GrTexture and the
65 // surface needs to perform a copy-on-write
66 extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture);