gfx/skia/trunk/src/image/SkImagePriv.h

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

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

mercurial