michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef SkImagePriv_DEFINED michael@0: #define SkImagePriv_DEFINED michael@0: michael@0: #include "SkBitmap.h" michael@0: #include "SkImage.h" michael@0: michael@0: class SkPicture; michael@0: michael@0: extern SkBitmap::Config SkImageInfoToBitmapConfig(const SkImageInfo&); michael@0: michael@0: // Call this if you explicitly want to use/share this pixelRef in the image michael@0: extern SkImage* SkNewImageFromPixelRef(const SkImageInfo&, SkPixelRef*, michael@0: size_t rowBytes); michael@0: michael@0: /** michael@0: * Examines the bitmap to decide if it can share the existing pixelRef, or michael@0: * if it needs to make a deep-copy of the pixels. The bitmap's pixelref will michael@0: * be shared if either the bitmap is marked as immutable, or canSharePixelRef michael@0: * is true. michael@0: * michael@0: * If the bitmap's config cannot be converted into a corresponding michael@0: * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return michael@0: * NULL. michael@0: */ michael@0: extern SkImage* SkNewImageFromBitmap(const SkBitmap&, bool canSharePixelRef); michael@0: michael@0: extern void SkImagePrivDrawPicture(SkCanvas*, SkPicture*, michael@0: SkScalar x, SkScalar y, const SkPaint*); michael@0: michael@0: extern void SkImagePrivDrawPicture(SkCanvas*, SkPicture*, michael@0: const SkRect*, const SkRect&, const SkPaint*); michael@0: michael@0: /** michael@0: * Return an SkImage whose contents are those of the specified picture. Note: michael@0: * The picture itself is unmodified, and may continue to be used for recording michael@0: */ michael@0: extern SkImage* SkNewImageFromPicture(const SkPicture*); michael@0: michael@0: static inline size_t SkImageMinRowBytes(const SkImageInfo& info) { michael@0: return SkAlign4(info.minRowBytes()); michael@0: } michael@0: michael@0: // Given an image created from SkNewImageFromBitmap, return its pixelref. This michael@0: // may be called to see if the surface and the image share the same pixelref, michael@0: // in which case the surface may need to perform a copy-on-write. michael@0: extern SkPixelRef* SkBitmapImageGetPixelRef(SkImage* rasterImage); michael@0: michael@0: // Given an image created with NewPicture, return its SkPicture. michael@0: extern SkPicture* SkPictureImageGetPicture(SkImage* pictureImage); michael@0: michael@0: // Given an image created with NewTexture, return its GrTexture. This michael@0: // may be called to see if the surface and the image share the same GrTexture, michael@0: // in which case the surface may need to perform a copy-on-write. michael@0: extern GrTexture* SkTextureImageGetTexture(SkImage* textureImage); michael@0: michael@0: // Update the texture wrapped by an image created with NewTexture. This michael@0: // is called when a surface and image share the same GrTexture and the michael@0: // surface needs to perform a copy-on-write michael@0: extern void SkTextureImageSetTexture(SkImage* image, GrTexture* texture); michael@0: michael@0: #endif