Flutter Engine
The Flutter Engine
SkImagePriv.h
Go to the documentation of this file.
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
14
15class SkPixelRef;
16
18 kIfMutable_SkCopyPixelsMode, //!< only copy src pixels if they are marked mutable
19 kAlways_SkCopyPixelsMode, //!< always copy src pixels (even if they are marked immutable)
20 kNever_SkCopyPixelsMode, //!< never copy src pixels (even if they are marked mutable)
21};
22
23// Convenience function to return a shader that implements the shader+image behavior defined for
24// drawImage/Bitmap where the paint's shader is ignored when the bitmap is a color image, but
25// properly compose them together when it is an alpha image. This allows the returned paint to
26// be assigned to a paint clone without discarding the original behavior.
29 const SkMatrix* localMatrix, SkCopyPixelsMode);
30
31// Given arguments for a call to SkCanvas::drawImageRect, modify the SkPaint and return a
32// possibly adjusted 'dst' SkRect such that calling SkCanvas::drawRect(newDst, *paint) produces
33// visually equivalent results to the original drawImageRect() call.
35 const SkSamplingOptions&,
36 SkRect src,
37 SkRect dst,
38 bool strictSrcSubset,
39 SkPaint* paint);
40
41/**
42 * Examines the bitmap to decide if it can share the existing pixelRef, or
43 * if it needs to make a deep-copy of the pixels.
44 *
45 * The bitmap's pixelref will be shared if either the bitmap is marked as
46 * immutable, or CopyPixelsMode allows it. Shared pixel refs are also
47 * locked when kLocked_SharedPixelRefMode is specified.
48 *
49 * Passing kLocked_SharedPixelRefMode allows the image's peekPixels() method
50 * to succeed, but it will force any lazy decodes/generators to execute if
51 * they exist on the pixelref.
52 *
53 * It is illegal to call this with a texture-backed bitmap.
54 *
55 * If the bitmap's colortype cannot be converted into a corresponding
56 * SkImageInfo, or the bitmap's pixels cannot be accessed, this will return
57 * nullptr.
58 */
60
61// Given an image created from SkNewImageFromBitmap, return its pixelref. This
62// may be called to see if the surface and the image share the same pixelref,
63// in which case the surface may need to perform a copy-on-write.
64extern const SkPixelRef* SkBitmapImageGetPixelRef(const SkImage* rasterImage);
65
66#endif
#define SK_SPI
Definition: SkAPI.h:41
SK_SPI sk_sp< SkImage > SkMakeImageFromRasterBitmap(const SkBitmap &, SkCopyPixelsMode)
SkCopyPixelsMode
Definition: SkImagePriv.h:17
@ kNever_SkCopyPixelsMode
never copy src pixels (even if they are marked mutable)
Definition: SkImagePriv.h:20
@ kIfMutable_SkCopyPixelsMode
only copy src pixels if they are marked mutable
Definition: SkImagePriv.h:18
@ kAlways_SkCopyPixelsMode
always copy src pixels (even if they are marked immutable)
Definition: SkImagePriv.h:19
SkRect SkModifyPaintAndDstForDrawImageRect(const SkImage *image, const SkSamplingOptions &, SkRect src, SkRect dst, bool strictSrcSubset, SkPaint *paint)
const SkPixelRef * SkBitmapImageGetPixelRef(const SkImage *rasterImage)
sk_sp< SkShader > SkMakeBitmapShaderForPaint(const SkPaint &paint, const SkBitmap &src, SkTileMode, SkTileMode, const SkSamplingOptions &, const SkMatrix *localMatrix, SkCopyPixelsMode)
SkTileMode
Definition: SkTileMode.h:13
const Paint & paint
Definition: color_source.cc:38
sk_sp< const SkImage > image
Definition: SkRecords.h:269
dst
Definition: cp.py:12