2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkCanvas_DEFINED
|
|
|
|
#define SkCanvas_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkBlendMode.h"
|
|
|
|
#include "include/core/SkClipOp.h"
|
|
|
|
#include "include/core/SkColor.h"
|
|
|
|
#include "include/core/SkFontTypes.h"
|
|
|
|
#include "include/core/SkImageInfo.h"
|
2020-02-20 20:42:29 +00:00
|
|
|
#include "include/core/SkM44.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkMatrix.h"
|
|
|
|
#include "include/core/SkPaint.h"
|
|
|
|
#include "include/core/SkPoint.h"
|
|
|
|
#include "include/core/SkRasterHandleAllocator.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
2020-12-16 21:13:19 +00:00
|
|
|
#include "include/core/SkSamplingOptions.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkScalar.h"
|
|
|
|
#include "include/core/SkSize.h"
|
|
|
|
#include "include/core/SkString.h"
|
|
|
|
#include "include/core/SkSurfaceProps.h"
|
|
|
|
#include "include/core/SkTypes.h"
|
2020-02-17 21:51:14 +00:00
|
|
|
#include "include/private/SkDeque.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/private/SkMacros.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2019-04-16 20:25:07 +00:00
|
|
|
#include <cstring>
|
|
|
|
#include <memory>
|
2020-01-16 18:58:22 +00:00
|
|
|
#include <vector>
|
2019-04-16 20:25:07 +00:00
|
|
|
|
2020-12-03 16:21:31 +00:00
|
|
|
// Working on allow this to be undefined
|
|
|
|
#define SK_SUPPORT_LEGACY_GETTOTALMATRIX
|
2021-01-20 20:22:51 +00:00
|
|
|
|
2021-01-13 18:14:23 +00:00
|
|
|
#define SK_SUPPORT_LEGACY_DRAWBITMAP
|
2020-12-03 16:21:31 +00:00
|
|
|
|
2021-01-19 22:58:25 +00:00
|
|
|
#define SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING
|
|
|
|
|
2020-12-11 22:34:23 +00:00
|
|
|
class GrBackendRenderTarget;
|
2020-06-26 18:04:05 +00:00
|
|
|
class GrRecordingContext;
|
2020-12-09 21:37:04 +00:00
|
|
|
class GrSurfaceDrawContext;
|
2013-08-29 11:54:56 +00:00
|
|
|
class SkBaseDevice;
|
2017-02-13 14:32:54 +00:00
|
|
|
class SkBitmap;
|
2016-03-05 00:36:20 +00:00
|
|
|
class SkData;
|
2015-02-06 16:36:15 +00:00
|
|
|
class SkDrawable;
|
2017-05-17 12:53:36 +00:00
|
|
|
struct SkDrawShadowRec;
|
2018-11-23 20:27:51 +00:00
|
|
|
class SkFont;
|
2018-06-07 16:44:09 +00:00
|
|
|
class SkGlyphRunBuilder;
|
2017-02-13 14:32:54 +00:00
|
|
|
class SkImage;
|
2015-08-05 20:57:49 +00:00
|
|
|
class SkImageFilter;
|
2020-04-14 13:16:40 +00:00
|
|
|
class SkMarkerStack;
|
2019-03-28 20:39:58 +00:00
|
|
|
class SkPaintFilterCanvas;
|
2015-08-05 20:57:49 +00:00
|
|
|
class SkPath;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkPicture;
|
2015-08-05 20:57:49 +00:00
|
|
|
class SkPixmap;
|
2017-02-13 14:32:54 +00:00
|
|
|
class SkRegion;
|
2012-12-12 20:48:18 +00:00
|
|
|
class SkRRect;
|
2015-06-24 17:29:17 +00:00
|
|
|
struct SkRSXform;
|
2014-02-05 15:32:21 +00:00
|
|
|
class SkSurface;
|
2012-08-28 12:19:02 +00:00
|
|
|
class SkSurface_Base;
|
2014-08-21 15:53:26 +00:00
|
|
|
class SkTextBlob;
|
2020-04-01 13:29:13 +00:00
|
|
|
class SkVertices;
|
2014-09-04 19:14:36 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** \class SkCanvas
|
2017-09-01 17:49:54 +00:00
|
|
|
SkCanvas provides an interface for drawing, and how the drawing is clipped and transformed.
|
|
|
|
SkCanvas contains a stack of SkMatrix and clip values.
|
|
|
|
|
|
|
|
SkCanvas and SkPaint together provide the state to draw into SkSurface or SkBaseDevice.
|
|
|
|
Each SkCanvas draw call transforms the geometry of the object by the concatenation of all
|
|
|
|
SkMatrix values in the stack. The transformed geometry is clipped by the intersection
|
|
|
|
of all of clip values in the stack. The SkCanvas draw calls use SkPaint to supply drawing
|
|
|
|
state such as color, SkTypeface, text size, stroke width, SkShader and so on.
|
|
|
|
|
|
|
|
To draw to a pixel-based destination, create raster surface or GPU surface.
|
|
|
|
Request SkCanvas from SkSurface to obtain the interface to draw.
|
|
|
|
SkCanvas generated by raster surface draws to memory visible to the CPU.
|
|
|
|
SkCanvas generated by GPU surface uses Vulkan or OpenGL to draw to the GPU.
|
|
|
|
|
2018-10-31 14:54:50 +00:00
|
|
|
To draw to a document, obtain SkCanvas from SVG canvas, document PDF, or SkPictureRecorder.
|
2018-05-30 13:20:29 +00:00
|
|
|
SkDocument based SkCanvas and other SkCanvas subclasses reference SkBaseDevice describing the
|
2017-09-01 17:49:54 +00:00
|
|
|
destination.
|
|
|
|
|
|
|
|
SkCanvas can be constructed to draw to SkBitmap without first creating raster surface.
|
|
|
|
This approach may be deprecated in the future.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2018-06-14 18:57:12 +00:00
|
|
|
class SK_API SkCanvas {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Allocates raster SkCanvas that will draw directly into pixels.
|
|
|
|
|
|
|
|
SkCanvas is returned if all parameters are valid.
|
|
|
|
Valid parameters include:
|
|
|
|
info dimensions are zero or positive;
|
|
|
|
info contains SkColorType and SkAlphaType supported by raster surface;
|
|
|
|
pixels is not nullptr;
|
|
|
|
rowBytes is zero or large enough to contain info width pixels of SkColorType.
|
|
|
|
|
|
|
|
Pass zero for rowBytes to compute rowBytes from info width and size of pixel.
|
|
|
|
If rowBytes is greater than zero, it must be equal to or greater than
|
|
|
|
info width times bytes required for SkColorType.
|
|
|
|
|
|
|
|
Pixel buffer size should be info height times computed rowBytes.
|
2018-01-03 15:00:34 +00:00
|
|
|
Pixels are not initialized.
|
|
|
|
To access pixels after drawing, call flush() or peekPixels().
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param info width, height, SkColorType, SkAlphaType, SkColorSpace, of raster surface;
|
2017-09-01 17:49:54 +00:00
|
|
|
width, or height, or both, may be zero
|
|
|
|
@param pixels pointer to destination pixels buffer
|
|
|
|
@param rowBytes interval from one SkSurface row to the next, or zero
|
2018-01-03 15:00:34 +00:00
|
|
|
@param props LCD striping orientation and setting for device independent fonts;
|
|
|
|
may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
@return SkCanvas if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
static std::unique_ptr<SkCanvas> MakeRasterDirect(const SkImageInfo& info, void* pixels,
|
2017-11-08 16:19:52 +00:00
|
|
|
size_t rowBytes,
|
|
|
|
const SkSurfaceProps* props = nullptr);
|
2016-11-12 14:06:55 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Allocates raster SkCanvas specified by inline image specification. Subsequent SkCanvas
|
|
|
|
calls draw into pixels.
|
|
|
|
SkColorType is set to kN32_SkColorType.
|
|
|
|
SkAlphaType is set to kPremul_SkAlphaType.
|
|
|
|
To access pixels after drawing, call flush() or peekPixels().
|
|
|
|
|
|
|
|
SkCanvas is returned if all parameters are valid.
|
|
|
|
Valid parameters include:
|
|
|
|
width and height are zero or positive;
|
|
|
|
pixels is not nullptr;
|
|
|
|
rowBytes is zero or large enough to contain width pixels of kN32_SkColorType.
|
|
|
|
|
|
|
|
Pass zero for rowBytes to compute rowBytes from width and size of pixel.
|
|
|
|
If rowBytes is greater than zero, it must be equal to or greater than
|
|
|
|
width times bytes required for SkColorType.
|
|
|
|
|
|
|
|
Pixel buffer size should be height times rowBytes.
|
|
|
|
|
|
|
|
@param width pixel column count on raster surface created; must be zero or greater
|
2017-10-30 15:48:35 +00:00
|
|
|
@param height pixel row count on raster surface created; must be zero or greater
|
2017-09-01 17:49:54 +00:00
|
|
|
@param pixels pointer to destination pixels buffer; buffer size should be height
|
|
|
|
times rowBytes
|
|
|
|
@param rowBytes interval from one SkSurface row to the next, or zero
|
|
|
|
@return SkCanvas if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2016-11-12 14:06:55 +00:00
|
|
|
static std::unique_ptr<SkCanvas> MakeRasterDirectN32(int width, int height, SkPMColor* pixels,
|
|
|
|
size_t rowBytes) {
|
|
|
|
return MakeRasterDirect(SkImageInfo::MakeN32Premul(width, height), pixels, rowBytes);
|
|
|
|
}
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Creates an empty SkCanvas with no backing device or pixels, with
|
2017-09-01 17:49:54 +00:00
|
|
|
a width and height of zero.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@return empty SkCanvas
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_empty_constructor
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2011-07-06 20:00:52 +00:00
|
|
|
SkCanvas();
|
2010-10-13 22:13:05 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Creates SkCanvas of the specified dimensions without a SkSurface.
|
2018-05-30 13:20:29 +00:00
|
|
|
Used by subclasses with custom implementations for draw member functions.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
If props equals nullptr, SkSurfaceProps are created with
|
|
|
|
SkSurfaceProps::InitType settings, which choose the pixel striping
|
|
|
|
direction and order. Since a platform may dynamically change its direction when
|
|
|
|
the device is rotated, and since a platform may have multiple monitors with
|
|
|
|
different characteristics, it is best not to rely on this legacy behavior.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param width zero or greater
|
|
|
|
@param height zero or greater
|
|
|
|
@param props LCD striping orientation and setting for device independent fonts;
|
|
|
|
may be nullptr
|
|
|
|
@return SkCanvas placeholder with dimensions
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_int_int_const_SkSurfaceProps_star
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-08-28 14:34:05 +00:00
|
|
|
SkCanvas(int width, int height, const SkSurfaceProps* props = nullptr);
|
2014-01-31 19:42:58 +00:00
|
|
|
|
2018-11-29 17:05:25 +00:00
|
|
|
/** Private. For internal use only.
|
2010-10-13 22:13:05 +00:00
|
|
|
*/
|
2018-05-01 21:06:20 +00:00
|
|
|
explicit SkCanvas(sk_sp<SkBaseDevice> device);
|
2010-10-13 22:13:05 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Constructs a canvas that draws into bitmap.
|
2020-09-24 18:49:00 +00:00
|
|
|
Sets kUnknown_SkPixelGeometry in constructed SkSurface.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
SkBitmap is copied so that subsequently editing bitmap will not affect
|
|
|
|
constructed SkCanvas.
|
|
|
|
|
|
|
|
May be deprecated in the future.
|
|
|
|
|
|
|
|
@param bitmap width, height, SkColorType, SkAlphaType, and pixel
|
|
|
|
storage of raster surface
|
|
|
|
@return SkCanvas that can be used to draw into bitmap
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_copy_const_SkBitmap
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
explicit SkCanvas(const SkBitmap& bitmap);
|
2015-02-02 13:25:04 +00:00
|
|
|
|
2017-04-11 12:46:01 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
2018-11-15 13:25:12 +00:00
|
|
|
/** Private.
|
|
|
|
*/
|
2017-04-11 12:46:01 +00:00
|
|
|
enum class ColorBehavior {
|
2018-05-30 13:20:29 +00:00
|
|
|
kLegacy, //!< placeholder
|
2017-04-11 12:46:01 +00:00
|
|
|
};
|
|
|
|
|
2018-11-15 13:25:12 +00:00
|
|
|
/** Private. For use by Android framework only.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param bitmap specifies a bitmap for the canvas to draw into
|
|
|
|
@param behavior specializes this constructor; value is unused
|
|
|
|
@return SkCanvas that can be used to draw into bitmap
|
|
|
|
*/
|
2017-05-13 17:35:35 +00:00
|
|
|
SkCanvas(const SkBitmap& bitmap, ColorBehavior behavior);
|
2017-04-11 12:46:01 +00:00
|
|
|
#endif
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Constructs a canvas that draws into bitmap.
|
2017-09-01 17:49:54 +00:00
|
|
|
Use props to match the device characteristics, like LCD striping.
|
|
|
|
|
|
|
|
bitmap is copied so that subsequently editing bitmap will not affect
|
|
|
|
constructed SkCanvas.
|
|
|
|
|
|
|
|
@param bitmap width, height, SkColorType, SkAlphaType,
|
|
|
|
and pixel storage of raster surface
|
|
|
|
@param props order and orientation of RGB striping; and whether to use
|
|
|
|
device independent fonts
|
|
|
|
@return SkCanvas that can be used to draw into bitmap
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_const_SkBitmap_const_SkSurfaceProps
|
2015-02-02 13:25:04 +00:00
|
|
|
*/
|
|
|
|
SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props);
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** Draws saved layers, if any.
|
2018-02-27 15:22:04 +00:00
|
|
|
Frees up resources used by SkCanvas.
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_destructor
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
virtual ~SkCanvas();
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns SkImageInfo for SkCanvas. If SkCanvas is not associated with raster surface or
|
|
|
|
GPU surface, returned SkColorType is set to kUnknown_SkColorType.
|
|
|
|
|
|
|
|
@return dimensions and SkColorType of SkCanvas
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_imageInfo
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2014-02-13 17:14:46 +00:00
|
|
|
SkImageInfo imageInfo() const;
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Copies SkSurfaceProps, if SkCanvas is associated with raster surface or
|
|
|
|
GPU surface, and returns true. Otherwise, returns false and leave props unchanged.
|
2016-04-06 14:38:23 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param props storage for writable SkSurfaceProps
|
|
|
|
@return true if SkSurfaceProps was copied
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_getProps
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
|
|
|
bool getProps(SkSurfaceProps* props) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Triggers the immediate execution of all pending draw operations.
|
|
|
|
If SkCanvas is associated with GPU surface, resolves all pending GPU operations.
|
2018-01-03 15:00:34 +00:00
|
|
|
If SkCanvas is associated with raster surface, has no effect; raster draw
|
|
|
|
operations are never deferred.
|
2020-11-30 13:32:38 +00:00
|
|
|
|
|
|
|
DEPRECATED: Replace usage with GrDirectContext::flush()
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2012-01-30 14:53:22 +00:00
|
|
|
void flush();
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Gets the size of the base or root layer in global canvas coordinates. The
|
|
|
|
origin of the base layer is always (0,0). The area available for drawing may be
|
2017-09-01 17:49:54 +00:00
|
|
|
smaller (due to clipping or saveLayer).
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@return integral width and height of base layer
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_getBaseLayerSize
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2015-03-23 14:22:40 +00:00
|
|
|
virtual SkISize getBaseLayerSize() const;
|
2014-02-26 20:22:32 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Creates SkSurface matching info and props, and associates it with SkCanvas.
|
|
|
|
Returns nullptr if no match found.
|
|
|
|
|
|
|
|
If props is nullptr, matches SkSurfaceProps in SkCanvas. If props is nullptr and SkCanvas
|
|
|
|
does not have SkSurfaceProps, creates SkSurface with default SkSurfaceProps.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param info width, height, SkColorType, SkAlphaType, and SkColorSpace
|
2017-09-01 17:49:54 +00:00
|
|
|
@param props SkSurfaceProps to match; may be nullptr to match SkCanvas
|
|
|
|
@return SkSurface matching info and props, or nullptr if no match is available
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_makeSurface
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-13 17:35:35 +00:00
|
|
|
sk_sp<SkSurface> makeSurface(const SkImageInfo& info, const SkSurfaceProps* props = nullptr);
|
2011-06-17 13:10:25 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns GPU context of the GPU surface associated with SkCanvas.
|
|
|
|
|
|
|
|
@return GPU context, if available; nullptr otherwise
|
2019-03-15 19:47:01 +00:00
|
|
|
|
2020-09-16 11:39:31 +00:00
|
|
|
example: https://fiddle.skia.org/c/@Canvas_recordingContext
|
2020-06-26 18:04:05 +00:00
|
|
|
*/
|
|
|
|
virtual GrRecordingContext* recordingContext();
|
|
|
|
|
2019-11-15 20:00:27 +00:00
|
|
|
/** Sometimes a canvas is owned by a surface. If it is, getSurface() will return a bare
|
|
|
|
* pointer to that surface, else this will return nullptr.
|
|
|
|
*/
|
|
|
|
SkSurface* getSurface() const;
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns the pixel base address, SkImageInfo, rowBytes, and origin if the pixels
|
|
|
|
can be read directly. The returned address is only valid
|
|
|
|
while SkCanvas is in scope and unchanged. Any SkCanvas call or SkSurface call
|
|
|
|
may invalidate the returned address and other returned values.
|
|
|
|
|
|
|
|
If pixels are inaccessible, info, rowBytes, and origin are unchanged.
|
2011-01-11 18:32:13 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param info storage for writable pixels' SkImageInfo; may be nullptr
|
|
|
|
@param rowBytes storage for writable pixels' row bytes; may be nullptr
|
2017-10-30 15:48:35 +00:00
|
|
|
@param origin storage for SkCanvas top layer origin, its top-left corner;
|
2017-09-01 17:49:54 +00:00
|
|
|
may be nullptr
|
|
|
|
@return address of pixels, or nullptr if inaccessible
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_accessTopLayerPixels_a
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_accessTopLayerPixels_b
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-08-28 14:34:05 +00:00
|
|
|
void* accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoint* origin = nullptr);
|
2014-03-12 18:28:35 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns custom context that tracks the SkMatrix and clip.
|
|
|
|
|
|
|
|
Use SkRasterHandleAllocator to blend Skia drawing with custom drawing, typically performed
|
2017-10-30 15:48:35 +00:00
|
|
|
by the host platform user interface. The custom context returned is generated by
|
2017-09-01 17:49:54 +00:00
|
|
|
SkRasterHandleAllocator::MakeCanvas, which creates a custom canvas with raster storage for
|
|
|
|
the drawing destination.
|
|
|
|
|
|
|
|
@return context of custom allocation
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_accessTopRasterHandle
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-01-10 16:58:39 +00:00
|
|
|
SkRasterHandleAllocator::Handle accessTopRasterHandle() const;
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if SkCanvas has direct access to its pixels.
|
|
|
|
|
|
|
|
Pixels are readable when SkBaseDevice is raster. Pixels are not readable when SkCanvas
|
|
|
|
is returned from GPU surface, returned by SkDocument::beginPage, returned by
|
|
|
|
SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility class
|
2019-03-20 16:59:00 +00:00
|
|
|
like DebugCanvas.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
pixmap is valid only while SkCanvas is in scope and unchanged. Any
|
|
|
|
SkCanvas or SkSurface call may invalidate the pixmap values.
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
@param pixmap storage for pixel state if pixels are readable; otherwise, ignored
|
2017-09-01 17:49:54 +00:00
|
|
|
@return true if SkCanvas has direct access to pixels
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_peekPixels
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
bool peekPixels(SkPixmap* pixmap);
|
2016-03-09 22:26:26 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** Copies SkRect of pixels from SkCanvas into dstPixels. SkMatrix and clip are
|
2018-01-03 15:00:34 +00:00
|
|
|
ignored.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Source SkRect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
|
|
|
|
Destination SkRect corners are (0, 0) and (dstInfo.width(), dstInfo.height()).
|
2017-09-21 16:28:43 +00:00
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
|
|
|
converting to dstInfo.colorType() and dstInfo.alphaType() if required.
|
|
|
|
|
|
|
|
Pixels are readable when SkBaseDevice is raster, or backed by a GPU.
|
|
|
|
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
|
|
|
|
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
|
2019-03-20 16:59:00 +00:00
|
|
|
class like DebugCanvas.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
The destination pixel storage must be allocated by the caller.
|
|
|
|
|
|
|
|
Pixel values are converted only if SkColorType and SkAlphaType
|
|
|
|
do not match. Only pixels within both source and destination rectangles
|
2017-10-30 15:48:35 +00:00
|
|
|
are copied. dstPixels contents outside SkRect intersection are unchanged.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Pass negative values for srcX or srcY to offset pixels across or down destination.
|
|
|
|
|
|
|
|
Does not copy, and returns false if:
|
|
|
|
- Source and destination rectangles do not intersect.
|
|
|
|
- SkCanvas pixels could not be converted to dstInfo.colorType() or dstInfo.alphaType().
|
|
|
|
- SkCanvas pixels are not readable; for instance, SkCanvas is document-based.
|
|
|
|
- dstRowBytes is too small to contain one row of pixels.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param dstInfo width, height, SkColorType, and SkAlphaType of dstPixels
|
|
|
|
@param dstPixels storage for pixels; dstInfo.height() times dstRowBytes, or larger
|
|
|
|
@param dstRowBytes size of one destination row; dstInfo.width() times pixel size, or larger
|
2018-06-14 17:21:08 +00:00
|
|
|
@param srcX offset into readable pixels on x-axis; may be negative
|
|
|
|
@param srcY offset into readable pixels on y-axis; may be negative
|
2017-09-01 17:49:54 +00:00
|
|
|
@return true if pixels were copied
|
|
|
|
*/
|
2014-07-13 11:32:32 +00:00
|
|
|
bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
|
|
|
|
int srcX, int srcY);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** Copies SkRect of pixels from SkCanvas into pixmap. SkMatrix and clip are
|
2018-01-03 15:00:34 +00:00
|
|
|
ignored.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Source SkRect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
|
|
|
|
Destination SkRect corners are (0, 0) and (pixmap.width(), pixmap.height()).
|
2017-09-21 16:28:43 +00:00
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
|
|
|
converting to pixmap.colorType() and pixmap.alphaType() if required.
|
|
|
|
|
|
|
|
Pixels are readable when SkBaseDevice is raster, or backed by a GPU.
|
|
|
|
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
|
|
|
|
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
|
2019-03-20 16:59:00 +00:00
|
|
|
class like DebugCanvas.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Caller must allocate pixel storage in pixmap if needed.
|
|
|
|
|
|
|
|
Pixel values are converted only if SkColorType and SkAlphaType
|
2018-02-27 15:22:04 +00:00
|
|
|
do not match. Only pixels within both source and destination SkRect
|
2017-10-30 15:48:35 +00:00
|
|
|
are copied. pixmap pixels contents outside SkRect intersection are unchanged.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Pass negative values for srcX or srcY to offset pixels across or down pixmap.
|
|
|
|
|
|
|
|
Does not copy, and returns false if:
|
|
|
|
- Source and destination rectangles do not intersect.
|
|
|
|
- SkCanvas pixels could not be converted to pixmap.colorType() or pixmap.alphaType().
|
|
|
|
- SkCanvas pixels are not readable; for instance, SkCanvas is document-based.
|
|
|
|
- SkPixmap pixels could not be allocated.
|
|
|
|
- pixmap.rowBytes() is too small to contain one row of pixels.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param pixmap storage for pixels copied from SkCanvas
|
2018-06-14 17:21:08 +00:00
|
|
|
@param srcX offset into readable pixels on x-axis; may be negative
|
|
|
|
@param srcY offset into readable pixels on y-axis; may be negative
|
2017-09-01 17:49:54 +00:00
|
|
|
@return true if pixels were copied
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_readPixels_2
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
bool readPixels(const SkPixmap& pixmap, int srcX, int srcY);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** Copies SkRect of pixels from SkCanvas into bitmap. SkMatrix and clip are
|
2018-01-03 15:00:34 +00:00
|
|
|
ignored.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Source SkRect corners are (srcX, srcY) and (imageInfo().width(), imageInfo().height()).
|
2017-10-30 15:48:35 +00:00
|
|
|
Destination SkRect corners are (0, 0) and (bitmap.width(), bitmap.height()).
|
2017-09-21 16:28:43 +00:00
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
|
|
|
converting to bitmap.colorType() and bitmap.alphaType() if required.
|
|
|
|
|
|
|
|
Pixels are readable when SkBaseDevice is raster, or backed by a GPU.
|
|
|
|
Pixels are not readable when SkCanvas is returned by SkDocument::beginPage,
|
|
|
|
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
|
2019-03-20 16:59:00 +00:00
|
|
|
class like DebugCanvas.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Caller must allocate pixel storage in bitmap if needed.
|
|
|
|
|
|
|
|
SkBitmap values are converted only if SkColorType and SkAlphaType
|
|
|
|
do not match. Only pixels within both source and destination rectangles
|
2017-10-30 15:48:35 +00:00
|
|
|
are copied. SkBitmap pixels outside SkRect intersection are unchanged.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Pass negative values for srcX or srcY to offset pixels across or down bitmap.
|
|
|
|
|
|
|
|
Does not copy, and returns false if:
|
|
|
|
- Source and destination rectangles do not intersect.
|
|
|
|
- SkCanvas pixels could not be converted to bitmap.colorType() or bitmap.alphaType().
|
|
|
|
- SkCanvas pixels are not readable; for instance, SkCanvas is document-based.
|
|
|
|
- bitmap pixels could not be allocated.
|
|
|
|
- bitmap.rowBytes() is too small to contain one row of pixels.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param bitmap storage for pixels copied from SkCanvas
|
2018-06-14 17:21:08 +00:00
|
|
|
@param srcX offset into readable pixels on x-axis; may be negative
|
|
|
|
@param srcY offset into readable pixels on y-axis; may be negative
|
2017-09-01 17:49:54 +00:00
|
|
|
@return true if pixels were copied
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_readPixels_3
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-13 17:35:35 +00:00
|
|
|
bool readPixels(const SkBitmap& bitmap, int srcX, int srcY);
|
2014-03-17 21:31:26 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** Copies SkRect from pixels to SkCanvas. SkMatrix and clip are ignored.
|
|
|
|
Source SkRect corners are (0, 0) and (info.width(), info.height()).
|
|
|
|
Destination SkRect corners are (x, y) and
|
|
|
|
(imageInfo().width(), imageInfo().height()).
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
2017-10-30 15:48:35 +00:00
|
|
|
converting to imageInfo().colorType() and imageInfo().alphaType() if required.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Pixels are writable when SkBaseDevice is raster, or backed by a GPU.
|
|
|
|
Pixels are not writable when SkCanvas is returned by SkDocument::beginPage,
|
|
|
|
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
|
2019-03-20 16:59:00 +00:00
|
|
|
class like DebugCanvas.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Pixel values are converted only if SkColorType and SkAlphaType
|
|
|
|
do not match. Only pixels within both source and destination rectangles
|
2017-10-30 15:48:35 +00:00
|
|
|
are copied. SkCanvas pixels outside SkRect intersection are unchanged.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Pass negative values for x or y to offset pixels to the left or
|
|
|
|
above SkCanvas pixels.
|
|
|
|
|
|
|
|
Does not copy, and returns false if:
|
|
|
|
- Source and destination rectangles do not intersect.
|
2018-02-27 15:22:04 +00:00
|
|
|
- pixels could not be converted to SkCanvas imageInfo().colorType() or
|
|
|
|
imageInfo().alphaType().
|
2017-09-21 16:28:43 +00:00
|
|
|
- SkCanvas pixels are not writable; for instance, SkCanvas is document-based.
|
|
|
|
- rowBytes is too small to contain one row of pixels.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param info width, height, SkColorType, and SkAlphaType of pixels
|
|
|
|
@param pixels pixels to copy, of size info.height() times rowBytes, or larger
|
2017-09-21 16:28:43 +00:00
|
|
|
@param rowBytes size of one row of pixels; info.width() times pixel size, or larger
|
2018-06-14 17:21:08 +00:00
|
|
|
@param x offset into SkCanvas writable pixels on x-axis; may be negative
|
|
|
|
@param y offset into SkCanvas writable pixels on y-axis; may be negative
|
2017-09-01 17:49:54 +00:00
|
|
|
@return true if pixels were written to SkCanvas
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_writePixels
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
bool writePixels(const SkImageInfo& info, const void* pixels, size_t rowBytes, int x, int y);
|
2014-03-07 03:25:16 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** Copies SkRect from pixels to SkCanvas. SkMatrix and clip are ignored.
|
|
|
|
Source SkRect corners are (0, 0) and (bitmap.width(), bitmap.height()).
|
2017-09-21 16:28:43 +00:00
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
Destination SkRect corners are (x, y) and
|
|
|
|
(imageInfo().width(), imageInfo().height()).
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
2017-10-30 15:48:35 +00:00
|
|
|
converting to imageInfo().colorType() and imageInfo().alphaType() if required.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Pixels are writable when SkBaseDevice is raster, or backed by a GPU.
|
|
|
|
Pixels are not writable when SkCanvas is returned by SkDocument::beginPage,
|
|
|
|
returned by SkPictureRecorder::beginRecording, or SkCanvas is the base of a utility
|
2019-03-20 16:59:00 +00:00
|
|
|
class like DebugCanvas.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Pixel values are converted only if SkColorType and SkAlphaType
|
|
|
|
do not match. Only pixels within both source and destination rectangles
|
2017-10-30 15:48:35 +00:00
|
|
|
are copied. SkCanvas pixels outside SkRect intersection are unchanged.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
|
|
|
Pass negative values for x or y to offset pixels to the left or
|
|
|
|
above SkCanvas pixels.
|
|
|
|
|
|
|
|
Does not copy, and returns false if:
|
|
|
|
- Source and destination rectangles do not intersect.
|
|
|
|
- bitmap does not have allocated pixels.
|
2018-02-27 15:22:04 +00:00
|
|
|
- bitmap pixels could not be converted to SkCanvas imageInfo().colorType() or
|
|
|
|
imageInfo().alphaType().
|
2017-09-21 16:28:43 +00:00
|
|
|
- SkCanvas pixels are not writable; for instance, SkCanvas is document based.
|
|
|
|
- bitmap pixels are inaccessible; for instance, bitmap wraps a texture.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param bitmap contains pixels copied to SkCanvas
|
2018-10-31 14:54:50 +00:00
|
|
|
@param x offset into SkCanvas writable pixels on x-axis; may be negative
|
|
|
|
@param y offset into SkCanvas writable pixels on y-axis; may be negative
|
2017-09-01 17:49:54 +00:00
|
|
|
@return true if pixels were written to SkCanvas
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_writePixels_2
|
|
|
|
example: https://fiddle.skia.org/c/@State_Stack_a
|
|
|
|
example: https://fiddle.skia.org/c/@State_Stack_b
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2014-03-07 03:25:16 +00:00
|
|
|
bool writePixels(const SkBitmap& bitmap, int x, int y);
|
2011-01-11 18:32:13 +00:00
|
|
|
|
2018-06-27 18:46:46 +00:00
|
|
|
/** Saves SkMatrix and clip.
|
2018-07-13 12:21:59 +00:00
|
|
|
Calling restore() discards changes to SkMatrix and clip,
|
|
|
|
restoring the SkMatrix and clip to their state when save() was called.
|
2010-10-13 22:13:05 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(), setMatrix(),
|
|
|
|
and resetMatrix(). Clip may be changed by clipRect(), clipRRect(), clipPath(), clipRegion().
|
2014-04-24 21:51:58 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
Saved SkCanvas state is put on a stack; multiple calls to save() should be balance
|
|
|
|
by an equal number of calls to restore().
|
|
|
|
|
|
|
|
Call restoreToCount() with result to restore this and subsequent saves.
|
|
|
|
|
|
|
|
@return depth of saved stack
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_save
|
2014-04-24 21:51:58 +00:00
|
|
|
*/
|
|
|
|
int save();
|
|
|
|
|
2018-06-27 18:46:46 +00:00
|
|
|
/** Saves SkMatrix and clip, and allocates a SkBitmap for subsequent drawing.
|
|
|
|
Calling restore() discards changes to SkMatrix and clip, and draws the SkBitmap.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(),
|
|
|
|
setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(),
|
|
|
|
clipPath(), clipRegion().
|
|
|
|
|
|
|
|
SkRect bounds suggests but does not define the SkBitmap size. To clip drawing to
|
|
|
|
a specific rectangle, use clipRect().
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
Optional SkPaint paint applies alpha, SkColorFilter, SkImageFilter, and
|
2017-09-01 17:49:54 +00:00
|
|
|
SkBlendMode when restore() is called.
|
|
|
|
|
|
|
|
Call restoreToCount() with returned value to restore this and subsequent saves.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param bounds hint to limit the size of the layer; may be nullptr
|
|
|
|
@param paint graphics state for layer; may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
@return depth of saved stack
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_saveLayer
|
2020-03-17 17:55:58 +00:00
|
|
|
example: https://fiddle.skia.org/c/@Canvas_saveLayer_4
|
2014-04-24 21:51:58 +00:00
|
|
|
*/
|
|
|
|
int saveLayer(const SkRect* bounds, const SkPaint* paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-06-27 18:46:46 +00:00
|
|
|
/** Saves SkMatrix and clip, and allocates a SkBitmap for subsequent drawing.
|
|
|
|
Calling restore() discards changes to SkMatrix and clip, and draws the SkBitmap.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(),
|
|
|
|
setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(),
|
|
|
|
clipPath(), clipRegion().
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
SkRect bounds suggests but does not define the layer size. To clip drawing to
|
2017-09-01 17:49:54 +00:00
|
|
|
a specific rectangle, use clipRect().
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
Optional SkPaint paint applies alpha, SkColorFilter, SkImageFilter, and
|
2017-09-01 17:49:54 +00:00
|
|
|
SkBlendMode when restore() is called.
|
|
|
|
|
|
|
|
Call restoreToCount() with returned value to restore this and subsequent saves.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param bounds hint to limit the size of layer; may be nullptr
|
|
|
|
@param paint graphics state for layer; may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
@return depth of saved stack
|
|
|
|
*/
|
2015-08-10 02:41:13 +00:00
|
|
|
int saveLayer(const SkRect& bounds, const SkPaint* paint) {
|
|
|
|
return this->saveLayer(&bounds, paint);
|
|
|
|
}
|
2014-04-24 21:51:58 +00:00
|
|
|
|
2018-06-27 18:46:46 +00:00
|
|
|
/** Saves SkMatrix and clip, and allocates SkBitmap for subsequent drawing.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
Calling restore() discards changes to SkMatrix and clip,
|
|
|
|
and blends layer with alpha opacity onto prior layer.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(),
|
|
|
|
setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(),
|
|
|
|
clipPath(), clipRegion().
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
SkRect bounds suggests but does not define layer size. To clip drawing to
|
2017-09-01 17:49:54 +00:00
|
|
|
a specific rectangle, use clipRect().
|
|
|
|
|
|
|
|
alpha of zero is fully transparent, 255 is fully opaque.
|
|
|
|
|
|
|
|
Call restoreToCount() with returned value to restore this and subsequent saves.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param bounds hint to limit the size of layer; may be nullptr
|
|
|
|
@param alpha opacity of layer
|
2017-09-01 17:49:54 +00:00
|
|
|
@return depth of saved stack
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_saveLayerAlpha
|
2014-04-24 21:51:58 +00:00
|
|
|
*/
|
|
|
|
int saveLayerAlpha(const SkRect* bounds, U8CPU alpha);
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** \enum SkCanvas::SaveLayerFlagsSet
|
2017-09-01 17:49:54 +00:00
|
|
|
SaveLayerFlags provides options that may be used in any combination in SaveLayerRec,
|
2018-05-30 13:20:29 +00:00
|
|
|
defining how layer allocated by saveLayer() operates. It may be set to zero,
|
|
|
|
kPreserveLCDText_SaveLayerFlag, kInitWithPrevious_SaveLayerFlag, or both flags.
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2018-04-26 12:32:37 +00:00
|
|
|
enum SaveLayerFlagsSet {
|
2020-05-01 16:34:57 +00:00
|
|
|
kPreserveLCDText_SaveLayerFlag = 1 << 1,
|
2018-05-30 13:20:29 +00:00
|
|
|
kInitWithPrevious_SaveLayerFlag = 1 << 2, //!< initializes with previous contents
|
|
|
|
kMaskAgainstCoverage_EXPERIMENTAL_DONT_USE_SaveLayerFlag =
|
|
|
|
1 << 3, //!< experimental: do not use
|
2019-07-12 16:53:11 +00:00
|
|
|
// instead of matching previous layer's colortype, use F16
|
|
|
|
kF16ColorType = 1 << 4,
|
2015-12-18 15:09:18 +00:00
|
|
|
};
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2015-12-18 15:09:18 +00:00
|
|
|
typedef uint32_t SaveLayerFlags;
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \struct SkCanvas::SaveLayerRec
|
2017-10-30 15:48:35 +00:00
|
|
|
SaveLayerRec contains the state used to create the layer.
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2015-12-18 15:09:18 +00:00
|
|
|
struct SaveLayerRec {
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Sets fBounds, fPaint, and fBackdrop to nullptr. Clears fSaveLayerFlags.
|
|
|
|
|
|
|
|
@return empty SaveLayerRec
|
|
|
|
*/
|
2017-04-28 17:48:37 +00:00
|
|
|
SaveLayerRec() {}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Sets fBounds, fPaint, and fSaveLayerFlags; sets fBackdrop to nullptr.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param bounds layer dimensions; may be nullptr
|
|
|
|
@param paint applied to layer when overlaying prior layer; may be nullptr
|
|
|
|
@param saveLayerFlags SaveLayerRec options to modify layer
|
2018-10-31 14:54:50 +00:00
|
|
|
@return SaveLayerRec with empty fBackdrop
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2015-12-18 15:09:18 +00:00
|
|
|
SaveLayerRec(const SkRect* bounds, const SkPaint* paint, SaveLayerFlags saveLayerFlags = 0)
|
|
|
|
: fBounds(bounds)
|
|
|
|
, fPaint(paint)
|
2016-01-07 19:28:08 +00:00
|
|
|
, fSaveLayerFlags(saveLayerFlags)
|
|
|
|
{}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Sets fBounds, fPaint, fBackdrop, and fSaveLayerFlags.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param bounds layer dimensions; may be nullptr
|
|
|
|
@param paint applied to layer when overlaying prior layer;
|
2017-09-01 17:49:54 +00:00
|
|
|
may be nullptr
|
2019-02-22 13:31:36 +00:00
|
|
|
@param backdrop If not null, this causes the current layer to be filtered by
|
|
|
|
backdrop, and then drawn into the new layer
|
|
|
|
(respecting the current clip).
|
|
|
|
If null, the new layer is initialized with transparent-black.
|
2017-09-21 16:28:43 +00:00
|
|
|
@param saveLayerFlags SaveLayerRec options to modify layer
|
2017-09-01 17:49:54 +00:00
|
|
|
@return SaveLayerRec fully specified
|
|
|
|
*/
|
2017-05-01 14:58:40 +00:00
|
|
|
SaveLayerRec(const SkRect* bounds, const SkPaint* paint, const SkImageFilter* backdrop,
|
|
|
|
SaveLayerFlags saveLayerFlags)
|
|
|
|
: fBounds(bounds)
|
|
|
|
, fPaint(paint)
|
|
|
|
, fBackdrop(backdrop)
|
|
|
|
, fSaveLayerFlags(saveLayerFlags)
|
|
|
|
{}
|
2017-05-01 21:34:14 +00:00
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** hints at layer size limit */
|
2017-09-01 17:49:54 +00:00
|
|
|
const SkRect* fBounds = nullptr;
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** modifies overlay */
|
2017-09-01 17:49:54 +00:00
|
|
|
const SkPaint* fPaint = nullptr;
|
|
|
|
|
2019-02-22 13:31:36 +00:00
|
|
|
/**
|
|
|
|
* If not null, this triggers the same initialization behavior as setting
|
|
|
|
* kInitWithPrevious_SaveLayerFlag on fSaveLayerFlags: the current layer is copied into
|
|
|
|
* the new layer, rather than initializing the new layer with transparent-black.
|
|
|
|
* This is then filtered by fBackdrop (respecting the current clip).
|
|
|
|
*/
|
2017-09-01 17:49:54 +00:00
|
|
|
const SkImageFilter* fBackdrop = nullptr;
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** preserves LCD text, creates with prior layer contents */
|
2017-09-01 17:49:54 +00:00
|
|
|
SaveLayerFlags fSaveLayerFlags = 0;
|
2015-12-18 15:09:18 +00:00
|
|
|
};
|
|
|
|
|
2018-06-27 18:46:46 +00:00
|
|
|
/** Saves SkMatrix and clip, and allocates SkBitmap for subsequent drawing.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-06-27 18:46:46 +00:00
|
|
|
Calling restore() discards changes to SkMatrix and clip,
|
2018-05-30 13:20:29 +00:00
|
|
|
and blends SkBitmap with alpha opacity onto the prior layer.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
SkMatrix may be changed by translate(), scale(), rotate(), skew(), concat(),
|
|
|
|
setMatrix(), and resetMatrix(). Clip may be changed by clipRect(), clipRRect(),
|
|
|
|
clipPath(), clipRegion().
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
SaveLayerRec contains the state used to create the layer.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
Call restoreToCount() with returned value to restore this and subsequent saves.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param layerRec layer state
|
2018-12-18 22:38:18 +00:00
|
|
|
@return depth of save state stack before this call was made.
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_saveLayer_3
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
int saveLayer(const SaveLayerRec& layerRec);
|
2015-12-18 15:09:18 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Removes changes to SkMatrix and clip since SkCanvas state was
|
|
|
|
last saved. The state is removed from the stack.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
Does nothing if the stack is empty.
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@AutoCanvasRestore_restore
|
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_restore
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-03-12 20:21:48 +00:00
|
|
|
void restore();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-06-27 18:46:46 +00:00
|
|
|
/** Returns the number of saved states, each containing: SkMatrix and clip.
|
2017-09-01 17:49:54 +00:00
|
|
|
Equals the number of save() calls less the number of restore() calls plus one.
|
|
|
|
The save count of a new canvas is one.
|
|
|
|
|
|
|
|
@return depth of save state stack
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_getSaveCount
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2012-02-24 21:54:07 +00:00
|
|
|
int getSaveCount() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-06-27 18:46:46 +00:00
|
|
|
/** Restores state to SkMatrix and clip values when save(), saveLayer(),
|
2017-09-01 17:49:54 +00:00
|
|
|
saveLayerPreserveLCDTextRequests(), or saveLayerAlpha() returned saveCount.
|
|
|
|
|
|
|
|
Does nothing if saveCount is greater than state stack count.
|
|
|
|
Restores state to initial values if saveCount is less than or equal to one.
|
|
|
|
|
|
|
|
@param saveCount depth of state stack to restore
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_restoreToCount
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void restoreToCount(int saveCount);
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Translates SkMatrix by dx along the x-axis and dy along the y-axis.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
Mathematically, replaces SkMatrix with a translation matrix
|
2017-09-01 17:49:54 +00:00
|
|
|
premultiplied with SkMatrix.
|
|
|
|
|
|
|
|
This has the effect of moving the drawing by (dx, dy) before transforming
|
|
|
|
the result with SkMatrix.
|
|
|
|
|
2018-10-31 14:54:50 +00:00
|
|
|
@param dx distance to translate on x-axis
|
|
|
|
@param dy distance to translate on y-axis
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_translate
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-03-18 12:51:48 +00:00
|
|
|
void translate(SkScalar dx, SkScalar dy);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Scales SkMatrix by sx on the x-axis and sy on the y-axis.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
Mathematically, replaces SkMatrix with a scale matrix
|
2017-09-01 17:49:54 +00:00
|
|
|
premultiplied with SkMatrix.
|
|
|
|
|
|
|
|
This has the effect of scaling the drawing by (sx, sy) before transforming
|
|
|
|
the result with SkMatrix.
|
|
|
|
|
2018-10-31 14:54:50 +00:00
|
|
|
@param sx amount to scale on x-axis
|
|
|
|
@param sy amount to scale on y-axis
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_scale
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-03-18 12:51:48 +00:00
|
|
|
void scale(SkScalar sx, SkScalar sy);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Rotates SkMatrix by degrees. Positive degrees rotates clockwise.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
Mathematically, replaces SkMatrix with a rotation matrix
|
2017-09-01 17:49:54 +00:00
|
|
|
premultiplied with SkMatrix.
|
|
|
|
|
|
|
|
This has the effect of rotating the drawing by degrees before transforming
|
|
|
|
the result with SkMatrix.
|
|
|
|
|
|
|
|
@param degrees amount to rotate, in degrees
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_rotate
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-03-18 12:51:48 +00:00
|
|
|
void rotate(SkScalar degrees);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Rotates SkMatrix by degrees about a point at (px, py). Positive degrees rotates
|
2017-09-21 16:28:43 +00:00
|
|
|
clockwise.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
Mathematically, constructs a rotation matrix; premultiplies the rotation matrix by
|
|
|
|
a translation matrix; then replaces SkMatrix with the resulting matrix
|
2017-09-01 17:49:54 +00:00
|
|
|
premultiplied with SkMatrix.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
This has the effect of rotating the drawing about a given point before
|
|
|
|
transforming the result with SkMatrix.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param degrees amount to rotate, in degrees
|
2018-06-14 17:21:08 +00:00
|
|
|
@param px x-axis value of the point to rotate about
|
|
|
|
@param py y-axis value of the point to rotate about
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_rotate_2
|
2016-07-12 22:01:19 +00:00
|
|
|
*/
|
|
|
|
void rotate(SkScalar degrees, SkScalar px, SkScalar py);
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Skews SkMatrix by sx on the x-axis and sy on the y-axis. A positive value of sx
|
2018-06-14 17:21:08 +00:00
|
|
|
skews the drawing right as y-axis values increase; a positive value of sy skews
|
|
|
|
the drawing down as x-axis values increase.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
Mathematically, replaces SkMatrix with a skew matrix premultiplied with SkMatrix.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
This has the effect of skewing the drawing by (sx, sy) before transforming
|
|
|
|
the result with SkMatrix.
|
|
|
|
|
2018-06-14 17:21:08 +00:00
|
|
|
@param sx amount to skew on x-axis
|
|
|
|
@param sy amount to skew on y-axis
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_skew
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-03-18 12:51:48 +00:00
|
|
|
void skew(SkScalar sx, SkScalar sy);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces SkMatrix with matrix premultiplied with existing SkMatrix.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
This has the effect of transforming the drawn geometry by matrix, before
|
|
|
|
transforming the result with existing SkMatrix.
|
|
|
|
|
|
|
|
@param matrix matrix to premultiply with existing SkMatrix
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_concat
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-03-18 12:51:48 +00:00
|
|
|
void concat(const SkMatrix& matrix);
|
2020-04-06 14:41:09 +00:00
|
|
|
void concat(const SkM44&);
|
|
|
|
|
2020-04-09 16:35:09 +00:00
|
|
|
/**
|
2020-04-24 16:02:25 +00:00
|
|
|
* Record a marker (provided by caller) for the current CTM. This does not change anything
|
|
|
|
* about the ctm or clip, but does "name" this matrix value, so it can be referenced by
|
|
|
|
* custom effects (who access it by specifying the same name).
|
2020-04-09 16:35:09 +00:00
|
|
|
*
|
2020-04-24 16:02:25 +00:00
|
|
|
* Within a save frame, marking with the same name more than once just replaces the previous
|
|
|
|
* value. However, between save frames, marking with the same name does not lose the marker
|
2020-04-09 16:35:09 +00:00
|
|
|
* in the previous save frame. It is "visible" when the current save() is balanced with
|
|
|
|
* a restore().
|
|
|
|
*/
|
2020-04-24 16:02:25 +00:00
|
|
|
void markCTM(const char* name);
|
2020-04-09 16:35:09 +00:00
|
|
|
|
2020-04-24 16:02:25 +00:00
|
|
|
bool findMarkedCTM(const char* name, SkM44*) const;
|
2020-04-09 16:35:09 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces SkMatrix with matrix.
|
2017-09-01 17:49:54 +00:00
|
|
|
Unlike concat(), any prior matrix state is overwritten.
|
|
|
|
|
|
|
|
@param matrix matrix to copy, replacing existing SkMatrix
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_setMatrix
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2020-11-25 18:37:30 +00:00
|
|
|
void setMatrix(const SkM44& matrix);
|
|
|
|
|
|
|
|
// DEPRECATED -- use SkM44 version
|
2014-03-13 20:03:58 +00:00
|
|
|
void setMatrix(const SkMatrix& matrix);
|
2011-01-11 18:32:13 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Sets SkMatrix to the identity matrix.
|
|
|
|
Any prior matrix state is overwritten.
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_resetMatrix
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void resetMatrix();
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection or difference of clip and rect,
|
2017-09-01 17:49:54 +00:00
|
|
|
with an aliased or anti-aliased clip edge. rect is transformed by SkMatrix
|
|
|
|
before it is combined with clip.
|
|
|
|
|
|
|
|
@param rect SkRect to combine with clip
|
|
|
|
@param op SkClipOp to apply to clip
|
|
|
|
@param doAntiAlias true if clip is to be anti-aliased
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_clipRect
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void clipRect(const SkRect& rect, SkClipOp op, bool doAntiAlias);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection or difference of clip and rect.
|
2017-09-01 17:49:54 +00:00
|
|
|
Resulting clip is aliased; pixels are fully contained by the clip.
|
|
|
|
rect is transformed by SkMatrix before it is combined with clip.
|
|
|
|
|
|
|
|
@param rect SkRect to combine with clip
|
|
|
|
@param op SkClipOp to apply to clip
|
|
|
|
*/
|
2016-12-09 14:00:50 +00:00
|
|
|
void clipRect(const SkRect& rect, SkClipOp op) {
|
2016-09-21 18:15:07 +00:00
|
|
|
this->clipRect(rect, op, false);
|
|
|
|
}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection of clip and rect.
|
2017-09-01 17:49:54 +00:00
|
|
|
Resulting clip is aliased; pixels are fully contained by the clip.
|
|
|
|
rect is transformed by SkMatrix
|
|
|
|
before it is combined with clip.
|
|
|
|
|
|
|
|
@param rect SkRect to combine with clip
|
|
|
|
@param doAntiAlias true if clip is to be anti-aliased
|
|
|
|
*/
|
2016-09-21 18:15:07 +00:00
|
|
|
void clipRect(const SkRect& rect, bool doAntiAlias = false) {
|
2016-12-14 19:00:03 +00:00
|
|
|
this->clipRect(rect, SkClipOp::kIntersect, doAntiAlias);
|
2016-09-21 18:15:07 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2021-01-24 13:57:23 +00:00
|
|
|
void clipIRect(const SkIRect& irect, SkClipOp op = SkClipOp::kIntersect) {
|
|
|
|
this->clipRect(SkRect::Make(irect), op, false);
|
|
|
|
}
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Sets the maximum clip rectangle, which can be set by clipRect(), clipRRect() and
|
|
|
|
clipPath() and intersect the current clip with the specified rect.
|
|
|
|
The maximum clip affects only future clipping operations; it is not retroactive.
|
|
|
|
The clip restriction is not recorded in pictures.
|
|
|
|
|
|
|
|
Pass an empty rect to disable maximum clip.
|
2018-05-30 13:20:29 +00:00
|
|
|
This private API is for use by Android framework only.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2020-06-25 20:19:03 +00:00
|
|
|
DEPRECATED: Replace usage with SkAndroidFrameworkUtils::replaceClip()
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param rect maximum allowed clip in device coordinates
|
|
|
|
*/
|
2016-12-12 22:39:55 +00:00
|
|
|
void androidFramework_setDeviceClipRestriction(const SkIRect& rect);
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection or difference of clip and rrect,
|
2017-09-01 17:49:54 +00:00
|
|
|
with an aliased or anti-aliased clip edge.
|
|
|
|
rrect is transformed by SkMatrix
|
|
|
|
before it is combined with clip.
|
|
|
|
|
|
|
|
@param rrect SkRRect to combine with clip
|
|
|
|
@param op SkClipOp to apply to clip
|
|
|
|
@param doAntiAlias true if clip is to be anti-aliased
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_clipRRect
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2016-12-09 14:00:50 +00:00
|
|
|
void clipRRect(const SkRRect& rrect, SkClipOp op, bool doAntiAlias);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection or difference of clip and rrect.
|
2017-09-01 17:49:54 +00:00
|
|
|
Resulting clip is aliased; pixels are fully contained by the clip.
|
|
|
|
rrect is transformed by SkMatrix before it is combined with clip.
|
|
|
|
|
|
|
|
@param rrect SkRRect to combine with clip
|
|
|
|
@param op SkClipOp to apply to clip
|
|
|
|
*/
|
2016-12-09 14:00:50 +00:00
|
|
|
void clipRRect(const SkRRect& rrect, SkClipOp op) {
|
2016-09-21 18:15:07 +00:00
|
|
|
this->clipRRect(rrect, op, false);
|
|
|
|
}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection of clip and rrect,
|
2017-09-01 17:49:54 +00:00
|
|
|
with an aliased or anti-aliased clip edge.
|
|
|
|
rrect is transformed by SkMatrix before it is combined with clip.
|
|
|
|
|
|
|
|
@param rrect SkRRect to combine with clip
|
|
|
|
@param doAntiAlias true if clip is to be anti-aliased
|
|
|
|
*/
|
2016-09-21 18:15:07 +00:00
|
|
|
void clipRRect(const SkRRect& rrect, bool doAntiAlias = false) {
|
2016-12-14 19:00:03 +00:00
|
|
|
this->clipRRect(rrect, SkClipOp::kIntersect, doAntiAlias);
|
2016-09-21 18:15:07 +00:00
|
|
|
}
|
2012-12-12 20:48:18 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection or difference of clip and path,
|
2017-09-01 17:49:54 +00:00
|
|
|
with an aliased or anti-aliased clip edge. SkPath::FillType determines if path
|
|
|
|
describes the area inside or outside its contours; and if path contour overlaps
|
|
|
|
itself or another path contour, whether the overlaps form part of the area.
|
|
|
|
path is transformed by SkMatrix before it is combined with clip.
|
|
|
|
|
|
|
|
@param path SkPath to combine with clip
|
|
|
|
@param op SkClipOp to apply to clip
|
|
|
|
@param doAntiAlias true if clip is to be anti-aliased
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_clipPath
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2016-12-09 14:00:50 +00:00
|
|
|
void clipPath(const SkPath& path, SkClipOp op, bool doAntiAlias);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection or difference of clip and path.
|
2017-09-01 17:49:54 +00:00
|
|
|
Resulting clip is aliased; pixels are fully contained by the clip.
|
|
|
|
SkPath::FillType determines if path
|
|
|
|
describes the area inside or outside its contours; and if path contour overlaps
|
|
|
|
itself or another path contour, whether the overlaps form part of the area.
|
|
|
|
path is transformed by SkMatrix
|
|
|
|
before it is combined with clip.
|
|
|
|
|
|
|
|
@param path SkPath to combine with clip
|
|
|
|
@param op SkClipOp to apply to clip
|
|
|
|
*/
|
2016-12-09 14:00:50 +00:00
|
|
|
void clipPath(const SkPath& path, SkClipOp op) {
|
2016-09-21 18:15:07 +00:00
|
|
|
this->clipPath(path, op, false);
|
|
|
|
}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection of clip and path.
|
2017-09-01 17:49:54 +00:00
|
|
|
Resulting clip is aliased; pixels are fully contained by the clip.
|
|
|
|
SkPath::FillType determines if path
|
|
|
|
describes the area inside or outside its contours; and if path contour overlaps
|
|
|
|
itself or another path contour, whether the overlaps form part of the area.
|
|
|
|
path is transformed by SkMatrix before it is combined with clip.
|
|
|
|
|
|
|
|
@param path SkPath to combine with clip
|
|
|
|
@param doAntiAlias true if clip is to be anti-aliased
|
|
|
|
*/
|
2016-09-21 18:15:07 +00:00
|
|
|
void clipPath(const SkPath& path, bool doAntiAlias = false) {
|
2016-12-14 19:00:03 +00:00
|
|
|
this->clipPath(path, SkClipOp::kIntersect, doAntiAlias);
|
2016-09-21 18:15:07 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2020-03-10 18:02:56 +00:00
|
|
|
void clipShader(sk_sp<SkShader>, SkClipOp = SkClipOp::kIntersect);
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Replaces clip with the intersection or difference of clip and SkRegion deviceRgn.
|
2017-09-01 17:49:54 +00:00
|
|
|
Resulting clip is aliased; pixels are fully contained by the clip.
|
|
|
|
deviceRgn is unaffected by SkMatrix.
|
|
|
|
|
|
|
|
@param deviceRgn SkRegion to combine with clip
|
|
|
|
@param op SkClipOp to apply to clip
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_clipRegion
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2016-12-14 19:00:03 +00:00
|
|
|
void clipRegion(const SkRegion& deviceRgn, SkClipOp op = SkClipOp::kIntersect);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns true if SkRect rect, transformed by SkMatrix, can be quickly determined to be
|
2017-09-01 17:49:54 +00:00
|
|
|
outside of clip. May return false even though rect is outside of clip.
|
|
|
|
|
|
|
|
Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.
|
|
|
|
|
|
|
|
@param rect SkRect to compare with clip
|
|
|
|
@return true if rect, transformed by SkMatrix, does not intersect clip
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_quickReject
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2012-08-16 20:53:31 +00:00
|
|
|
bool quickReject(const SkRect& rect) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns true if path, transformed by SkMatrix, can be quickly determined to be
|
2017-09-01 17:49:54 +00:00
|
|
|
outside of clip. May return false even though path is outside of clip.
|
|
|
|
|
|
|
|
Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.
|
|
|
|
|
|
|
|
@param path SkPath to compare with clip
|
|
|
|
@return true if path, transformed by SkMatrix, does not intersect clip
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_quickReject_2
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2012-08-16 20:53:31 +00:00
|
|
|
bool quickReject(const SkPath& path) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns bounds of clip, transformed by inverse of SkMatrix. If clip is empty,
|
2017-09-01 17:49:54 +00:00
|
|
|
return SkRect::MakeEmpty, where all SkRect sides equal zero.
|
|
|
|
|
|
|
|
SkRect returned is outset by one to account for partial pixel coverage if clip
|
|
|
|
is anti-aliased.
|
|
|
|
|
|
|
|
@return bounds of clip in local coordinates
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_getLocalClipBounds
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-11-28 22:08:45 +00:00
|
|
|
SkRect getLocalClipBounds() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns bounds of clip, transformed by inverse of SkMatrix. If clip is empty,
|
2017-09-01 17:49:54 +00:00
|
|
|
return false, and set bounds to SkRect::MakeEmpty, where all SkRect sides equal zero.
|
|
|
|
|
|
|
|
bounds is outset by one to account for partial pixel coverage if clip
|
|
|
|
is anti-aliased.
|
|
|
|
|
|
|
|
@param bounds SkRect of clip in local coordinates
|
|
|
|
@return true if clip bounds is not empty
|
|
|
|
*/
|
2017-01-24 14:13:40 +00:00
|
|
|
bool getLocalClipBounds(SkRect* bounds) const {
|
2017-11-28 22:08:45 +00:00
|
|
|
*bounds = this->getLocalClipBounds();
|
2017-01-24 14:13:40 +00:00
|
|
|
return !bounds->isEmpty();
|
|
|
|
}
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns SkIRect bounds of clip, unaffected by SkMatrix. If clip is empty,
|
2017-09-01 17:49:54 +00:00
|
|
|
return SkRect::MakeEmpty, where all SkRect sides equal zero.
|
|
|
|
|
|
|
|
Unlike getLocalClipBounds(), returned SkIRect is not outset.
|
|
|
|
|
|
|
|
@return bounds of clip in SkBaseDevice coordinates
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_getDeviceClipBounds
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-11-28 22:08:45 +00:00
|
|
|
SkIRect getDeviceClipBounds() const;
|
2017-01-23 19:09:13 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns SkIRect bounds of clip, unaffected by SkMatrix. If clip is empty,
|
2017-09-01 17:49:54 +00:00
|
|
|
return false, and set bounds to SkRect::MakeEmpty, where all SkRect sides equal zero.
|
|
|
|
|
|
|
|
Unlike getLocalClipBounds(), bounds is not outset.
|
|
|
|
|
|
|
|
@param bounds SkRect of clip in device coordinates
|
|
|
|
@return true if clip bounds is not empty
|
|
|
|
*/
|
2017-01-24 14:13:40 +00:00
|
|
|
bool getDeviceClipBounds(SkIRect* bounds) const {
|
2017-11-28 22:08:45 +00:00
|
|
|
*bounds = this->getDeviceClipBounds();
|
2017-01-24 14:13:40 +00:00
|
|
|
return !bounds->isEmpty();
|
|
|
|
}
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Fills clip with color color.
|
2017-09-01 17:49:54 +00:00
|
|
|
mode determines how ARGB is combined with destination.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param color unpremultiplied ARGB
|
2017-09-01 17:49:54 +00:00
|
|
|
@param mode SkBlendMode used to combine source color and destination
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawColor
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2020-06-03 15:19:49 +00:00
|
|
|
void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver) {
|
|
|
|
this->drawColor(SkColor4f::FromColor(color), mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Fills clip with color color.
|
|
|
|
mode determines how ARGB is combined with destination.
|
|
|
|
|
|
|
|
@param color SkColor4f representing unpremultiplied color.
|
|
|
|
@param mode SkBlendMode used to combine source color and destination
|
|
|
|
*/
|
|
|
|
void drawColor(const SkColor4f& color, SkBlendMode mode = SkBlendMode::kSrcOver);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Fills clip with color color using SkBlendMode::kSrc.
|
2017-09-01 17:49:54 +00:00
|
|
|
This has the effect of replacing all pixels contained by clip with color.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param color unpremultiplied ARGB
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2014-12-06 04:49:03 +00:00
|
|
|
void clear(SkColor color) {
|
2020-06-03 15:19:49 +00:00
|
|
|
this->clear(SkColor4f::FromColor(color));
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Fills clip with color color using SkBlendMode::kSrc.
|
|
|
|
This has the effect of replacing all pixels contained by clip with color.
|
|
|
|
|
|
|
|
@param color SkColor4f representing unpremultiplied color.
|
|
|
|
*/
|
|
|
|
void clear(const SkColor4f& color) {
|
2016-10-06 00:33:02 +00:00
|
|
|
this->drawColor(color, SkBlendMode::kSrc);
|
2014-12-04 15:50:14 +00:00
|
|
|
}
|
2011-04-14 18:59:28 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Makes SkCanvas contents undefined. Subsequent calls that read SkCanvas pixels,
|
2017-09-01 17:49:54 +00:00
|
|
|
such as drawing with SkBlendMode, return undefined results. discard() does
|
|
|
|
not change clip or SkMatrix.
|
|
|
|
|
|
|
|
discard() may do nothing, depending on the implementation of SkSurface or SkBaseDevice
|
|
|
|
that created SkCanvas.
|
|
|
|
|
|
|
|
discard() allows optimized performance on subsequent draws by removing
|
|
|
|
cached data associated with SkSurface or SkBaseDevice.
|
|
|
|
It is not necessary to call discard() once done with SkCanvas;
|
|
|
|
any cached data is deleted when owning SkSurface or SkBaseDevice is deleted.
|
|
|
|
*/
|
2014-03-28 16:08:05 +00:00
|
|
|
void discard() { this->onDiscard(); }
|
|
|
|
|
2020-10-20 18:50:06 +00:00
|
|
|
/** Fills clip with SkPaint paint. SkPaint components, SkShader,
|
2017-09-01 17:49:54 +00:00
|
|
|
SkColorFilter, SkImageFilter, and SkBlendMode affect drawing;
|
2020-10-20 18:50:06 +00:00
|
|
|
SkMaskFilter and SkPathEffect in paint are ignored.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param paint graphics state used to fill SkCanvas
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawPaint
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2015-01-09 22:17:40 +00:00
|
|
|
void drawPaint(const SkPaint& paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \enum SkCanvas::PointMode
|
|
|
|
Selects if an array of points are drawn as discrete points, as lines, or as
|
|
|
|
an open polygon.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
enum PointMode {
|
2018-05-30 13:20:29 +00:00
|
|
|
kPoints_PointMode, //!< draw each point separately
|
|
|
|
kLines_PointMode, //!< draw each pair of points as a line segment
|
|
|
|
kPolygon_PointMode, //!< draw the array of points as a open polygon
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws pts using clip, SkMatrix and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
count is the number of points; if count is less than one, has no effect.
|
|
|
|
mode may be one of: kPoints_PointMode, kLines_PointMode, or kPolygon_PointMode.
|
|
|
|
|
|
|
|
If mode is kPoints_PointMode, the shape of point drawn depends on paint
|
|
|
|
SkPaint::Cap. If paint is set to SkPaint::kRound_Cap, each point draws a
|
|
|
|
circle of diameter SkPaint stroke width. If paint is set to SkPaint::kSquare_Cap
|
|
|
|
or SkPaint::kButt_Cap, each point draws a square of width and height
|
|
|
|
SkPaint stroke width.
|
|
|
|
|
|
|
|
If mode is kLines_PointMode, each pair of points draws a line segment.
|
|
|
|
One line is drawn for every two points; each point is used once. If count is odd,
|
|
|
|
the final point is ignored.
|
|
|
|
|
|
|
|
If mode is kPolygon_PointMode, each adjacent pair of points draws a line segment.
|
|
|
|
count minus one lines are drawn; the first and last point are used once.
|
|
|
|
|
|
|
|
Each line segment respects paint SkPaint::Cap and SkPaint stroke width.
|
|
|
|
SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
|
|
|
|
|
|
|
|
Always draws each element one at a time; is not affected by
|
|
|
|
SkPaint::Join, and unlike drawPath(), does not create a mask from all points
|
|
|
|
and lines before drawing.
|
|
|
|
|
|
|
|
@param mode whether pts draws points or lines
|
|
|
|
@param count number of points in the array
|
|
|
|
@param pts array of points to draw
|
|
|
|
@param paint stroke, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawPoints
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2015-01-09 22:17:40 +00:00
|
|
|
void drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws point at (x, y) using clip, SkMatrix and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
The shape of point drawn depends on paint SkPaint::Cap.
|
|
|
|
If paint is set to SkPaint::kRound_Cap, draw a circle of diameter
|
|
|
|
SkPaint stroke width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap,
|
|
|
|
draw a square of width and height SkPaint stroke width.
|
|
|
|
SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
|
|
|
|
|
|
|
|
@param x left edge of circle or square
|
|
|
|
@param y top edge of circle or square
|
|
|
|
@param paint stroke, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawPoint
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws point p using clip, SkMatrix and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
The shape of point drawn depends on paint SkPaint::Cap.
|
|
|
|
If paint is set to SkPaint::kRound_Cap, draw a circle of diameter
|
|
|
|
SkPaint stroke width. If paint is set to SkPaint::kSquare_Cap or SkPaint::kButt_Cap,
|
|
|
|
draw a square of width and height SkPaint stroke width.
|
|
|
|
SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
|
|
|
|
|
|
|
|
@param p top-left edge of circle or square
|
|
|
|
@param paint stroke, blend, color, and so on, used to draw
|
|
|
|
*/
|
2017-05-15 17:35:35 +00:00
|
|
|
void drawPoint(SkPoint p, const SkPaint& paint) {
|
|
|
|
this->drawPoint(p.x(), p.y(), paint);
|
|
|
|
}
|
2011-01-11 18:32:13 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Draws line segment from (x0, y0) to (x1, y1) using clip, SkMatrix, and SkPaint paint.
|
|
|
|
In paint: SkPaint stroke width describes the line thickness;
|
|
|
|
SkPaint::Cap draws the end rounded or square;
|
|
|
|
SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
|
|
|
|
|
|
|
|
@param x0 start of line segment on x-axis
|
|
|
|
@param y0 start of line segment on y-axis
|
|
|
|
@param x1 end of line segment on x-axis
|
|
|
|
@param y1 end of line segment on y-axis
|
|
|
|
@param paint stroke, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawLine
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2017-02-22 18:21:42 +00:00
|
|
|
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint& paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
/** Draws line segment from p0 to p1 using clip, SkMatrix, and SkPaint paint.
|
|
|
|
In paint: SkPaint stroke width describes the line thickness;
|
|
|
|
SkPaint::Cap draws the end rounded or square;
|
|
|
|
SkPaint::Style is ignored, as if were set to SkPaint::kStroke_Style.
|
|
|
|
|
|
|
|
@param p0 start of line segment
|
|
|
|
@param p1 end of line segment
|
|
|
|
@param paint stroke, blend, color, and so on, used to draw
|
|
|
|
*/
|
2017-05-15 17:35:35 +00:00
|
|
|
void drawLine(SkPoint p0, SkPoint p1, const SkPaint& paint) {
|
|
|
|
this->drawLine(p0.x(), p0.y(), p1.x(), p1.y(), paint);
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkRect rect using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
In paint: SkPaint::Style determines if rectangle is stroked or filled;
|
|
|
|
if stroked, SkPaint stroke width describes the line thickness, and
|
|
|
|
SkPaint::Join draws the corners rounded or square.
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
@param rect rectangle to draw
|
2017-09-01 17:49:54 +00:00
|
|
|
@param paint stroke or fill, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawRect
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2015-01-09 22:17:40 +00:00
|
|
|
void drawRect(const SkRect& rect, const SkPaint& paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkIRect rect using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
In paint: SkPaint::Style determines if rectangle is stroked or filled;
|
|
|
|
if stroked, SkPaint stroke width describes the line thickness, and
|
|
|
|
SkPaint::Join draws the corners rounded or square.
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
@param rect rectangle to draw
|
2017-09-01 17:49:54 +00:00
|
|
|
@param paint stroke or fill, blend, color, and so on, used to draw
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-02-17 16:28:05 +00:00
|
|
|
void drawIRect(const SkIRect& rect, const SkPaint& paint) {
|
2008-12-17 15:59:43 +00:00
|
|
|
SkRect r;
|
|
|
|
r.set(rect); // promotes the ints to scalars
|
|
|
|
this->drawRect(r, paint);
|
|
|
|
}
|
2011-01-11 18:32:13 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkRegion region using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
In paint: SkPaint::Style determines if rectangle is stroked or filled;
|
|
|
|
if stroked, SkPaint stroke width describes the line thickness, and
|
|
|
|
SkPaint::Join draws the corners rounded or square.
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
@param region region to draw
|
2017-09-01 17:49:54 +00:00
|
|
|
@param paint SkPaint stroke or fill, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawRegion
|
2016-08-25 20:54:30 +00:00
|
|
|
*/
|
2016-08-26 13:37:45 +00:00
|
|
|
void drawRegion(const SkRegion& region, const SkPaint& paint);
|
2016-08-25 20:54:30 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws oval oval using clip, SkMatrix, and SkPaint.
|
2017-09-01 17:49:54 +00:00
|
|
|
In paint: SkPaint::Style determines if oval is stroked or filled;
|
|
|
|
if stroked, SkPaint stroke width describes the line thickness.
|
|
|
|
|
|
|
|
@param oval SkRect bounds of oval
|
|
|
|
@param paint SkPaint stroke or fill, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawOval
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2017-05-13 17:35:35 +00:00
|
|
|
void drawOval(const SkRect& oval, const SkPaint& paint);
|
2012-12-12 20:48:18 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkRRect rrect using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
In paint: SkPaint::Style determines if rrect is stroked or filled;
|
|
|
|
if stroked, SkPaint stroke width describes the line thickness.
|
|
|
|
|
|
|
|
rrect may represent a rectangle, circle, oval, uniformly rounded rectangle, or
|
|
|
|
may have any combination of positive non-square radii for the four corners.
|
|
|
|
|
|
|
|
@param rrect SkRRect with up to eight corner radii to draw
|
|
|
|
@param paint SkPaint stroke or fill, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawRRect
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2015-01-09 22:17:40 +00:00
|
|
|
void drawRRect(const SkRRect& rrect, const SkPaint& paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkRRect outer and inner
|
2017-09-01 17:49:54 +00:00
|
|
|
using clip, SkMatrix, and SkPaint paint.
|
|
|
|
outer must contain inner or the drawing is undefined.
|
|
|
|
In paint: SkPaint::Style determines if SkRRect is stroked or filled;
|
|
|
|
if stroked, SkPaint stroke width describes the line thickness.
|
|
|
|
If stroked and SkRRect corner has zero length radii, SkPaint::Join can
|
|
|
|
draw corners rounded or square.
|
|
|
|
|
|
|
|
GPU-backed platforms optimize drawing when both outer and inner are
|
|
|
|
concave and outer contains inner. These platforms may not be able to draw
|
|
|
|
SkPath built with identical data as fast.
|
|
|
|
|
|
|
|
@param outer SkRRect outer bounds to draw
|
|
|
|
@param inner SkRRect inner bounds to draw
|
|
|
|
@param paint SkPaint stroke or fill, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawDRRect_a
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawDRRect_b
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-13 17:35:35 +00:00
|
|
|
void drawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint);
|
2014-02-21 02:32:36 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws circle at (cx, cy) with radius using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
If radius is zero or less, nothing is drawn.
|
|
|
|
In paint: SkPaint::Style determines if circle is stroked or filled;
|
|
|
|
if stroked, SkPaint stroke width describes the line thickness.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param cx circle center on the x-axis
|
|
|
|
@param cy circle center on the y-axis
|
2017-09-01 17:49:54 +00:00
|
|
|
@param radius half the diameter of circle
|
|
|
|
@param paint SkPaint stroke or fill, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawCircle
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2017-02-22 18:21:42 +00:00
|
|
|
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws circle at center with radius using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
If radius is zero or less, nothing is drawn.
|
|
|
|
In paint: SkPaint::Style determines if circle is stroked or filled;
|
|
|
|
if stroked, SkPaint stroke width describes the line thickness.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param center circle center
|
2017-09-01 17:49:54 +00:00
|
|
|
@param radius half the diameter of circle
|
|
|
|
@param paint SkPaint stroke or fill, blend, color, and so on, used to draw
|
|
|
|
*/
|
2017-05-15 17:35:35 +00:00
|
|
|
void drawCircle(SkPoint center, SkScalar radius, const SkPaint& paint) {
|
|
|
|
this->drawCircle(center.x(), center.y(), radius, paint);
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws arc using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus
|
|
|
|
sweepAngle. startAngle and sweepAngle are in degrees.
|
|
|
|
|
|
|
|
startAngle of zero places start point at the right middle edge of oval.
|
|
|
|
A positive sweepAngle places arc end point clockwise from start point;
|
|
|
|
a negative sweepAngle places arc end point counterclockwise from start point.
|
|
|
|
sweepAngle may exceed 360 degrees, a full circle.
|
|
|
|
If useCenter is true, draw a wedge that includes lines from oval
|
|
|
|
center to arc end points. If useCenter is false, draw arc between end points.
|
|
|
|
|
|
|
|
If SkRect oval is empty or sweepAngle is zero, nothing is drawn.
|
|
|
|
|
|
|
|
@param oval SkRect bounds of oval containing arc to draw
|
|
|
|
@param startAngle angle in degrees where arc begins
|
|
|
|
@param sweepAngle sweep angle in degrees; positive is clockwise
|
|
|
|
@param useCenter if true, include the center of the oval
|
|
|
|
@param paint SkPaint stroke or fill, blend, color, and so on, used to draw
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void drawArc(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle,
|
|
|
|
bool useCenter, const SkPaint& paint);
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkRRect bounded by SkRect rect, with corner radii (rx, ry) using clip,
|
2017-09-01 17:49:54 +00:00
|
|
|
SkMatrix, and SkPaint paint.
|
|
|
|
|
|
|
|
In paint: SkPaint::Style determines if SkRRect is stroked or filled;
|
|
|
|
if stroked, SkPaint stroke width describes the line thickness.
|
|
|
|
If rx or ry are less than zero, they are treated as if they are zero.
|
|
|
|
If rx plus ry exceeds rect width or rect height, radii are scaled down to fit.
|
|
|
|
If rx and ry are zero, SkRRect is drawn as SkRect and if stroked is affected by
|
|
|
|
SkPaint::Join.
|
|
|
|
|
|
|
|
@param rect SkRect bounds of SkRRect to draw
|
2018-06-14 17:21:08 +00:00
|
|
|
@param rx axis length on x-axis of oval describing rounded corners
|
|
|
|
@param ry axis length on y-axis of oval describing rounded corners
|
2017-09-01 17:49:54 +00:00
|
|
|
@param paint stroke, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawRoundRect
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2017-02-22 18:21:42 +00:00
|
|
|
void drawRoundRect(const SkRect& rect, SkScalar rx, SkScalar ry, const SkPaint& paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkPath path using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
SkPath contains an array of path contour, each of which may be open or closed.
|
|
|
|
|
|
|
|
In paint: SkPaint::Style determines if SkRRect is stroked or filled:
|
|
|
|
if filled, SkPath::FillType determines whether path contour describes inside or
|
|
|
|
outside of fill; if stroked, SkPaint stroke width describes the line thickness,
|
|
|
|
SkPaint::Cap describes line ends, and SkPaint::Join describes how
|
|
|
|
corners are drawn.
|
|
|
|
|
|
|
|
@param path SkPath to draw
|
|
|
|
@param paint stroke, blend, color, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawPath
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2015-01-09 22:17:40 +00:00
|
|
|
void drawPath(const SkPath& path, const SkPaint& paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2021-01-19 22:58:25 +00:00
|
|
|
void drawImage(const SkImage* image, SkScalar left, SkScalar top) {
|
|
|
|
this->drawImage(image, left, top, SkSamplingOptions(), nullptr);
|
|
|
|
}
|
|
|
|
void drawImage(const sk_sp<SkImage>& image, SkScalar left, SkScalar top) {
|
|
|
|
this->drawImage(image.get(), left, top, SkSamplingOptions(), nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkImage image, with its top-left corner at (left, top),
|
2017-09-01 17:49:54 +00:00
|
|
|
using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2019-02-11 16:09:15 +00:00
|
|
|
This is equivalent to drawImageRect() using a dst rect at (x,y) with the
|
|
|
|
same width and height of the image.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param image uncompressed rectangular map of pixels
|
|
|
|
@param left left side of image
|
|
|
|
@param top top side of image
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
*/
|
2017-08-28 14:34:05 +00:00
|
|
|
void drawImage(const SkImage* image, SkScalar left, SkScalar top,
|
2021-01-19 22:58:25 +00:00
|
|
|
const SkPaint* paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkImage image, with its top-left corner at (left, top),
|
2017-09-01 17:49:54 +00:00
|
|
|
using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2019-02-11 16:09:15 +00:00
|
|
|
This is equivalent to drawImageRect() using a dst rect at (x,y) with the
|
|
|
|
same width and height of the image.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param image uncompressed rectangular map of pixels
|
|
|
|
@param left left side of image
|
|
|
|
@param top pop side of image
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
*/
|
2016-03-17 15:14:57 +00:00
|
|
|
void drawImage(const sk_sp<SkImage>& image, SkScalar left, SkScalar top,
|
2021-01-19 22:58:25 +00:00
|
|
|
const SkPaint* paint) {
|
2016-03-17 15:14:57 +00:00
|
|
|
this->drawImage(image.get(), left, top, paint);
|
|
|
|
}
|
2021-01-19 22:58:25 +00:00
|
|
|
#endif
|
2014-09-24 20:03:30 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \enum SkCanvas::SrcRectConstraint
|
|
|
|
SrcRectConstraint controls the behavior at the edge of source SkRect,
|
|
|
|
provided to drawImageRect(), trading off speed for precision.
|
|
|
|
|
2018-10-26 20:15:46 +00:00
|
|
|
SkFilterQuality in SkPaint may sample multiple pixels in the image. Source SkRect
|
|
|
|
restricts the bounds of pixels that may be read. SkFilterQuality may slow down if
|
2017-09-01 17:49:54 +00:00
|
|
|
it cannot read outside the bounds, when sampling near the edge of source SkRect.
|
|
|
|
SrcRectConstraint specifies whether an SkImageFilter is allowed to read pixels
|
|
|
|
outside source SkRect.
|
|
|
|
*/
|
2015-07-14 17:54:12 +00:00
|
|
|
enum SrcRectConstraint {
|
2018-05-30 13:20:29 +00:00
|
|
|
kStrict_SrcRectConstraint, //!< sample only inside bounds; slower
|
|
|
|
kFast_SrcRectConstraint, //!< sample outside bounds; faster
|
2015-07-14 17:54:12 +00:00
|
|
|
};
|
|
|
|
|
2021-01-19 22:58:25 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_DRAWIMAGE_NOSAMPLING
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkRect src of SkImage image, scaled and translated to fill SkRect dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from image bounds.
|
|
|
|
|
|
|
|
If generated mask extends beyond image bounds, replicate image edge colors, just
|
|
|
|
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
|
2017-10-30 15:48:35 +00:00
|
|
|
replicates the image edge color when it samples outside of its bounds.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2019-02-11 16:09:15 +00:00
|
|
|
When using a shader or shader mask filter, its coordinate system is based on the
|
|
|
|
current CTM, so will reflect the dst rect geometry and is equivalent to
|
|
|
|
drawRect(dst). The src rect is only used to access the provided image.
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
|
|
|
|
sample within src; set to kFast_SrcRectConstraint allows sampling outside to
|
|
|
|
improve performance.
|
|
|
|
|
|
|
|
@param image SkImage containing pixels, dimensions, and format
|
|
|
|
@param src source SkRect of image to draw from
|
|
|
|
@param dst destination SkRect of image to draw to
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
@param constraint filter strictly within src or draw faster
|
|
|
|
*/
|
2015-08-06 17:02:53 +00:00
|
|
|
void drawImageRect(const SkImage* image, const SkRect& src, const SkRect& dst,
|
|
|
|
const SkPaint* paint,
|
|
|
|
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkIRect isrc of SkImage image, scaled and translated to fill SkRect dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
Note that isrc is on integer pixel boundaries; dst may include fractional
|
|
|
|
boundaries. Additionally transform draw using clip, SkMatrix, and optional SkPaint
|
|
|
|
paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from image bounds.
|
|
|
|
|
|
|
|
If generated mask extends beyond image bounds, replicate image edge colors, just
|
|
|
|
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
|
2017-10-30 15:48:35 +00:00
|
|
|
replicates the image edge color when it samples outside of its bounds.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2019-02-11 16:09:15 +00:00
|
|
|
When using a shader or shader mask filter, its coordinate system is based on the
|
|
|
|
current CTM, so will reflect the dst rect geometry and is equivalent to
|
|
|
|
drawRect(dst). The src rect is only used to access the provided image.
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
|
|
|
|
sample within isrc; set to kFast_SrcRectConstraint allows sampling outside to
|
|
|
|
improve performance.
|
|
|
|
|
|
|
|
@param image SkImage containing pixels, dimensions, and format
|
|
|
|
@param isrc source SkIRect of image to draw from
|
|
|
|
@param dst destination SkRect of image to draw to
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
@param constraint filter strictly within isrc or draw faster
|
|
|
|
*/
|
2015-08-06 17:02:53 +00:00
|
|
|
void drawImageRect(const SkImage* image, const SkIRect& isrc, const SkRect& dst,
|
2017-05-10 13:07:42 +00:00
|
|
|
const SkPaint* paint,
|
|
|
|
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkImage image, scaled and translated to fill SkRect dst, using clip, SkMatrix,
|
2017-09-01 17:49:54 +00:00
|
|
|
and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from image bounds.
|
|
|
|
|
|
|
|
If generated mask extends beyond image bounds, replicate image edge colors, just
|
|
|
|
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
|
2017-10-30 15:48:35 +00:00
|
|
|
replicates the image edge color when it samples outside of its bounds.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2019-02-11 16:09:15 +00:00
|
|
|
When using a shader or shader mask filter, its coordinate system is based on the
|
|
|
|
current CTM, so will reflect the dst rect geometry and is equivalent to
|
|
|
|
drawRect(dst).
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param image SkImage containing pixels, dimensions, and format
|
|
|
|
@param dst destination SkRect of image to draw to
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawImageRect_3
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2018-10-26 20:15:46 +00:00
|
|
|
void drawImageRect(const SkImage* image, const SkRect& dst, const SkPaint* paint);
|
2015-07-17 14:09:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkRect src of SkImage image, scaled and translated to fill SkRect dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from image bounds.
|
|
|
|
|
|
|
|
If generated mask extends beyond image bounds, replicate image edge colors, just
|
|
|
|
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
|
2017-10-30 15:48:35 +00:00
|
|
|
replicates the image edge color when it samples outside of its bounds.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2019-02-11 16:09:15 +00:00
|
|
|
When using a shader or shader mask filter, its coordinate system is based on the
|
|
|
|
current CTM, so will reflect the dst rect geometry and is equivalent to
|
|
|
|
drawRect(dst). The src rect is only used to access the provided image.
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param image SkImage containing pixels, dimensions, and format
|
|
|
|
@param src source SkRect of image to draw from
|
|
|
|
@param dst destination SkRect of image to draw to
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
@param constraint filter strictly within src or draw faster
|
|
|
|
*/
|
2016-03-17 15:14:57 +00:00
|
|
|
void drawImageRect(const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst,
|
|
|
|
const SkPaint* paint,
|
|
|
|
SrcRectConstraint constraint = kStrict_SrcRectConstraint) {
|
|
|
|
this->drawImageRect(image.get(), src, dst, paint, constraint);
|
|
|
|
}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkIRect isrc of SkImage image, scaled and translated to fill SkRect dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
isrc is on integer pixel boundaries; dst may include fractional boundaries.
|
|
|
|
Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from image bounds.
|
|
|
|
|
|
|
|
If generated mask extends beyond image bounds, replicate image edge colors, just
|
|
|
|
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
|
2017-10-30 15:48:35 +00:00
|
|
|
replicates the image edge color when it samples outside of its bounds.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2019-02-11 16:09:15 +00:00
|
|
|
When using a shader or shader mask filter, its coordinate system is based on the
|
|
|
|
current CTM, so will reflect the dst rect geometry and is equivalent to
|
|
|
|
drawRect(dst). The src rect is only used to access the provided image.
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
|
|
|
|
sample within image; set to kFast_SrcRectConstraint allows sampling outside to
|
|
|
|
improve performance.
|
|
|
|
|
|
|
|
@param image SkImage containing pixels, dimensions, and format
|
|
|
|
@param isrc source SkIRect of image to draw from
|
|
|
|
@param dst destination SkRect of image to draw to
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
@param constraint filter strictly within image or draw faster
|
|
|
|
*/
|
2016-03-17 15:14:57 +00:00
|
|
|
void drawImageRect(const sk_sp<SkImage>& image, const SkIRect& isrc, const SkRect& dst,
|
2017-10-09 19:45:33 +00:00
|
|
|
const SkPaint* paint,
|
2017-05-10 13:07:42 +00:00
|
|
|
SrcRectConstraint constraint = kStrict_SrcRectConstraint) {
|
|
|
|
this->drawImageRect(image.get(), isrc, dst, paint, constraint);
|
2016-03-17 15:14:57 +00:00
|
|
|
}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkImage image, scaled and translated to fill SkRect dst,
|
2017-09-01 17:49:54 +00:00
|
|
|
using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from image bounds.
|
|
|
|
|
|
|
|
If generated mask extends beyond image bounds, replicate image edge colors, just
|
|
|
|
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
|
2017-10-30 15:48:35 +00:00
|
|
|
replicates the image edge color when it samples outside of its bounds.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2019-02-11 16:09:15 +00:00
|
|
|
When using a shader or shader mask filter, its coordinate system is based on the
|
|
|
|
current CTM, so will reflect the dst rect geometry and is equivalent to
|
|
|
|
drawRect(dst).
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param image SkImage containing pixels, dimensions, and format
|
|
|
|
@param dst destination SkRect of image to draw to
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
*/
|
2018-10-26 20:15:46 +00:00
|
|
|
void drawImageRect(const sk_sp<SkImage>& image, const SkRect& dst, const SkPaint* paint) {
|
|
|
|
this->drawImageRect(image.get(), dst, paint);
|
2016-03-17 15:14:57 +00:00
|
|
|
}
|
2021-01-19 22:58:25 +00:00
|
|
|
#endif
|
2016-03-17 15:14:57 +00:00
|
|
|
|
2020-12-07 17:29:18 +00:00
|
|
|
void drawImage(const SkImage*, SkScalar x, SkScalar y, const SkSamplingOptions&,
|
|
|
|
const SkPaint* = nullptr);
|
2021-01-22 03:25:21 +00:00
|
|
|
void drawImage(const sk_sp<SkImage>& image, SkScalar x, SkScalar y,
|
|
|
|
const SkSamplingOptions& sampling, const SkPaint* paint = nullptr) {
|
|
|
|
this->drawImage(image.get(), x, y, sampling, paint);
|
|
|
|
}
|
2020-12-07 17:29:18 +00:00
|
|
|
void drawImageRect(const SkImage*, const SkRect& src, const SkRect& dst,
|
Reland "Add new virts, hide old ones"
This reverts commit 8f924ac0ce63806886b7297e8be554984a6e7ce5.
Reason for revert: suppressions landed for fuchsia images to rebaseline
Original change's description:
> Revert "Add new virts, hide old ones"
>
> This reverts commit c56e2e5aa65dd129e5927224d2f6c1f82edff74e.
>
> Reason for revert: suspected of breaking chrome roll
>
> Original change's description:
> > Add new virts, hide old ones
> >
> > Add virtuals for the draw methods that now take sampling/filtermode.
> >
> > drawImage
> > drawImageRect
> > drawImageLattice
> > drawAtlas
> >
> > Add a flag that can remove the older virtuals, once each client has
> > stopped overriding them. In that situation, the older public methods
> > will simplify extract the sampling from the paint, and call the new
> > public methods.
> >
> > Bug: skia:11105, skia:7650
> > Change-Id: I8b0029727295caa983e8148fc743a55cfbecd043
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347022
> > Commit-Queue: Mike Reed <reed@google.com>
> > Reviewed-by: Florin Malita <fmalita@chromium.org>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,fmalita@chromium.org,reed@google.com
>
> Change-Id: I0a90952c11a180d918126ea06a630f4a0bf9b49b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11105
> Bug: skia:7650
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348194
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: Derek Sollenberger <djsollen@google.com>
TBR=djsollen@google.com,bsalomon@google.com,fmalita@chromium.org,reed@google.com
# Not skipping CQ checks because this is a reland.
Bug: skia:11105
Bug: skia:7650
Change-Id: Ia2b4537a2d330460b7554278d2c05075cf27162a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348876
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-30 14:22:42 +00:00
|
|
|
const SkSamplingOptions&, const SkPaint*, SrcRectConstraint);
|
2021-01-13 18:14:23 +00:00
|
|
|
void drawImageRect(const SkImage*, const SkRect& dst, const SkSamplingOptions&,
|
2021-01-22 20:26:41 +00:00
|
|
|
const SkPaint* = nullptr);
|
|
|
|
void drawImageRect(const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst,
|
|
|
|
const SkSamplingOptions& sampling, const SkPaint* paint,
|
|
|
|
SrcRectConstraint constraint) {
|
|
|
|
this->drawImageRect(image.get(), src, dst, sampling, paint, constraint);
|
|
|
|
}
|
|
|
|
void drawImageRect(const sk_sp<SkImage>& image, const SkRect& dst,
|
|
|
|
const SkSamplingOptions& sampling, const SkPaint* paint = nullptr) {
|
|
|
|
this->drawImageRect(image.get(), dst, sampling, paint);
|
|
|
|
}
|
2020-12-07 17:29:18 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkImage image stretched proportionally to fit into SkRect dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
SkIRect center divides the image into nine sections: four sides, four corners, and
|
|
|
|
the center. Corners are unmodified or scaled down proportionately if their sides
|
|
|
|
are larger than dst; center and four sides are scaled to fit remaining space, if any.
|
|
|
|
|
|
|
|
Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader.
|
2020-12-17 14:17:59 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from image bounds.
|
2018-05-30 13:20:29 +00:00
|
|
|
Any SkMaskFilter on paint is ignored as is paint anti-aliasing state.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If generated mask extends beyond image bounds, replicate image edge colors, just
|
|
|
|
as SkShader made from SkImage::makeShader with SkShader::kClamp_TileMode set
|
2017-10-30 15:48:35 +00:00
|
|
|
replicates the image edge color when it samples outside of its bounds.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param image SkImage containing pixels, dimensions, and format
|
|
|
|
@param center SkIRect edge of image corners and sides
|
|
|
|
@param dst destination SkRect of image to draw to
|
2020-12-16 21:13:19 +00:00
|
|
|
@param filter what technique to use when sampling the image
|
2017-09-01 17:49:54 +00:00
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
|
2020-12-16 21:13:19 +00:00
|
|
|
SkFilterMode filter, const SkPaint* paint = nullptr);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2020-12-16 21:13:19 +00:00
|
|
|
// DEPRECATED -- pass filtermode explicitly
|
|
|
|
void drawImageNine(const SkImage* image, const SkIRect& center, const SkRect& dst,
|
|
|
|
const SkPaint* paint = nullptr);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2020-12-16 21:13:19 +00:00
|
|
|
// DEPRECATED -- pass filtermode explicitly
|
2016-03-17 15:14:57 +00:00
|
|
|
void drawImageNine(const sk_sp<SkImage>& image, const SkIRect& center, const SkRect& dst,
|
|
|
|
const SkPaint* paint = nullptr) {
|
|
|
|
this->drawImageNine(image.get(), center, dst, paint);
|
|
|
|
}
|
2015-06-25 19:32:03 +00:00
|
|
|
|
2021-01-13 18:14:23 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_DRAWBITMAP
|
|
|
|
public:
|
|
|
|
#else
|
|
|
|
private:
|
|
|
|
#endif
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkBitmap bitmap, with its top-left corner at (left, top),
|
2017-09-01 17:49:54 +00:00
|
|
|
using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is not nullptr, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If bitmap is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from bitmap bounds.
|
2013-12-05 15:43:19 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
|
|
|
|
just as SkShader made from SkShader::MakeBitmapShader with
|
2017-10-30 15:48:35 +00:00
|
|
|
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
|
2017-09-01 17:49:54 +00:00
|
|
|
outside of its bounds.
|
2013-12-05 15:43:19 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param bitmap SkBitmap containing pixels, dimensions, and format
|
|
|
|
@param left left side of bitmap
|
|
|
|
@param top top side of bitmap
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2015-01-09 22:17:40 +00:00
|
|
|
void drawBitmap(const SkBitmap& bitmap, SkScalar left, SkScalar top,
|
2017-08-28 14:34:05 +00:00
|
|
|
const SkPaint* paint = nullptr);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkRect src of SkBitmap bitmap, scaled and translated to fill SkRect dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If bitmap is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from bitmap bounds.
|
|
|
|
|
|
|
|
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
|
|
|
|
just as SkShader made from SkShader::MakeBitmapShader with
|
2017-10-30 15:48:35 +00:00
|
|
|
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
|
2017-09-01 17:49:54 +00:00
|
|
|
outside of its bounds.
|
|
|
|
|
|
|
|
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
|
|
|
|
sample within src; set to kFast_SrcRectConstraint allows sampling outside to
|
|
|
|
improve performance.
|
|
|
|
|
|
|
|
@param bitmap SkBitmap containing pixels, dimensions, and format
|
|
|
|
@param src source SkRect of image to draw from
|
|
|
|
@param dst destination SkRect of image to draw to
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
@param constraint filter strictly within src or draw faster
|
|
|
|
*/
|
2015-08-06 17:02:53 +00:00
|
|
|
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& src, const SkRect& dst,
|
2017-05-10 13:07:42 +00:00
|
|
|
const SkPaint* paint,
|
|
|
|
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkIRect isrc of SkBitmap bitmap, scaled and translated to fill SkRect dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
isrc is on integer pixel boundaries; dst may include fractional boundaries.
|
|
|
|
Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If bitmap is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from bitmap bounds.
|
|
|
|
|
|
|
|
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
|
|
|
|
just as SkShader made from SkShader::MakeBitmapShader with
|
2017-10-30 15:48:35 +00:00
|
|
|
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
|
2017-09-01 17:49:54 +00:00
|
|
|
outside of its bounds.
|
|
|
|
|
|
|
|
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
|
|
|
|
sample within isrc; set to kFast_SrcRectConstraint allows sampling outside to
|
|
|
|
improve performance.
|
|
|
|
|
|
|
|
@param bitmap SkBitmap containing pixels, dimensions, and format
|
|
|
|
@param isrc source SkIRect of image to draw from
|
|
|
|
@param dst destination SkRect of image to draw to
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
@param constraint sample strictly within isrc, or draw faster
|
|
|
|
*/
|
2015-07-17 14:09:43 +00:00
|
|
|
void drawBitmapRect(const SkBitmap& bitmap, const SkIRect& isrc, const SkRect& dst,
|
2017-10-09 19:45:33 +00:00
|
|
|
const SkPaint* paint,
|
2017-05-10 13:07:42 +00:00
|
|
|
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkBitmap bitmap, scaled and translated to fill SkRect dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
bitmap bounds is on integer pixel boundaries; dst may include fractional boundaries.
|
|
|
|
Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If bitmap is kAlpha_8_SkColorType, apply SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from bitmap bounds.
|
|
|
|
|
|
|
|
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
|
|
|
|
just as SkShader made from SkShader::MakeBitmapShader with
|
2017-10-30 15:48:35 +00:00
|
|
|
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
|
2017-09-01 17:49:54 +00:00
|
|
|
outside of its bounds.
|
|
|
|
|
|
|
|
constraint set to kStrict_SrcRectConstraint limits SkPaint SkFilterQuality to
|
|
|
|
sample within bitmap; set to kFast_SrcRectConstraint allows sampling outside to
|
|
|
|
improve performance.
|
|
|
|
|
|
|
|
@param bitmap SkBitmap containing pixels, dimensions, and format
|
|
|
|
@param dst destination SkRect of image to draw to
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
@param constraint filter strictly within bitmap or draw faster
|
|
|
|
*/
|
2015-08-06 17:02:53 +00:00
|
|
|
void drawBitmapRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint,
|
2017-05-10 13:07:42 +00:00
|
|
|
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
2021-01-13 18:14:23 +00:00
|
|
|
public:
|
2015-07-17 14:09:43 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** \struct SkCanvas::Lattice
|
2018-02-27 15:22:04 +00:00
|
|
|
SkCanvas::Lattice divides SkBitmap or SkImage into a rectangular grid.
|
2017-09-21 16:28:43 +00:00
|
|
|
Grid entries on even columns and even rows are fixed; these entries are
|
|
|
|
always drawn at their original size if the destination is large enough.
|
|
|
|
If the destination side is too small to hold the fixed entries, all fixed
|
|
|
|
entries are proportionately scaled down to fit.
|
|
|
|
The grid entries not on even columns and rows are scaled to fit the
|
|
|
|
remaining space, if any.
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2016-08-02 15:05:56 +00:00
|
|
|
struct Lattice {
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-12-11 18:01:58 +00:00
|
|
|
/** \enum SkCanvas::Lattice::RectType
|
2018-01-03 15:00:34 +00:00
|
|
|
Optional setting per rectangular grid entry to make it transparent,
|
|
|
|
or to fill the grid entry with a color.
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-12-11 18:01:58 +00:00
|
|
|
enum RectType : uint8_t {
|
2018-05-30 13:20:29 +00:00
|
|
|
kDefault = 0, //!< draws SkBitmap into lattice rectangle
|
|
|
|
kTransparent, //!< skips lattice rectangle by making it transparent
|
|
|
|
kFixedColor, //!< draws one of fColors into lattice rectangle
|
2016-09-02 18:24:30 +00:00
|
|
|
};
|
|
|
|
|
2018-06-14 17:21:08 +00:00
|
|
|
const int* fXDivs; //!< x-axis values dividing bitmap
|
|
|
|
const int* fYDivs; //!< y-axis values dividing bitmap
|
2018-05-30 13:20:29 +00:00
|
|
|
const RectType* fRectTypes; //!< array of fill types
|
|
|
|
int fXCount; //!< number of x-coordinates
|
|
|
|
int fYCount; //!< number of y-coordinates
|
|
|
|
const SkIRect* fBounds; //!< source bounds to draw from
|
|
|
|
const SkColor* fColors; //!< array of colors
|
2016-08-02 15:05:56 +00:00
|
|
|
};
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkImage image stretched proportionally to fit into SkRect dst.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
SkCanvas::Lattice lattice divides image into a rectangular grid.
|
2021-01-01 14:29:26 +00:00
|
|
|
Each intersection of an even-numbered row and column is fixed;
|
|
|
|
fixed lattice elements never scale larger than their initial
|
2017-10-30 15:48:35 +00:00
|
|
|
size and shrink proportionately when all fixed elements exceed the bitmap
|
2017-09-01 17:49:54 +00:00
|
|
|
dimension. All other grid elements scale to fill the available space, if any.
|
|
|
|
|
|
|
|
Additionally transform draw using clip, SkMatrix, and optional SkPaint paint.
|
|
|
|
|
2020-05-26 21:31:28 +00:00
|
|
|
If SkPaint paint is supplied, apply SkColorFilter, alpha, SkImageFilter, and
|
|
|
|
SkBlendMode. If image is kAlpha_8_SkColorType, apply SkShader.
|
2020-12-17 14:17:59 +00:00
|
|
|
If paint contains SkMaskFilter, generate mask from image bounds.
|
2018-05-30 13:20:29 +00:00
|
|
|
Any SkMaskFilter on paint is ignored as is paint anti-aliasing state.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If generated mask extends beyond bitmap bounds, replicate bitmap edge colors,
|
|
|
|
just as SkShader made from SkShader::MakeBitmapShader with
|
2017-10-30 15:48:35 +00:00
|
|
|
SkShader::kClamp_TileMode set replicates the bitmap edge color when it samples
|
2017-09-01 17:49:54 +00:00
|
|
|
outside of its bounds.
|
|
|
|
|
|
|
|
@param image SkImage containing pixels, dimensions, and format
|
|
|
|
@param lattice division of bitmap into fixed and variable rectangles
|
|
|
|
@param dst destination SkRect of image to draw to
|
2020-12-16 21:13:19 +00:00
|
|
|
@param filter what technique to use when sampling the image
|
2017-09-01 17:49:54 +00:00
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
*/
|
2020-12-16 21:13:19 +00:00
|
|
|
void drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
|
|
|
|
SkFilterMode filter, const SkPaint* paint = nullptr);
|
|
|
|
|
|
|
|
// DEPRECATED -- pass filtermode explicitly
|
2016-08-02 15:05:56 +00:00
|
|
|
void drawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
|
|
|
|
const SkPaint* paint = nullptr);
|
|
|
|
|
2018-10-12 15:42:02 +00:00
|
|
|
/**
|
2018-11-15 13:25:12 +00:00
|
|
|
* Experimental. Controls anti-aliasing of each edge of images in an image-set.
|
2018-10-12 15:42:02 +00:00
|
|
|
*/
|
|
|
|
enum QuadAAFlags : unsigned {
|
|
|
|
kLeft_QuadAAFlag = 0b0001,
|
|
|
|
kTop_QuadAAFlag = 0b0010,
|
|
|
|
kRight_QuadAAFlag = 0b0100,
|
|
|
|
kBottom_QuadAAFlag = 0b1000,
|
|
|
|
|
|
|
|
kNone_QuadAAFlags = 0b0000,
|
|
|
|
kAll_QuadAAFlags = 0b1111,
|
|
|
|
};
|
|
|
|
|
|
|
|
/** This is used by the experimental API below. */
|
2019-03-19 17:12:44 +00:00
|
|
|
struct SK_API ImageSetEntry {
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
ImageSetEntry(sk_sp<const SkImage> image, const SkRect& srcRect, const SkRect& dstRect,
|
|
|
|
int matrixIndex, float alpha, unsigned aaFlags, bool hasClip);
|
|
|
|
|
|
|
|
ImageSetEntry(sk_sp<const SkImage> image, const SkRect& srcRect, const SkRect& dstRect,
|
|
|
|
float alpha, unsigned aaFlags);
|
|
|
|
|
2019-04-10 14:26:10 +00:00
|
|
|
ImageSetEntry();
|
|
|
|
~ImageSetEntry();
|
|
|
|
ImageSetEntry(const ImageSetEntry&);
|
|
|
|
ImageSetEntry& operator=(const ImageSetEntry&);
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
|
2018-10-12 15:42:02 +00:00
|
|
|
sk_sp<const SkImage> fImage;
|
|
|
|
SkRect fSrcRect;
|
|
|
|
SkRect fDstRect;
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
int fMatrixIndex = -1; // Index into the preViewMatrices arg, or < 0
|
|
|
|
float fAlpha = 1.f;
|
|
|
|
unsigned fAAFlags = kNone_QuadAAFlags; // QuadAAFlags
|
|
|
|
bool fHasClip = false; // True to use next 4 points in dstClip arg as quad
|
2018-10-12 15:42:02 +00:00
|
|
|
};
|
|
|
|
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
/**
|
|
|
|
* This is an experimental API for the SkiaRenderer Chromium project, and its API will surely
|
|
|
|
* evolve if it is not removed outright.
|
|
|
|
*
|
|
|
|
* This behaves very similarly to drawRect() combined with a clipPath() formed by clip
|
|
|
|
* quadrilateral. 'rect' and 'clip' are in the same coordinate space. If 'clip' is null, then it
|
|
|
|
* is as if the rectangle was not clipped (or, alternatively, clipped to itself). If not null,
|
|
|
|
* then it must provide 4 points.
|
|
|
|
*
|
|
|
|
* In addition to combining the draw and clipping into one operation, this function adds the
|
|
|
|
* additional capability of controlling each of the rectangle's edges anti-aliasing
|
|
|
|
* independently. The edges of the clip will respect the per-edge AA flags. It is required that
|
|
|
|
* 'clip' be contained inside 'rect'. In terms of mapping to edge labels, the 'clip' points
|
|
|
|
* should be ordered top-left, top-right, bottom-right, bottom-left so that the edge between [0]
|
|
|
|
* and [1] is "top", [1] and [2] is "right", [2] and [3] is "bottom", and [3] and [0] is "left".
|
|
|
|
* This ordering matches SkRect::toQuad().
|
|
|
|
*
|
|
|
|
* This API only draws solid color, filled rectangles so it does not accept a full SkPaint.
|
|
|
|
*/
|
|
|
|
void experimental_DrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4], QuadAAFlags aaFlags,
|
2019-08-27 19:25:49 +00:00
|
|
|
const SkColor4f& color, SkBlendMode mode);
|
|
|
|
void experimental_DrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4], QuadAAFlags aaFlags,
|
|
|
|
SkColor color, SkBlendMode mode) {
|
|
|
|
this->experimental_DrawEdgeAAQuad(rect, clip, aaFlags, SkColor4f::FromColor(color), mode);
|
|
|
|
}
|
|
|
|
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
/**
|
|
|
|
* This is an bulk variant of experimental_DrawEdgeAAQuad() that renders 'cnt' textured quads.
|
|
|
|
* For each entry, 'fDstRect' is rendered with its clip (determined by entry's 'fHasClip' and
|
|
|
|
* the current index in 'dstClip'). The entry's fImage is applied to the destination rectangle
|
|
|
|
* by sampling from 'fSrcRect' sub-image. The corners of 'fSrcRect' map to the corners of
|
|
|
|
* 'fDstRect', just like in drawImageRect(), and they will be properly interpolated when
|
|
|
|
* applying a clip.
|
|
|
|
*
|
|
|
|
* Like experimental_DrawEdgeAAQuad(), each entry can specify edge AA flags that apply to both
|
|
|
|
* the destination rect and its clip.
|
|
|
|
*
|
|
|
|
* If provided, the 'dstClips' array must have length equal 4 * the number of entries with
|
|
|
|
* fHasClip true. If 'dstClips' is null, every entry must have 'fHasClip' set to false. The
|
|
|
|
* destination clip coordinates will be read consecutively with the image set entries, advancing
|
|
|
|
* by 4 points every time an entry with fHasClip is passed.
|
|
|
|
*
|
|
|
|
* This entry point supports per-entry manipulations to the canvas's current matrix. If an
|
|
|
|
* entry provides 'fMatrixIndex' >= 0, it will be drawn as if the canvas's CTM was
|
|
|
|
* canvas->getTotalMatrix() * preViewMatrices[fMatrixIndex]. If 'fMatrixIndex' is less than 0,
|
|
|
|
* the pre-view matrix transform is implicitly the identity, so it will be drawn using just the
|
|
|
|
* current canvas matrix. The pre-view matrix modifies the canvas's view matrix, it does not
|
|
|
|
* affect the local coordinates of each entry.
|
|
|
|
*
|
|
|
|
* An optional paint may be provided, which supports the same subset of features usable with
|
|
|
|
* drawImageRect (i.e. assumed to be filled and no path effects). When a paint is provided, the
|
|
|
|
* image set is drawn as if each image used the applied paint independently, so each is affected
|
|
|
|
* by the image, color, and/or mask filter.
|
|
|
|
*/
|
2021-01-05 17:03:47 +00:00
|
|
|
void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt,
|
|
|
|
const SkPoint dstClips[], const SkMatrix preViewMatrices[],
|
|
|
|
const SkSamplingOptions&, const SkPaint* paint = nullptr,
|
|
|
|
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
|
|
|
// DEPRECATED -- pass sampling directly
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
void experimental_DrawEdgeAAImageSet(const ImageSetEntry imageSet[], int cnt,
|
|
|
|
const SkPoint dstClips[], const SkMatrix preViewMatrices[],
|
|
|
|
const SkPaint* paint = nullptr,
|
|
|
|
SrcRectConstraint constraint = kStrict_SrcRectConstraint);
|
|
|
|
|
2019-01-15 02:36:15 +00:00
|
|
|
/** Draws text, with origin at (x, y), using clip, SkMatrix, SkFont font,
|
2019-01-07 14:30:27 +00:00
|
|
|
and SkPaint paint.
|
2019-01-07 17:51:32 +00:00
|
|
|
|
2019-02-06 10:33:30 +00:00
|
|
|
When encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or
|
|
|
|
SkTextEncoding::kUTF32, this function uses the default
|
|
|
|
character-to-glyph mapping from the SkTypeface in font. It does not
|
|
|
|
perform typeface fallback for characters not found in the SkTypeface.
|
|
|
|
It does not perform kerning or other complex shaping; glyphs are
|
|
|
|
positioned based on their default advances.
|
|
|
|
|
|
|
|
Text meaning depends on SkTextEncoding.
|
|
|
|
|
|
|
|
Text size is affected by SkMatrix and SkFont text size. Default text
|
|
|
|
size is 12 point.
|
2019-01-07 17:51:32 +00:00
|
|
|
|
|
|
|
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
|
2020-05-26 21:31:28 +00:00
|
|
|
SkColorFilter, and SkImageFilter; apply to text. By
|
2019-01-07 14:30:27 +00:00
|
|
|
default, draws filled black glyphs.
|
2019-01-07 17:51:32 +00:00
|
|
|
|
|
|
|
@param text character code points or glyphs drawn
|
|
|
|
@param byteLength byte length of text array
|
|
|
|
@param encoding text encoding used in the text array
|
|
|
|
@param x start of text on x-axis
|
|
|
|
@param y start of text on y-axis
|
|
|
|
@param font typeface, text size and so, used to describe the text
|
|
|
|
@param paint blend, color, and so on, used to draw
|
2019-01-07 14:30:27 +00:00
|
|
|
*/
|
2018-11-23 20:27:51 +00:00
|
|
|
void drawSimpleText(const void* text, size_t byteLength, SkTextEncoding encoding,
|
|
|
|
SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint);
|
|
|
|
|
2019-04-18 17:41:21 +00:00
|
|
|
/** Draws null terminated string, with origin at (x, y), using clip, SkMatrix,
|
2019-02-06 10:33:30 +00:00
|
|
|
SkFont font, and SkPaint paint.
|
|
|
|
|
|
|
|
This function uses the default character-to-glyph mapping from the
|
|
|
|
SkTypeface in font. It does not perform typeface fallback for
|
|
|
|
characters not found in the SkTypeface. It does not perform kerning;
|
|
|
|
glyphs are positioned based on their default advances.
|
|
|
|
|
|
|
|
String str is encoded as UTF-8.
|
2019-01-07 14:30:27 +00:00
|
|
|
|
2019-02-06 10:33:30 +00:00
|
|
|
Text size is affected by SkMatrix and font text size. Default text
|
|
|
|
size is 12 point.
|
|
|
|
|
|
|
|
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
|
2020-05-26 21:31:28 +00:00
|
|
|
SkColorFilter, and SkImageFilter; apply to text. By
|
2019-02-06 10:33:30 +00:00
|
|
|
default, draws filled black glyphs.
|
|
|
|
|
|
|
|
@param str character code points drawn,
|
|
|
|
ending with a char value of zero
|
2019-01-07 14:30:27 +00:00
|
|
|
@param x start of string on x-axis
|
|
|
|
@param y start of string on y-axis
|
|
|
|
@param font typeface, text size and so, used to describe the text
|
|
|
|
@param paint blend, color, and so on, used to draw
|
|
|
|
*/
|
2019-02-06 10:33:30 +00:00
|
|
|
void drawString(const char str[], SkScalar x, SkScalar y, const SkFont& font,
|
|
|
|
const SkPaint& paint) {
|
2019-05-07 19:38:46 +00:00
|
|
|
this->drawSimpleText(str, strlen(str), SkTextEncoding::kUTF8, x, y, font, paint);
|
2019-01-05 21:35:13 +00:00
|
|
|
}
|
2019-01-07 14:30:27 +00:00
|
|
|
|
2019-04-18 17:41:21 +00:00
|
|
|
/** Draws SkString, with origin at (x, y), using clip, SkMatrix, SkFont font,
|
2019-02-06 10:33:30 +00:00
|
|
|
and SkPaint paint.
|
2019-01-07 14:30:27 +00:00
|
|
|
|
2019-02-06 10:33:30 +00:00
|
|
|
This function uses the default character-to-glyph mapping from the
|
|
|
|
SkTypeface in font. It does not perform typeface fallback for
|
|
|
|
characters not found in the SkTypeface. It does not perform kerning;
|
|
|
|
glyphs are positioned based on their default advances.
|
|
|
|
|
|
|
|
SkString str is encoded as UTF-8.
|
|
|
|
|
|
|
|
Text size is affected by SkMatrix and SkFont text size. Default text
|
|
|
|
size is 12 point.
|
2019-01-07 14:30:27 +00:00
|
|
|
|
2019-02-06 10:33:30 +00:00
|
|
|
All elements of paint: SkPathEffect, SkMaskFilter, SkShader,
|
2020-05-26 21:31:28 +00:00
|
|
|
SkColorFilter, and SkImageFilter; apply to text. By
|
2019-02-06 10:33:30 +00:00
|
|
|
default, draws filled black glyphs.
|
|
|
|
|
|
|
|
@param str character code points drawn,
|
|
|
|
ending with a char value of zero
|
2019-01-07 14:30:27 +00:00
|
|
|
@param x start of string on x-axis
|
|
|
|
@param y start of string on y-axis
|
|
|
|
@param font typeface, text size and so, used to describe the text
|
|
|
|
@param paint blend, color, and so on, used to draw
|
2019-02-06 10:33:30 +00:00
|
|
|
*/
|
|
|
|
void drawString(const SkString& str, SkScalar x, SkScalar y, const SkFont& font,
|
2019-01-05 21:35:13 +00:00
|
|
|
const SkPaint& paint) {
|
2019-05-07 19:38:46 +00:00
|
|
|
this->drawSimpleText(str.c_str(), str.size(), SkTextEncoding::kUTF8, x, y, font, paint);
|
2019-01-05 21:35:13 +00:00
|
|
|
}
|
2017-04-28 19:35:12 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
blob contains glyphs, their positions, and paint attributes specific to text:
|
2018-08-10 17:11:06 +00:00
|
|
|
SkTypeface, SkPaint text size, SkPaint text scale x,
|
|
|
|
SkPaint text skew x, SkPaint::Align, SkPaint::Hinting, anti-alias, SkPaint fake bold,
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPaint font embedded bitmaps, SkPaint full hinting spacing, LCD text, SkPaint linear text,
|
2018-08-10 17:11:06 +00:00
|
|
|
and SkPaint subpixel text.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2019-05-07 19:38:46 +00:00
|
|
|
SkTextEncoding must be set to SkTextEncoding::kGlyphID.
|
2018-01-03 15:00:34 +00:00
|
|
|
|
2018-08-10 17:11:06 +00:00
|
|
|
Elements of paint: anti-alias, SkBlendMode, color including alpha,
|
2020-05-26 21:31:28 +00:00
|
|
|
SkColorFilter, SkPaint dither, SkMaskFilter, SkPathEffect, SkShader, and
|
2018-08-10 17:11:06 +00:00
|
|
|
SkPaint::Style; apply to blob. If SkPaint contains SkPaint::kStroke_Style:
|
|
|
|
SkPaint miter limit, SkPaint::Cap, SkPaint::Join, and SkPaint stroke width;
|
|
|
|
apply to SkPath created from blob.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param blob glyphs, positions, and their paints' text size, typeface, and so on
|
2017-09-01 17:49:54 +00:00
|
|
|
@param x horizontal offset applied to blob
|
|
|
|
@param y vertical offset applied to blob
|
|
|
|
@param paint blend, color, stroking, and so on, used to draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawTextBlob
|
2014-08-21 15:53:26 +00:00
|
|
|
*/
|
|
|
|
void drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint& paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkTextBlob blob at (x, y), using clip, SkMatrix, and SkPaint paint.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
blob contains glyphs, their positions, and paint attributes specific to text:
|
2018-08-10 17:11:06 +00:00
|
|
|
SkTypeface, SkPaint text size, SkPaint text scale x,
|
|
|
|
SkPaint text skew x, SkPaint::Align, SkPaint::Hinting, anti-alias, SkPaint fake bold,
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPaint font embedded bitmaps, SkPaint full hinting spacing, LCD text, SkPaint linear text,
|
2018-08-10 17:11:06 +00:00
|
|
|
and SkPaint subpixel text.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2019-05-07 19:38:46 +00:00
|
|
|
SkTextEncoding must be set to SkTextEncoding::kGlyphID.
|
2018-01-03 15:00:34 +00:00
|
|
|
|
2018-01-20 00:09:32 +00:00
|
|
|
Elements of paint: SkPathEffect, SkMaskFilter, SkShader, SkColorFilter,
|
2020-05-26 21:31:28 +00:00
|
|
|
and SkImageFilter; apply to blob.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param blob glyphs, positions, and their paints' text size, typeface, and so on
|
2017-09-01 17:49:54 +00:00
|
|
|
@param x horizontal offset applied to blob
|
|
|
|
@param y vertical offset applied to blob
|
|
|
|
@param paint blend, color, stroking, and so on, used to draw
|
|
|
|
*/
|
2016-08-10 21:16:41 +00:00
|
|
|
void drawTextBlob(const sk_sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint) {
|
|
|
|
this->drawTextBlob(blob.get(), x, y, paint);
|
|
|
|
}
|
2014-08-21 15:53:26 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkPicture picture, using clip and SkMatrix.
|
2017-09-01 17:49:54 +00:00
|
|
|
Clip and SkMatrix are unchanged by picture contents, as if
|
|
|
|
save() was called before and restore() was called after drawPicture().
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
SkPicture records a series of draw commands for later playback.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param picture recorded drawing commands to play
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2015-04-30 20:09:24 +00:00
|
|
|
void drawPicture(const SkPicture* picture) {
|
2017-08-28 14:34:05 +00:00
|
|
|
this->drawPicture(picture, nullptr, nullptr);
|
2015-04-30 20:09:24 +00:00
|
|
|
}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkPicture picture, using clip and SkMatrix.
|
2017-09-01 17:49:54 +00:00
|
|
|
Clip and SkMatrix are unchanged by picture contents, as if
|
|
|
|
save() was called before and restore() was called after drawPicture().
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
SkPicture records a series of draw commands for later playback.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param picture recorded drawing commands to play
|
|
|
|
*/
|
2016-03-18 14:25:55 +00:00
|
|
|
void drawPicture(const sk_sp<SkPicture>& picture) {
|
2016-03-17 15:14:57 +00:00
|
|
|
this->drawPicture(picture.get());
|
|
|
|
}
|
2014-06-04 12:40:44 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkPicture picture, using clip and SkMatrix; transforming picture with
|
2018-05-30 13:20:29 +00:00
|
|
|
SkMatrix matrix, if provided; and use SkPaint paint alpha, SkColorFilter,
|
2017-09-01 17:49:54 +00:00
|
|
|
SkImageFilter, and SkBlendMode, if provided.
|
|
|
|
|
2020-05-12 17:22:21 +00:00
|
|
|
If paint is non-null, then the picture is always drawn into a temporary layer before
|
|
|
|
actually landing on the canvas. Note that drawing into a layer can also change its
|
|
|
|
appearance if there are any non-associative blendModes inside any of the pictures elements.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param picture recorded drawing commands to play
|
|
|
|
@param matrix SkMatrix to rotate, scale, translate, and so on; may be nullptr
|
|
|
|
@param paint SkPaint to apply transparency, filtering, and so on; may be nullptr
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawPicture_3
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void drawPicture(const SkPicture* picture, const SkMatrix* matrix, const SkPaint* paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkPicture picture, using clip and SkMatrix; transforming picture with
|
2018-05-30 13:20:29 +00:00
|
|
|
SkMatrix matrix, if provided; and use SkPaint paint alpha, SkColorFilter,
|
2017-09-01 17:49:54 +00:00
|
|
|
SkImageFilter, and SkBlendMode, if provided.
|
|
|
|
|
2020-05-12 17:22:21 +00:00
|
|
|
If paint is non-null, then the picture is always drawn into a temporary layer before
|
|
|
|
actually landing on the canvas. Note that drawing into a layer can also change its
|
|
|
|
appearance if there are any non-associative blendModes inside any of the pictures elements.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param picture recorded drawing commands to play
|
|
|
|
@param matrix SkMatrix to rotate, scale, translate, and so on; may be nullptr
|
|
|
|
@param paint SkPaint to apply transparency, filtering, and so on; may be nullptr
|
|
|
|
*/
|
2018-09-13 15:32:08 +00:00
|
|
|
void drawPicture(const sk_sp<SkPicture>& picture, const SkMatrix* matrix,
|
|
|
|
const SkPaint* paint) {
|
2016-03-17 15:14:57 +00:00
|
|
|
this->drawPicture(picture.get(), matrix, paint);
|
|
|
|
}
|
2014-08-09 18:08:05 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix.
|
2020-05-15 17:04:48 +00:00
|
|
|
If paint contains an SkShader and vertices does not contain texCoords, the shader
|
|
|
|
is mapped using the vertices' positions.
|
|
|
|
|
|
|
|
If vertices colors are defined in vertices, and SkPaint paint contains SkShader,
|
|
|
|
SkBlendMode mode combines vertices colors with SkShader.
|
2017-02-06 14:41:10 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param vertices triangle mesh to draw
|
|
|
|
@param mode combines vertices colors with SkShader, if both are present
|
2018-05-30 13:20:29 +00:00
|
|
|
@param paint specifies the SkShader, used as SkVertices texture; may be nullptr
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawVertices
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-03-17 13:50:46 +00:00
|
|
|
void drawVertices(const SkVertices* vertices, SkBlendMode mode, const SkPaint& paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2020-03-06 17:52:52 +00:00
|
|
|
/** Variant of 3-parameter drawVertices, using the default of Modulate for the blend
|
|
|
|
* parameter. Note that SkVertices that include per-vertex-data ignore this mode parameter.
|
|
|
|
*/
|
|
|
|
void drawVertices(const SkVertices* vertices, const SkPaint& paint) {
|
|
|
|
this->drawVertices(vertices, SkBlendMode::kModulate, paint);
|
|
|
|
}
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkVertices vertices, a triangle mesh, using clip and SkMatrix.
|
2020-05-15 17:04:48 +00:00
|
|
|
If paint contains an SkShader and vertices does not contain texCoords, the shader
|
|
|
|
is mapped using the vertices' positions.
|
|
|
|
|
|
|
|
If vertices colors are defined in vertices, and SkPaint paint contains SkShader,
|
|
|
|
SkBlendMode mode combines vertices colors with SkShader.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param vertices triangle mesh to draw
|
|
|
|
@param mode combines vertices colors with SkShader, if both are present
|
2018-05-30 13:20:29 +00:00
|
|
|
@param paint specifies the SkShader, used as SkVertices texture, may be nullptr
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawVertices_2
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-03-17 13:50:46 +00:00
|
|
|
void drawVertices(const sk_sp<SkVertices>& vertices, SkBlendMode mode, const SkPaint& paint);
|
2016-10-28 19:42:34 +00:00
|
|
|
|
2020-03-06 17:52:52 +00:00
|
|
|
/** Variant of 3-parameter drawVertices, using the default of Modulate for the blend
|
|
|
|
* parameter. Note that SkVertices that include per-vertex-data ignore this mode parameter.
|
|
|
|
*/
|
|
|
|
void drawVertices(const sk_sp<SkVertices>& vertices, const SkPaint& paint) {
|
|
|
|
this->drawVertices(vertices, SkBlendMode::kModulate, paint);
|
|
|
|
}
|
|
|
|
|
2018-06-14 17:21:08 +00:00
|
|
|
/** Draws a Coons patch: the interpolation of four cubics with shared corners,
|
|
|
|
associating a color, and optionally a texture SkPoint, with each corner.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-06-14 17:21:08 +00:00
|
|
|
Coons patch uses clip and SkMatrix, paint SkShader, SkColorFilter,
|
2018-05-30 13:20:29 +00:00
|
|
|
alpha, SkImageFilter, and SkBlendMode. If SkShader is provided it is treated
|
2018-06-14 17:21:08 +00:00
|
|
|
as Coons patch texture; SkBlendMode mode combines color colors and SkShader if
|
2017-09-01 17:49:54 +00:00
|
|
|
both are provided.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPoint array cubics specifies four SkPath cubic starting at the top-left corner,
|
|
|
|
in clockwise order, sharing every fourth point. The last SkPath cubic ends at the
|
2017-09-01 17:49:54 +00:00
|
|
|
first point.
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
Color array color associates colors with corners in top-left, top-right,
|
|
|
|
bottom-right, bottom-left order.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If paint contains SkShader, SkPoint array texCoords maps SkShader as texture to
|
2020-05-15 17:04:48 +00:00
|
|
|
corners in top-left, top-right, bottom-right, bottom-left order. If texCoords is
|
|
|
|
nullptr, SkShader is mapped using positions (derived from cubics).
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param cubics SkPath cubic array, sharing common points
|
2017-09-21 16:28:43 +00:00
|
|
|
@param colors color array, one for each corner
|
2017-09-01 17:49:54 +00:00
|
|
|
@param texCoords SkPoint array of texture coordinates, mapping SkShader to corners;
|
|
|
|
may be nullptr
|
|
|
|
@param mode SkBlendMode for colors, and for SkShader if paint has one
|
|
|
|
@param paint SkShader, SkColorFilter, SkBlendMode, used to draw
|
|
|
|
*/
|
2014-08-12 15:34:29 +00:00
|
|
|
void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
2016-10-28 19:42:34 +00:00
|
|
|
const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-06-14 17:21:08 +00:00
|
|
|
/** Draws SkPath cubic Coons patch: the interpolation of four cubics with shared corners,
|
|
|
|
associating a color, and optionally a texture SkPoint, with each corner.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-06-14 17:21:08 +00:00
|
|
|
Coons patch uses clip and SkMatrix, paint SkShader, SkColorFilter,
|
2018-05-30 13:20:29 +00:00
|
|
|
alpha, SkImageFilter, and SkBlendMode. If SkShader is provided it is treated
|
2018-06-14 17:21:08 +00:00
|
|
|
as Coons patch texture; SkBlendMode mode combines color colors and SkShader if
|
2017-09-01 17:49:54 +00:00
|
|
|
both are provided.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
SkPoint array cubics specifies four SkPath cubic starting at the top-left corner,
|
|
|
|
in clockwise order, sharing every fourth point. The last SkPath cubic ends at the
|
2017-09-01 17:49:54 +00:00
|
|
|
first point.
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
Color array color associates colors with corners in top-left, top-right,
|
|
|
|
bottom-right, bottom-left order.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If paint contains SkShader, SkPoint array texCoords maps SkShader as texture to
|
2020-05-15 17:04:48 +00:00
|
|
|
corners in top-left, top-right, bottom-right, bottom-left order. If texCoords is
|
|
|
|
nullptr, SkShader is mapped using positions (derived from cubics).
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param cubics SkPath cubic array, sharing common points
|
2017-09-21 16:28:43 +00:00
|
|
|
@param colors color array, one for each corner
|
2017-09-01 17:49:54 +00:00
|
|
|
@param texCoords SkPoint array of texture coordinates, mapping SkShader to corners;
|
|
|
|
may be nullptr
|
|
|
|
@param paint SkShader, SkColorFilter, SkBlendMode, used to draw
|
|
|
|
*/
|
2016-10-28 19:42:34 +00:00
|
|
|
void drawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
|
|
|
const SkPoint texCoords[4], const SkPaint& paint) {
|
|
|
|
this->drawPatch(cubics, colors, texCoords, SkBlendMode::kModulate, paint);
|
|
|
|
}
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
|
2018-05-30 13:20:29 +00:00
|
|
|
paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode
|
2017-09-01 17:49:54 +00:00
|
|
|
to draw, if present. For each entry in the array, SkRect tex locates sprite in
|
|
|
|
atlas, and SkRSXform xform transforms it into destination space.
|
|
|
|
|
|
|
|
xform, text, and colors if present, must contain count entries.
|
2018-07-02 19:20:10 +00:00
|
|
|
Optional colors are applied for each sprite using SkBlendMode mode, treating
|
|
|
|
sprite as source and colors as destination.
|
2017-09-01 17:49:54 +00:00
|
|
|
Optional cullRect is a conservative bounds of all transformed sprites.
|
|
|
|
If cullRect is outside of clip, canvas can skip drawing.
|
|
|
|
|
2019-08-07 15:00:19 +00:00
|
|
|
If atlas is nullptr, this draws nothing.
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
@param atlas SkImage containing sprites
|
|
|
|
@param xform SkRSXform mappings for sprites in atlas
|
|
|
|
@param tex SkRect locations of sprites in atlas
|
2017-09-21 16:28:43 +00:00
|
|
|
@param colors one per sprite, blended with sprite using SkBlendMode; may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
@param count number of sprites to draw
|
|
|
|
@param mode SkBlendMode combining colors and sprites
|
Reland "Add new virts, hide old ones"
This reverts commit 8f924ac0ce63806886b7297e8be554984a6e7ce5.
Reason for revert: suppressions landed for fuchsia images to rebaseline
Original change's description:
> Revert "Add new virts, hide old ones"
>
> This reverts commit c56e2e5aa65dd129e5927224d2f6c1f82edff74e.
>
> Reason for revert: suspected of breaking chrome roll
>
> Original change's description:
> > Add new virts, hide old ones
> >
> > Add virtuals for the draw methods that now take sampling/filtermode.
> >
> > drawImage
> > drawImageRect
> > drawImageLattice
> > drawAtlas
> >
> > Add a flag that can remove the older virtuals, once each client has
> > stopped overriding them. In that situation, the older public methods
> > will simplify extract the sampling from the paint, and call the new
> > public methods.
> >
> > Bug: skia:11105, skia:7650
> > Change-Id: I8b0029727295caa983e8148fc743a55cfbecd043
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347022
> > Commit-Queue: Mike Reed <reed@google.com>
> > Reviewed-by: Florin Malita <fmalita@chromium.org>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,fmalita@chromium.org,reed@google.com
>
> Change-Id: I0a90952c11a180d918126ea06a630f4a0bf9b49b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11105
> Bug: skia:7650
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348194
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: Derek Sollenberger <djsollen@google.com>
TBR=djsollen@google.com,bsalomon@google.com,fmalita@chromium.org,reed@google.com
# Not skipping CQ checks because this is a reland.
Bug: skia:11105
Bug: skia:7650
Change-Id: Ia2b4537a2d330460b7554278d2c05075cf27162a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348876
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-30 14:22:42 +00:00
|
|
|
@param sampling SkSamplingOptions used when sampling from the atlas image
|
2017-09-21 16:28:43 +00:00
|
|
|
@param cullRect bounds of transformed sprites for efficient clipping; may be nullptr
|
|
|
|
@param paint SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
Reland "Add new virts, hide old ones"
This reverts commit 8f924ac0ce63806886b7297e8be554984a6e7ce5.
Reason for revert: suppressions landed for fuchsia images to rebaseline
Original change's description:
> Revert "Add new virts, hide old ones"
>
> This reverts commit c56e2e5aa65dd129e5927224d2f6c1f82edff74e.
>
> Reason for revert: suspected of breaking chrome roll
>
> Original change's description:
> > Add new virts, hide old ones
> >
> > Add virtuals for the draw methods that now take sampling/filtermode.
> >
> > drawImage
> > drawImageRect
> > drawImageLattice
> > drawAtlas
> >
> > Add a flag that can remove the older virtuals, once each client has
> > stopped overriding them. In that situation, the older public methods
> > will simplify extract the sampling from the paint, and call the new
> > public methods.
> >
> > Bug: skia:11105, skia:7650
> > Change-Id: I8b0029727295caa983e8148fc743a55cfbecd043
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347022
> > Commit-Queue: Mike Reed <reed@google.com>
> > Reviewed-by: Florin Malita <fmalita@chromium.org>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,fmalita@chromium.org,reed@google.com
>
> Change-Id: I0a90952c11a180d918126ea06a630f4a0bf9b49b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11105
> Bug: skia:7650
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348194
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: Derek Sollenberger <djsollen@google.com>
TBR=djsollen@google.com,bsalomon@google.com,fmalita@chromium.org,reed@google.com
# Not skipping CQ checks because this is a reland.
Bug: skia:11105
Bug: skia:7650
Change-Id: Ia2b4537a2d330460b7554278d2c05075cf27162a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348876
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-30 14:22:42 +00:00
|
|
|
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
|
|
|
|
const SkColor colors[], int count, SkBlendMode mode,
|
|
|
|
const SkSamplingOptions& sampling, const SkRect* cullRect, const SkPaint* paint);
|
|
|
|
|
|
|
|
// DEPRECATED -- pass sampling
|
2015-06-24 17:29:17 +00:00
|
|
|
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
|
2017-05-10 13:07:42 +00:00
|
|
|
const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
|
2015-06-24 17:29:17 +00:00
|
|
|
const SkPaint* paint);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
|
2018-05-30 13:20:29 +00:00
|
|
|
paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode
|
2017-09-01 17:49:54 +00:00
|
|
|
to draw, if present. For each entry in the array, SkRect tex locates sprite in
|
|
|
|
atlas, and SkRSXform xform transforms it into destination space.
|
|
|
|
|
|
|
|
xform, text, and colors if present, must contain count entries.
|
|
|
|
Optional colors is applied for each sprite using SkBlendMode.
|
|
|
|
Optional cullRect is a conservative bounds of all transformed sprites.
|
|
|
|
If cullRect is outside of clip, canvas can skip drawing.
|
|
|
|
|
|
|
|
@param atlas SkImage containing sprites
|
|
|
|
@param xform SkRSXform mappings for sprites in atlas
|
|
|
|
@param tex SkRect locations of sprites in atlas
|
2017-09-21 16:28:43 +00:00
|
|
|
@param colors one per sprite, blended with sprite using SkBlendMode; may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
@param count number of sprites to draw
|
|
|
|
@param mode SkBlendMode combining colors and sprites
|
2017-09-21 16:28:43 +00:00
|
|
|
@param cullRect bounds of transformed sprites for efficient clipping; may be nullptr
|
|
|
|
@param paint SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2016-10-28 19:42:34 +00:00
|
|
|
void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
|
|
|
|
const SkColor colors[], int count, SkBlendMode mode, const SkRect* cullRect,
|
|
|
|
const SkPaint* paint) {
|
|
|
|
this->drawAtlas(atlas.get(), xform, tex, colors, count, mode, cullRect, paint);
|
|
|
|
}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
|
2018-05-30 13:20:29 +00:00
|
|
|
paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode
|
2017-09-01 17:49:54 +00:00
|
|
|
to draw, if present. For each entry in the array, SkRect tex locates sprite in
|
|
|
|
atlas, and SkRSXform xform transforms it into destination space.
|
|
|
|
|
|
|
|
xform and text must contain count entries.
|
|
|
|
Optional cullRect is a conservative bounds of all transformed sprites.
|
|
|
|
If cullRect is outside of clip, canvas can skip drawing.
|
|
|
|
|
|
|
|
@param atlas SkImage containing sprites
|
|
|
|
@param xform SkRSXform mappings for sprites in atlas
|
|
|
|
@param tex SkRect locations of sprites in atlas
|
|
|
|
@param count number of sprites to draw
|
2017-09-21 16:28:43 +00:00
|
|
|
@param cullRect bounds of transformed sprites for efficient clipping; may be nullptr
|
|
|
|
@param paint SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2015-06-24 17:29:17 +00:00
|
|
|
void drawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[], int count,
|
|
|
|
const SkRect* cullRect, const SkPaint* paint) {
|
2016-10-28 19:42:34 +00:00
|
|
|
this->drawAtlas(atlas, xform, tex, nullptr, count, SkBlendMode::kDst, cullRect, paint);
|
2015-06-24 17:29:17 +00:00
|
|
|
}
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws a set of sprites from atlas, using clip, SkMatrix, and optional SkPaint paint.
|
2018-05-30 13:20:29 +00:00
|
|
|
paint uses anti-alias, alpha, SkColorFilter, SkImageFilter, and SkBlendMode
|
2017-09-01 17:49:54 +00:00
|
|
|
to draw, if present. For each entry in the array, SkRect tex locates sprite in
|
|
|
|
atlas, and SkRSXform xform transforms it into destination space.
|
|
|
|
|
|
|
|
xform and text must contain count entries.
|
|
|
|
Optional cullRect is a conservative bounds of all transformed sprites.
|
|
|
|
If cullRect is outside of clip, canvas can skip drawing.
|
|
|
|
|
|
|
|
@param atlas SkImage containing sprites
|
|
|
|
@param xform SkRSXform mappings for sprites in atlas
|
|
|
|
@param tex SkRect locations of sprites in atlas
|
|
|
|
@param count number of sprites to draw
|
2017-09-21 16:28:43 +00:00
|
|
|
@param cullRect bounds of transformed sprites for efficient clipping; may be nullptr
|
|
|
|
@param paint SkColorFilter, SkImageFilter, SkBlendMode, and so on; may be nullptr
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2016-03-17 15:14:57 +00:00
|
|
|
void drawAtlas(const sk_sp<SkImage>& atlas, const SkRSXform xform[], const SkRect tex[],
|
2016-10-28 19:42:34 +00:00
|
|
|
int count, const SkRect* cullRect, const SkPaint* paint) {
|
|
|
|
this->drawAtlas(atlas.get(), xform, tex, nullptr, count, SkBlendMode::kDst,
|
|
|
|
cullRect, paint);
|
|
|
|
}
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkDrawable drawable using clip and SkMatrix, concatenated with
|
2017-09-01 17:49:54 +00:00
|
|
|
optional matrix.
|
|
|
|
|
|
|
|
If SkCanvas has an asynchronous implementation, as is the case
|
2018-01-03 15:00:34 +00:00
|
|
|
when it is recording into SkPicture, then drawable will be referenced,
|
2017-09-01 17:49:54 +00:00
|
|
|
so that SkDrawable::draw() can be called when the operation is finalized. To force
|
|
|
|
immediate drawing, call SkDrawable::draw() instead.
|
|
|
|
|
|
|
|
@param drawable custom struct encapsulating drawing commands
|
|
|
|
@param matrix transformation applied to drawing; may be nullptr
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawDrawable
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-08-28 14:34:05 +00:00
|
|
|
void drawDrawable(SkDrawable* drawable, const SkMatrix* matrix = nullptr);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Draws SkDrawable drawable using clip and SkMatrix, offset by (x, y).
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
If SkCanvas has an asynchronous implementation, as is the case
|
2018-01-03 15:00:34 +00:00
|
|
|
when it is recording into SkPicture, then drawable will be referenced,
|
2017-09-01 17:49:54 +00:00
|
|
|
so that SkDrawable::draw() can be called when the operation is finalized. To force
|
|
|
|
immediate drawing, call SkDrawable::draw() instead.
|
|
|
|
|
|
|
|
@param drawable custom struct encapsulating drawing commands
|
2018-06-14 17:21:08 +00:00
|
|
|
@param x offset into SkCanvas writable pixels on x-axis
|
|
|
|
@param y offset into SkCanvas writable pixels on y-axis
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawDrawable_2
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void drawDrawable(SkDrawable* drawable, SkScalar x, SkScalar y);
|
2014-11-12 03:36:09 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Associates SkRect on SkCanvas with an annotation; a key-value pair, where the key is
|
2018-10-31 14:54:50 +00:00
|
|
|
a null-terminated UTF-8 string, and optional value is stored as SkData.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Only some canvas implementations, such as recording to SkPicture, or drawing to
|
2018-10-31 14:54:50 +00:00
|
|
|
document PDF, use annotations.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param rect SkRect extent of canvas to annotate
|
|
|
|
@param key string used for lookup
|
|
|
|
@param value data holding value stored in annotation
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_drawAnnotation_2
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void drawAnnotation(const SkRect& rect, const char key[], SkData* value);
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Associates SkRect on SkCanvas when an annotation; a key-value pair, where the key is
|
2018-10-31 14:54:50 +00:00
|
|
|
a null-terminated UTF-8 string, and optional value is stored as SkData.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
Only some canvas implementations, such as recording to SkPicture, or drawing to
|
2018-10-31 14:54:50 +00:00
|
|
|
document PDF, use annotations.
|
2017-09-01 17:49:54 +00:00
|
|
|
|
|
|
|
@param rect SkRect extent of canvas to annotate
|
|
|
|
@param key string used for lookup
|
|
|
|
@param value data holding value stored in annotation
|
|
|
|
*/
|
2016-04-01 11:55:51 +00:00
|
|
|
void drawAnnotation(const SkRect& rect, const char key[], const sk_sp<SkData>& value) {
|
|
|
|
this->drawAnnotation(rect, key, value.get());
|
|
|
|
}
|
2016-03-05 00:36:20 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if clip is empty; that is, nothing will draw.
|
|
|
|
|
|
|
|
May do work when called; it should not be called
|
|
|
|
more often than needed. However, once called, subsequent calls perform no
|
|
|
|
work until clip changes.
|
|
|
|
|
|
|
|
@return true if clip is empty
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_isClipEmpty
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2014-02-28 18:19:39 +00:00
|
|
|
virtual bool isClipEmpty() const;
|
2014-02-24 19:38:20 +00:00
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
/** Returns true if clip is SkRect and not empty.
|
|
|
|
Returns false if the clip is empty, or if it is not SkRect.
|
|
|
|
|
|
|
|
@return true if clip is SkRect and not empty
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Canvas_isClipRect
|
2017-09-01 17:49:54 +00:00
|
|
|
*/
|
2014-03-08 03:57:19 +00:00
|
|
|
virtual bool isClipRect() const;
|
|
|
|
|
2020-04-09 16:35:09 +00:00
|
|
|
/** Returns the current transform from local coordinates to the 'device', which for most
|
|
|
|
* purposes means pixels.
|
|
|
|
*
|
|
|
|
* @return transformation from local coordinates to device / pixels.
|
|
|
|
*/
|
|
|
|
SkM44 getLocalToDevice() const;
|
2019-03-15 19:47:01 +00:00
|
|
|
|
2020-12-03 16:21:31 +00:00
|
|
|
/**
|
|
|
|
* Throws away the 3rd row and column in the matrix, so be warned.
|
|
|
|
*/
|
|
|
|
SkMatrix getLocalToDeviceAs3x3() const {
|
|
|
|
return this->getLocalToDevice().asM33();
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SK_SUPPORT_LEGACY_GETTOTALMATRIX
|
2020-12-03 14:03:31 +00:00
|
|
|
/** DEPRECATED
|
|
|
|
* Legacy version of getLocalToDevice(), which strips away any Z information, and
|
2020-04-09 16:35:09 +00:00
|
|
|
* just returns a 3x3 version.
|
|
|
|
*
|
|
|
|
* @return 3x3 version of getLocalToDevice()
|
|
|
|
*
|
|
|
|
* example: https://fiddle.skia.org/c/@Canvas_getTotalMatrix
|
|
|
|
* example: https://fiddle.skia.org/c/@Clip
|
|
|
|
*/
|
2020-01-08 15:40:39 +00:00
|
|
|
SkMatrix getTotalMatrix() const;
|
2020-12-03 16:21:31 +00:00
|
|
|
#endif
|
2020-04-06 14:41:09 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-12-11 22:34:23 +00:00
|
|
|
#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && SK_SUPPORT_GPU
|
|
|
|
// These methods exist to support WebView in Android Framework.
|
2020-12-21 21:31:01 +00:00
|
|
|
SkIRect topLayerBounds() const;
|
2020-12-11 22:34:23 +00:00
|
|
|
GrBackendRenderTarget topLayerBackendRenderTarget() const;
|
|
|
|
#endif
|
2016-04-23 15:26:43 +00:00
|
|
|
|
2017-03-07 14:37:29 +00:00
|
|
|
/**
|
|
|
|
* Returns the global clip as a region. If the clip contains AA, then only the bounds
|
|
|
|
* of the clip may be returned.
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void temporary_internal_getRgnClip(SkRegion* region);
|
2017-01-19 16:36:41 +00:00
|
|
|
|
2017-05-17 12:53:36 +00:00
|
|
|
void private_draw_shadow_rec(const SkPath&, const SkDrawShadowRec&);
|
|
|
|
|
2018-03-15 21:34:40 +00:00
|
|
|
|
2016-04-21 18:05:32 +00:00
|
|
|
protected:
|
2014-02-05 15:32:21 +00:00
|
|
|
// default impl defers to getDevice()->newSurface(info)
|
2017-05-10 13:07:42 +00:00
|
|
|
virtual sk_sp<SkSurface> onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props);
|
2014-02-05 15:32:21 +00:00
|
|
|
|
2014-02-13 17:14:46 +00:00
|
|
|
// default impl defers to its device
|
2017-05-10 13:07:42 +00:00
|
|
|
virtual bool onPeekPixels(SkPixmap* pixmap);
|
|
|
|
virtual bool onAccessTopLayerPixels(SkPixmap* pixmap);
|
2016-07-07 23:44:27 +00:00
|
|
|
virtual SkImageInfo onImageInfo() const;
|
2017-05-10 13:07:42 +00:00
|
|
|
virtual bool onGetProps(SkSurfaceProps* props) const;
|
2016-07-07 23:44:27 +00:00
|
|
|
virtual void onFlush();
|
2014-02-13 17:14:46 +00:00
|
|
|
|
2014-03-12 20:21:48 +00:00
|
|
|
// Subclass save/restore notifiers.
|
|
|
|
// Overriders should call the corresponding INHERITED method up the inheritance chain.
|
2015-12-18 15:09:18 +00:00
|
|
|
// getSaveLayerStrategy()'s return value may suppress full layer allocation.
|
2014-03-12 20:21:48 +00:00
|
|
|
enum SaveLayerStrategy {
|
|
|
|
kFullLayer_SaveLayerStrategy,
|
2015-12-18 15:09:18 +00:00
|
|
|
kNoLayer_SaveLayerStrategy,
|
2014-03-12 20:21:48 +00:00
|
|
|
};
|
|
|
|
|
2014-06-17 20:52:18 +00:00
|
|
|
virtual void willSave() {}
|
2015-12-18 15:09:18 +00:00
|
|
|
// Overriders should call the corresponding INHERITED method up the inheritance chain.
|
2017-05-10 13:07:42 +00:00
|
|
|
virtual SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec& ) {
|
2015-12-18 15:09:18 +00:00
|
|
|
return kFullLayer_SaveLayerStrategy;
|
|
|
|
}
|
2020-04-06 19:44:17 +00:00
|
|
|
|
2018-12-18 22:38:18 +00:00
|
|
|
// returns true if we should actually perform the saveBehind, or false if we should just save.
|
|
|
|
virtual bool onDoSaveBehind(const SkRect*) { return true; }
|
2014-05-14 13:13:44 +00:00
|
|
|
virtual void willRestore() {}
|
2014-08-13 20:33:49 +00:00
|
|
|
virtual void didRestore() {}
|
2020-01-13 14:40:56 +00:00
|
|
|
|
2020-04-24 16:02:25 +00:00
|
|
|
virtual void onMarkCTM(const char*) {}
|
2020-04-07 01:32:43 +00:00
|
|
|
virtual void didConcat44(const SkM44&) {}
|
2020-11-25 18:37:30 +00:00
|
|
|
virtual void didSetM44(const SkM44&) {}
|
2020-01-13 14:40:56 +00:00
|
|
|
virtual void didTranslate(SkScalar, SkScalar) {}
|
2020-01-10 22:21:40 +00:00
|
|
|
virtual void didScale(SkScalar, SkScalar) {}
|
2016-07-21 17:25:54 +00:00
|
|
|
|
2018-03-09 18:40:31 +00:00
|
|
|
// NOTE: If you are adding a new onDraw virtual to SkCanvas, PLEASE add an override to
|
|
|
|
// SkCanvasVirtualEnforcer (in SkCanvasVirtualEnforcer.h). This ensures that subclasses using
|
|
|
|
// that mechanism will be required to implement the new function.
|
|
|
|
virtual void onDrawPaint(const SkPaint& paint);
|
2019-04-19 19:00:47 +00:00
|
|
|
virtual void onDrawBehind(const SkPaint& paint);
|
2018-03-09 18:40:31 +00:00
|
|
|
virtual void onDrawRect(const SkRect& rect, const SkPaint& paint);
|
|
|
|
virtual void onDrawRRect(const SkRRect& rrect, const SkPaint& paint);
|
2017-05-10 13:07:42 +00:00
|
|
|
virtual void onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint);
|
2018-03-09 18:40:31 +00:00
|
|
|
virtual void onDrawOval(const SkRect& rect, const SkPaint& paint);
|
|
|
|
virtual void onDrawArc(const SkRect& rect, SkScalar startAngle, SkScalar sweepAngle,
|
|
|
|
bool useCenter, const SkPaint& paint);
|
|
|
|
virtual void onDrawPath(const SkPath& path, const SkPaint& paint);
|
|
|
|
virtual void onDrawRegion(const SkRegion& region, const SkPaint& paint);
|
2014-02-21 02:32:36 +00:00
|
|
|
|
2014-08-21 15:53:26 +00:00
|
|
|
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
|
|
|
const SkPaint& paint);
|
|
|
|
|
2014-08-12 15:34:29 +00:00
|
|
|
virtual void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
|
2017-05-10 13:07:42 +00:00
|
|
|
const SkPoint texCoords[4], SkBlendMode mode, const SkPaint& paint);
|
|
|
|
virtual void onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
|
|
|
|
const SkPaint& paint);
|
2018-06-29 18:32:21 +00:00
|
|
|
|
Reland "Add new virts, hide old ones"
This reverts commit 8f924ac0ce63806886b7297e8be554984a6e7ce5.
Reason for revert: suppressions landed for fuchsia images to rebaseline
Original change's description:
> Revert "Add new virts, hide old ones"
>
> This reverts commit c56e2e5aa65dd129e5927224d2f6c1f82edff74e.
>
> Reason for revert: suspected of breaking chrome roll
>
> Original change's description:
> > Add new virts, hide old ones
> >
> > Add virtuals for the draw methods that now take sampling/filtermode.
> >
> > drawImage
> > drawImageRect
> > drawImageLattice
> > drawAtlas
> >
> > Add a flag that can remove the older virtuals, once each client has
> > stopped overriding them. In that situation, the older public methods
> > will simplify extract the sampling from the paint, and call the new
> > public methods.
> >
> > Bug: skia:11105, skia:7650
> > Change-Id: I8b0029727295caa983e8148fc743a55cfbecd043
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347022
> > Commit-Queue: Mike Reed <reed@google.com>
> > Reviewed-by: Florin Malita <fmalita@chromium.org>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,fmalita@chromium.org,reed@google.com
>
> Change-Id: I0a90952c11a180d918126ea06a630f4a0bf9b49b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11105
> Bug: skia:7650
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348194
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: Derek Sollenberger <djsollen@google.com>
TBR=djsollen@google.com,bsalomon@google.com,fmalita@chromium.org,reed@google.com
# Not skipping CQ checks because this is a reland.
Bug: skia:11105
Bug: skia:7650
Change-Id: Ia2b4537a2d330460b7554278d2c05075cf27162a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348876
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-30 14:22:42 +00:00
|
|
|
virtual void onDrawImage2(const SkImage*, SkScalar dx, SkScalar dy, const SkSamplingOptions&,
|
|
|
|
const SkPaint*);
|
|
|
|
virtual void onDrawImageRect2(const SkImage*, const SkRect& src, const SkRect& dst,
|
|
|
|
const SkSamplingOptions&, const SkPaint*, SrcRectConstraint);
|
|
|
|
virtual void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect& dst,
|
|
|
|
SkFilterMode, const SkPaint*);
|
|
|
|
virtual void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect src[],
|
|
|
|
const SkColor[], int count, SkBlendMode, const SkSamplingOptions&,
|
|
|
|
const SkRect* cull, const SkPaint*);
|
2021-01-05 17:03:47 +00:00
|
|
|
virtual void onDrawEdgeAAImageSet2(const ImageSetEntry imageSet[], int count,
|
|
|
|
const SkPoint dstClips[], const SkMatrix preViewMatrices[],
|
|
|
|
const SkSamplingOptions&, const SkPaint*,
|
|
|
|
SrcRectConstraint);
|
Reland "Add new virts, hide old ones"
This reverts commit 8f924ac0ce63806886b7297e8be554984a6e7ce5.
Reason for revert: suppressions landed for fuchsia images to rebaseline
Original change's description:
> Revert "Add new virts, hide old ones"
>
> This reverts commit c56e2e5aa65dd129e5927224d2f6c1f82edff74e.
>
> Reason for revert: suspected of breaking chrome roll
>
> Original change's description:
> > Add new virts, hide old ones
> >
> > Add virtuals for the draw methods that now take sampling/filtermode.
> >
> > drawImage
> > drawImageRect
> > drawImageLattice
> > drawAtlas
> >
> > Add a flag that can remove the older virtuals, once each client has
> > stopped overriding them. In that situation, the older public methods
> > will simplify extract the sampling from the paint, and call the new
> > public methods.
> >
> > Bug: skia:11105, skia:7650
> > Change-Id: I8b0029727295caa983e8148fc743a55cfbecd043
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347022
> > Commit-Queue: Mike Reed <reed@google.com>
> > Reviewed-by: Florin Malita <fmalita@chromium.org>
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
>
> TBR=bsalomon@google.com,fmalita@chromium.org,reed@google.com
>
> Change-Id: I0a90952c11a180d918126ea06a630f4a0bf9b49b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:11105
> Bug: skia:7650
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348194
> Reviewed-by: Derek Sollenberger <djsollen@google.com>
> Commit-Queue: Derek Sollenberger <djsollen@google.com>
TBR=djsollen@google.com,bsalomon@google.com,fmalita@chromium.org,reed@google.com
# Not skipping CQ checks because this is a reland.
Bug: skia:11105
Bug: skia:7650
Change-Id: Ia2b4537a2d330460b7554278d2c05075cf27162a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/348876
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
2020-12-30 14:22:42 +00:00
|
|
|
|
|
|
|
virtual void onDrawVerticesObject(const SkVertices* vertices, SkBlendMode mode,
|
|
|
|
const SkPaint& paint);
|
2018-03-09 18:40:31 +00:00
|
|
|
|
|
|
|
virtual void onDrawAnnotation(const SkRect& rect, const char key[], SkData* value);
|
2017-05-17 12:53:36 +00:00
|
|
|
virtual void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&);
|
2015-01-05 15:49:08 +00:00
|
|
|
|
2018-03-09 18:40:31 +00:00
|
|
|
virtual void onDrawDrawable(SkDrawable* drawable, const SkMatrix* matrix);
|
|
|
|
virtual void onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
|
|
|
|
const SkPaint* paint);
|
|
|
|
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
virtual void onDrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4], QuadAAFlags aaFlags,
|
2019-08-27 19:25:49 +00:00
|
|
|
const SkColor4f& color, SkBlendMode mode);
|
Reland "Reland "Update SkCanvas' experimental SkiaRenderer API""
This reverts commit 138a06d1b1cd035daf6b6a970c75126e94777822.
Reason for revert: add explicit constructors to ImageSetEntry to account for the new arguments,
matching SkiaRenderer's current initializer list. Also hardens SkPictureDrawback's deserialization
code for drawEdgeAAImageSet and drawEdgeAAQuad from a fuzz that was found during the CL's brief
lifespan.
Original change's description:
> Revert "Reland "Update SkCanvas' experimental SkiaRenderer API""
>
> This reverts commit bd9d88a6e4d9730f3aa67227e5a1618180513a87.
>
> Reason for revert: Breaks SkiaRenderer on Android. Rendering is all corrupted, bisected to this change.
>
> Original change's description:
> > Reland "Update SkCanvas' experimental SkiaRenderer API"
> >
> > This reverts commit 90791c202dd2d943565237bf511d929e8bd19951.
> >
> > Reason for revert: Jumped the gun, just need to update blacklist
> >
> > Original change's description:
> > > Revert "Update SkCanvas' experimental SkiaRenderer API"
> > >
> > > This reverts commit 4bf964602ab8758f6e580aaaa69add4fb260c1a6.
> > >
> > > Reason for revert: vulkan dm crashes
> > >
> > > Original change's description:
> > > > Update SkCanvas' experimental SkiaRenderer API
> > > >
> > > > This lifts the temporary functions in SkGpuDevice into SkCanvas and
> > > > deprecates the older experimental_DrawImageSetV1 and
> > > > experimental_DrawEdgeAARect. The new functions can handle paints and
> > > > transform batching. Internally, SkCanvas routes the old functions to the
> > > > new entry points and all device-level code is updated to handle the new
> > > > API features.
> > > >
> > > > While touching all of the canvas/device/recording areas, the
> > > > experimental functions are grouped in an "EdgeAA" cluster instead of being
> > > > separated into the image category and the rectangle category.
> > > >
> > > > Bug: skia:8739
> > > > Change-Id: I67c2a724873040ad5dc3307ab5b2823ba1eac54b
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/190221
> > > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > >
> > > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> > >
> > > Change-Id: I87a5a258c5a1bd15e16389cdf91743772d6fa98a
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:8739
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201226
> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
> >
> > Change-Id: I75e9b6cbf079a7739b69a7e208730a930621abf9
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:8739
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201229
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > Auto-Submit: Michael Ludwig <michaelludwig@google.com>
>
> TBR=bsalomon@google.com,robertphillips@google.com,michaelludwig@google.com
>
> Change-Id: Ib87ef9b8b8598c16a8a6915920adf0b5dffc644b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:8739
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201391
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Brian Salomon <bsalomon@google.com>
Bug: skia:8739, oss-fuzz:13794
Change-Id: Ibd7df4a398928c3170d16300bf3ade496125372c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201650
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2019-03-19 13:16:38 +00:00
|
|
|
|
2014-02-28 18:19:39 +00:00
|
|
|
enum ClipEdgeStyle {
|
|
|
|
kHard_ClipEdgeStyle,
|
|
|
|
kSoft_ClipEdgeStyle
|
|
|
|
};
|
|
|
|
|
2017-05-10 13:07:42 +00:00
|
|
|
virtual void onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle);
|
|
|
|
virtual void onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle);
|
|
|
|
virtual void onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle);
|
2020-03-10 18:02:56 +00:00
|
|
|
virtual void onClipShader(sk_sp<SkShader>, SkClipOp);
|
2017-05-10 13:07:42 +00:00
|
|
|
virtual void onClipRegion(const SkRegion& deviceRgn, SkClipOp op);
|
2014-02-28 18:19:39 +00:00
|
|
|
|
2014-03-28 16:08:05 +00:00
|
|
|
virtual void onDiscard();
|
|
|
|
|
Revert "Reland "Draw image filters directly under non-axis-aligned transforms""
This reverts commit 7712db9c246b79267c23793c591b9896f950358e.
Reason for revert: blink unittests and maybe vulkan+skiarenderer masks appear broken. The blink unittests had actually failed with original CL, but was missed because of focus on Android. Not sure what's going on yet.
Original change's description:
> Reland "Draw image filters directly under non-axis-aligned transforms"
>
> This reverts commit 6cafdc069bdb2a23dd399d18dd28942ffc60001b.
>
> Reason for revert: Fixes unit test failure in Android
>
> In the original version, this internalSaveLayer() returned early if the
> strategy was kNoLayer. This diverged from the old code that updated the
> canvas' clip bounds and then returned before making the layer. A comment
> had suggested this was maybe okay to switch to this early out, but it
> turns out that's not the case.
>
> In Android's unit tests, it queries the clip bounds on a recording canvas
> which always uses a no-layer strategy. However, we do need to set the
> clip bounds of these types of canvas' (or virtual wrappers of a real
> canvas) so that they stay consistent with a real canvas.
>
> The unit tests had two failures, first the bounds and second a color
> mismatch after reading back. However, the bounds test was an ASSERT_EQ
> inside an SkDrawable function. ASSERT_EQ aborts the current function, so
> it never ran the drawRect that sets the color to green. The later
> readback is outside the drawable function, so that test still happened
> and failed. The only real issue to fix is the clip bounds tracking; once
> that unit test succeeds, the color readback will work properly.
>
> Original change's description:
> > Revert "Draw image filters directly under non-axis-aligned transforms"
> >
> > This reverts commit f8f23b20307942710b496a41c7ea1581fe15d491.
> >
> > Reason for revert: b/172617382 is creating issues for Android's Webview
> >
> > Original change's description:
> > > Draw image filters directly under non-axis-aligned transforms
> > >
> > > This removes hacking the canvas CTM and wrapping the paint's image
> > > filter in a special MatrixTransform that computed a post-transform
> > > instead of its documented pre-transform effect. Performance-wise, the
> > > computed layer sizes should be about the same, but we avoid one less
> > > render target switch because we apply the transformation while drawing
> > > to the dst device, vs. transforming into another temporary layer and
> > > then drawing that to the dst device.
> > >
> > > Several important changes in behavior here:
> > > 1. The DeviceCM record no longer has a stashed matrix to restore and
> > > holds its restoration paint directly.
> > > 2. Devices for image filter inputs can now have device-to-global
> > > transforms that are not integer translates.
> > > 3. The MatrixTransform hack punted when there was perspective because it
> > > could produce excessively large temporary images, but the new version
> > > appears to work around that. We now impose a maximum layer size to
> > > protect against that and automatically scale the layer to prevent it.
> > > Perspective image filters otherwise now draw correctly.
> > > 6. Updated layer sizing code to use the new image filter APIs
> > > 7. Updated backdrop filter and restore filters to go through the same
> > > code paths, although restore filters skip the intermediate image
> > > transform.
> > > - layer bounds and transforms now go through the updated skif API
> > > and is hopefully more straight forward to understand.
> > > 8. Now we can optimize root color filter nodes of a filter DAG, even if
> > > the entire DAG can't be represented as a color filter. The last node
> > > is pulled off and composed with the restoration paint instead.
> > >
> > > Bug: skia:9074,skia:9283
> > > Change-Id: I1fa1d50135b9d6d453b02f89aa3cc3b54deab678
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328376
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
> >
> > Change-Id: I098d0e4b8ee067b436400eb9fea047e629544eec
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:9074
> > Bug: skia:9283
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332737
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Derek Sollenberger <djsollen@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: skia:9074
> Bug: skia:9283
> Change-Id: Ifd5fed708d05a64ddccbd096fbf29896a44ef9f5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333123
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
Change-Id: I7758641e0279ab5af44794d70cd381bc0a69f956
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9074
Bug: skia:9283
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333756
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-10 21:26:08 +00:00
|
|
|
// Clip rectangle bounds. Called internally by saveLayer.
|
|
|
|
// returns false if the entire rectangle is entirely clipped out
|
|
|
|
// If non-NULL, The imageFilter parameter will be used to expand the clip
|
|
|
|
// and offscreen bounds for any margin required by the filter DAG.
|
Reland "Simplify layer bounds syncing and no-device error handling in SkCanvas::internalSaveLayer"
This reverts commit 6c1191d749a3b9fe144466f473ca222d57898f11.
Reason for revert:
- the lowest-level issue is fixed in https://skia-review.googlesource.com/c/skia/+/337076
which prevents bad replaceClips from going beyond the device bounds
- but this also updates the original CL so that we don't call
replaceClip in these problematic situations. The old behavior of
effectively downgrading a saveLayer to a save when the new device
fails to allocate is better behavior.
- now the bounds tracking is still consolidated as before, but only
applied when the kNoLayer_Strategy is used, or the layer should be
empty (in which case replaceClip() is passed an empty rect and
everything works out).
- when the layer fails to allocate, we add a clipRegion to restrict
nested draw calls to what would have been the layers bounds, while
still respecting the old clip (that normally would have been applied
on the layer restore, but won't because there's no layer). This is
somewhat pedantic, and is probably a rare case in the wild, but it
makes some of our SkCanvas tests easier to deal with.
- This is because, if you just make an SkCanvas(width, height) directly
you get an SkNoPixelsDevice but also use the kFullLayer_Strategy.
SkNoPixelsDevice always fails to create a layer (since it's meant to
be used with subclasses of SkCanvas that return kNoLayer_Strategy,
like SkNoDrawCanvas).
- applying the failed layer bounds as a clip keeps the canvas' reported
bounds as accurate as possible in this case.
- in the future, it may be worth updating how SkCanvas can be
constructed to avoid this, and overhauling the unit tests but
I didn't want to further delay these changes.
- it's important that replaceClip() is still used for the kNoLayer case
because it allows image-filtered layers to expand the clip bounds
until the restore. This keeps any virtual canvas or recording canvas
completely in-sync with the base canvas or eventual real canvas that
is backed by a device that actually draws.
Original change's description:
> Revert "Simplify layer bounds syncing and no-device error handling in SkCanvas::internalSaveLayer"
>
> This reverts commit b27ba538ecd0bb52981c33a9f5731022cd165bdd.
>
> Reason for revert: causes invalid memory accesses due to replaceClip use, and replaceClip() is probably not the right operation to use
> to emulate a layer when no layer was the strategy or failed to allocate.
>
> Original change's description:
> > Simplify layer bounds syncing and no-device error handling in SkCanvas::internalSaveLayer
> >
> > This corrects some subtle bugs that can occur with recording canvas or
> > if a device fails to be created for a new layer, where the stashed
> > matrix would not be restored properly. Since no new DeviceCM would get
> > added in those cases, the canvas' total matrix wouldn't get fixed in the
> > paired onRestore() and it would remain dirty for the remainder of the
> > canvas's lifetime.
> >
> > After this change, the underlying SkDevice's bounds are also kept in
> > sync with the intent of the saveLayer when kNoLayer_Strategy is used.
> > Previously, the bounds would be applied to the canvas' conservative clip
> > and quick reject bounds, but the device would remain un-updated. As we
> > move towards SkNoPixelsDevice taking over the conservative clip bounds,
> > this ensures bounds remain up to date within a saveLayer/restore pair
> > even if no layer was allocated.
> >
> > Change-Id: I5ca389bdd624ea7278106da863a96e9d8f90e2d1
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335861
> > Reviewed-by: Mike Reed <reed@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com
>
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:1151195, chromium:1151270, chromium:1151294, chromium:1151320, chromium:1151322
> Change-Id: I9db07916ffc450cc6ecc9188d72bb7c35770a974
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337117
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com
# Not skipping CQ checks because this is a reland.
Change-Id: Idcab9084c7f19d8f31b11231fd9b52292fc397a3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/337157
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-21 17:40:00 +00:00
|
|
|
bool clipRectBounds(const SkRect* bounds, SkIRect* intersection,
|
Revert "Reland "Draw image filters directly under non-axis-aligned transforms""
This reverts commit 7712db9c246b79267c23793c591b9896f950358e.
Reason for revert: blink unittests and maybe vulkan+skiarenderer masks appear broken. The blink unittests had actually failed with original CL, but was missed because of focus on Android. Not sure what's going on yet.
Original change's description:
> Reland "Draw image filters directly under non-axis-aligned transforms"
>
> This reverts commit 6cafdc069bdb2a23dd399d18dd28942ffc60001b.
>
> Reason for revert: Fixes unit test failure in Android
>
> In the original version, this internalSaveLayer() returned early if the
> strategy was kNoLayer. This diverged from the old code that updated the
> canvas' clip bounds and then returned before making the layer. A comment
> had suggested this was maybe okay to switch to this early out, but it
> turns out that's not the case.
>
> In Android's unit tests, it queries the clip bounds on a recording canvas
> which always uses a no-layer strategy. However, we do need to set the
> clip bounds of these types of canvas' (or virtual wrappers of a real
> canvas) so that they stay consistent with a real canvas.
>
> The unit tests had two failures, first the bounds and second a color
> mismatch after reading back. However, the bounds test was an ASSERT_EQ
> inside an SkDrawable function. ASSERT_EQ aborts the current function, so
> it never ran the drawRect that sets the color to green. The later
> readback is outside the drawable function, so that test still happened
> and failed. The only real issue to fix is the clip bounds tracking; once
> that unit test succeeds, the color readback will work properly.
>
> Original change's description:
> > Revert "Draw image filters directly under non-axis-aligned transforms"
> >
> > This reverts commit f8f23b20307942710b496a41c7ea1581fe15d491.
> >
> > Reason for revert: b/172617382 is creating issues for Android's Webview
> >
> > Original change's description:
> > > Draw image filters directly under non-axis-aligned transforms
> > >
> > > This removes hacking the canvas CTM and wrapping the paint's image
> > > filter in a special MatrixTransform that computed a post-transform
> > > instead of its documented pre-transform effect. Performance-wise, the
> > > computed layer sizes should be about the same, but we avoid one less
> > > render target switch because we apply the transformation while drawing
> > > to the dst device, vs. transforming into another temporary layer and
> > > then drawing that to the dst device.
> > >
> > > Several important changes in behavior here:
> > > 1. The DeviceCM record no longer has a stashed matrix to restore and
> > > holds its restoration paint directly.
> > > 2. Devices for image filter inputs can now have device-to-global
> > > transforms that are not integer translates.
> > > 3. The MatrixTransform hack punted when there was perspective because it
> > > could produce excessively large temporary images, but the new version
> > > appears to work around that. We now impose a maximum layer size to
> > > protect against that and automatically scale the layer to prevent it.
> > > Perspective image filters otherwise now draw correctly.
> > > 6. Updated layer sizing code to use the new image filter APIs
> > > 7. Updated backdrop filter and restore filters to go through the same
> > > code paths, although restore filters skip the intermediate image
> > > transform.
> > > - layer bounds and transforms now go through the updated skif API
> > > and is hopefully more straight forward to understand.
> > > 8. Now we can optimize root color filter nodes of a filter DAG, even if
> > > the entire DAG can't be represented as a color filter. The last node
> > > is pulled off and composed with the restoration paint instead.
> > >
> > > Bug: skia:9074,skia:9283
> > > Change-Id: I1fa1d50135b9d6d453b02f89aa3cc3b54deab678
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328376
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
> >
> > Change-Id: I098d0e4b8ee067b436400eb9fea047e629544eec
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:9074
> > Bug: skia:9283
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332737
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Derek Sollenberger <djsollen@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: skia:9074
> Bug: skia:9283
> Change-Id: Ifd5fed708d05a64ddccbd096fbf29896a44ef9f5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333123
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
Change-Id: I7758641e0279ab5af44794d70cd381bc0a69f956
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9074
Bug: skia:9283
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333756
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-10 21:26:08 +00:00
|
|
|
const SkImageFilter* imageFilter = nullptr);
|
|
|
|
|
2015-07-16 14:40:45 +00:00
|
|
|
private:
|
Revert "Reland "Draw image filters directly under non-axis-aligned transforms""
This reverts commit 7712db9c246b79267c23793c591b9896f950358e.
Reason for revert: blink unittests and maybe vulkan+skiarenderer masks appear broken. The blink unittests had actually failed with original CL, but was missed because of focus on Android. Not sure what's going on yet.
Original change's description:
> Reland "Draw image filters directly under non-axis-aligned transforms"
>
> This reverts commit 6cafdc069bdb2a23dd399d18dd28942ffc60001b.
>
> Reason for revert: Fixes unit test failure in Android
>
> In the original version, this internalSaveLayer() returned early if the
> strategy was kNoLayer. This diverged from the old code that updated the
> canvas' clip bounds and then returned before making the layer. A comment
> had suggested this was maybe okay to switch to this early out, but it
> turns out that's not the case.
>
> In Android's unit tests, it queries the clip bounds on a recording canvas
> which always uses a no-layer strategy. However, we do need to set the
> clip bounds of these types of canvas' (or virtual wrappers of a real
> canvas) so that they stay consistent with a real canvas.
>
> The unit tests had two failures, first the bounds and second a color
> mismatch after reading back. However, the bounds test was an ASSERT_EQ
> inside an SkDrawable function. ASSERT_EQ aborts the current function, so
> it never ran the drawRect that sets the color to green. The later
> readback is outside the drawable function, so that test still happened
> and failed. The only real issue to fix is the clip bounds tracking; once
> that unit test succeeds, the color readback will work properly.
>
> Original change's description:
> > Revert "Draw image filters directly under non-axis-aligned transforms"
> >
> > This reverts commit f8f23b20307942710b496a41c7ea1581fe15d491.
> >
> > Reason for revert: b/172617382 is creating issues for Android's Webview
> >
> > Original change's description:
> > > Draw image filters directly under non-axis-aligned transforms
> > >
> > > This removes hacking the canvas CTM and wrapping the paint's image
> > > filter in a special MatrixTransform that computed a post-transform
> > > instead of its documented pre-transform effect. Performance-wise, the
> > > computed layer sizes should be about the same, but we avoid one less
> > > render target switch because we apply the transformation while drawing
> > > to the dst device, vs. transforming into another temporary layer and
> > > then drawing that to the dst device.
> > >
> > > Several important changes in behavior here:
> > > 1. The DeviceCM record no longer has a stashed matrix to restore and
> > > holds its restoration paint directly.
> > > 2. Devices for image filter inputs can now have device-to-global
> > > transforms that are not integer translates.
> > > 3. The MatrixTransform hack punted when there was perspective because it
> > > could produce excessively large temporary images, but the new version
> > > appears to work around that. We now impose a maximum layer size to
> > > protect against that and automatically scale the layer to prevent it.
> > > Perspective image filters otherwise now draw correctly.
> > > 6. Updated layer sizing code to use the new image filter APIs
> > > 7. Updated backdrop filter and restore filters to go through the same
> > > code paths, although restore filters skip the intermediate image
> > > transform.
> > > - layer bounds and transforms now go through the updated skif API
> > > and is hopefully more straight forward to understand.
> > > 8. Now we can optimize root color filter nodes of a filter DAG, even if
> > > the entire DAG can't be represented as a color filter. The last node
> > > is pulled off and composed with the restoration paint instead.
> > >
> > > Bug: skia:9074,skia:9283
> > > Change-Id: I1fa1d50135b9d6d453b02f89aa3cc3b54deab678
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/328376
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> >
> > TBR=bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
> >
> > Change-Id: I098d0e4b8ee067b436400eb9fea047e629544eec
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:9074
> > Bug: skia:9283
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/332737
> > Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> > Reviewed-by: Derek Sollenberger <djsollen@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
>
> # Not skipping CQ checks because original CL landed > 1 day ago.
>
> Bug: skia:9074
> Bug: skia:9283
> Change-Id: Ifd5fed708d05a64ddccbd096fbf29896a44ef9f5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333123
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=djsollen@google.com,bsalomon@google.com,robertphillips@google.com,fmalita@google.com,reed@google.com,michaelludwig@google.com
Change-Id: I7758641e0279ab5af44794d70cd381bc0a69f956
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:9074
Bug: skia:9283
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333756
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-11-10 21:26:08 +00:00
|
|
|
static void DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* filter,
|
|
|
|
SkBaseDevice* dst, const SkIPoint& dstOrigin,
|
|
|
|
const SkMatrix& ctm);
|
|
|
|
|
2015-07-16 14:40:45 +00:00
|
|
|
enum ShaderOverrideOpacity {
|
|
|
|
kNone_ShaderOverrideOpacity, //!< there is no overriding shader (bitmap or image)
|
|
|
|
kOpaque_ShaderOverrideOpacity, //!< the overriding shader is opaque
|
|
|
|
kNotOpaque_ShaderOverrideOpacity, //!< the overriding shader may not be opaque
|
|
|
|
};
|
|
|
|
|
2012-08-28 12:19:02 +00:00
|
|
|
// notify our surface (if we have one) that we are about to draw, so it
|
|
|
|
// can perform copy-on-write or invalidate any cached images
|
2015-07-16 14:40:45 +00:00
|
|
|
void predrawNotify(bool willOverwritesEntireSurface = false);
|
|
|
|
void predrawNotify(const SkRect* rect, const SkPaint* paint, ShaderOverrideOpacity);
|
2012-08-28 12:19:02 +00:00
|
|
|
|
2020-12-17 15:32:24 +00:00
|
|
|
// The bottom-most device in the stack, only changed by init(). Image properties and the final
|
|
|
|
// canvas pixels are determined by this device.
|
|
|
|
SkBaseDevice* baseDevice() const {
|
|
|
|
SkASSERT(fBaseDevice);
|
|
|
|
return fBaseDevice.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
// The top-most device in the stack, will change within saveLayer()'s. All drawing and clipping
|
|
|
|
// operations should route to this device.
|
|
|
|
SkBaseDevice* topDevice() const;
|
2020-12-23 14:16:59 +00:00
|
|
|
virtual GrSurfaceDrawContext* topDeviceSurfaceDrawContext();
|
2017-01-13 16:56:38 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
class MCRec;
|
|
|
|
|
|
|
|
SkDeque fMCStack;
|
|
|
|
// points to top of stack
|
|
|
|
MCRec* fMCRec;
|
2018-04-26 12:32:37 +00:00
|
|
|
|
2020-04-14 13:16:40 +00:00
|
|
|
sk_sp<SkMarkerStack> fMarkerStack;
|
2020-01-16 18:58:22 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
// the first N recs that can fit here mean we won't call malloc
|
Reland "Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice"
This reverts commit 8636e13c2d4e03e84fe6e66f71c932f3be30df35.
Reason for revert: recording canvases with really big float bounds could
produce a non-empty integer rect bounds that became empty after mapping
it to (0,0,w,h) for the device. This meant resetForNextPictures logic of
updating QR bounds directly from the input bounds allowed state to become
inconsistent with computeDevClipBounds().
PS1->PS4 shows the 1-liner to just compute bounds from the device. This
means that, for now, we preserve the behavior of setting the QR bounds to
be actually empty. skbug.com/10997 is added to fix the underlying issue
with recorders and excessively large float bounds. If that change landed
first, I'd be able to reland this w/o any modifications, but have decided
that it's better to have all locations that modify fQuickRejectBounds use
the exact same expression.
Original change's description:
> Revert "Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice"
>
> This reverts commit 11a394759a656154c877b610262e13f74e1022fe.
>
> Reason for revert: assert during google3 tests.
>
> Original change's description:
> > Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice
> >
> > Change-Id: I56670b4a4159e21eaa1a58a9a3ee439298d5aa8e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335863
> > Reviewed-by: Mike Reed <reed@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com
>
> Change-Id: I7c3a8797460113d9a8ef18d82bbbd64aba2f439c
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338316
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com
# Not skipping CQ checks because this is a reland.
Change-Id: I1b33e128b4fb4e06b8c7a6ee9b9dcc67202674d8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338322
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-11-25 14:21:10 +00:00
|
|
|
static constexpr int kMCRecSize = 96; // most recent measurement
|
|
|
|
static constexpr int kMCRecCount = 32; // common depth for save/restores
|
2018-04-26 12:32:37 +00:00
|
|
|
|
2015-04-07 11:40:48 +00:00
|
|
|
intptr_t fMCRecStorage[kMCRecSize * kMCRecCount / sizeof(intptr_t)];
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2020-12-09 00:22:45 +00:00
|
|
|
// Installed via init()
|
|
|
|
sk_sp<SkBaseDevice> fBaseDevice;
|
2014-09-22 14:29:03 +00:00
|
|
|
const SkSurfaceProps fProps;
|
|
|
|
|
2014-12-11 15:07:37 +00:00
|
|
|
int fSaveCount; // value returned by getSaveCount()
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-01-10 16:58:39 +00:00
|
|
|
std::unique_ptr<SkRasterHandleAllocator> fAllocator;
|
2012-09-26 02:24:45 +00:00
|
|
|
|
2012-08-28 12:19:02 +00:00
|
|
|
SkSurface_Base* fSurfaceBase;
|
|
|
|
SkSurface_Base* getSurfaceBase() const { return fSurfaceBase; }
|
|
|
|
void setSurfaceBase(SkSurface_Base* sb) {
|
|
|
|
fSurfaceBase = sb;
|
|
|
|
}
|
|
|
|
friend class SkSurface_Base;
|
2013-04-11 17:52:05 +00:00
|
|
|
friend class SkSurface_Gpu;
|
2012-10-11 02:01:14 +00:00
|
|
|
|
2016-12-12 22:39:55 +00:00
|
|
|
SkIRect fClipRestrictionRect = SkIRect::MakeEmpty();
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-12-11 15:07:37 +00:00
|
|
|
void doSave();
|
|
|
|
void checkForDeferredSave();
|
2020-11-25 18:37:30 +00:00
|
|
|
void internalSetMatrix(const SkM44&);
|
2014-12-11 15:07:37 +00:00
|
|
|
|
2017-08-02 19:36:24 +00:00
|
|
|
friend class SkAndroidFrameworkUtils;
|
2020-12-09 00:22:45 +00:00
|
|
|
friend class SkCanvasPriv; // needs to expose android functions for testing outside android
|
2019-07-30 14:48:15 +00:00
|
|
|
friend class AutoLayerForImageFilter;
|
2014-06-30 16:05:34 +00:00
|
|
|
friend class SkSurface_Raster; // needs getDevice()
|
2018-10-04 15:04:48 +00:00
|
|
|
friend class SkNoDrawCanvas; // needs resetForNextPicture()
|
2015-07-16 14:40:45 +00:00
|
|
|
friend class SkPictureRecord; // predrawNotify (why does it need it? <reed>)
|
2016-11-22 16:31:41 +00:00
|
|
|
friend class SkOverdrawCanvas;
|
2017-01-10 16:58:39 +00:00
|
|
|
friend class SkRasterHandleAllocator;
|
2018-03-09 18:40:31 +00:00
|
|
|
protected:
|
|
|
|
// For use by SkNoDrawCanvas (via SkCanvasVirtualEnforcer, which can't be a friend)
|
2018-10-04 15:04:48 +00:00
|
|
|
SkCanvas(const SkIRect& bounds);
|
2018-03-09 18:40:31 +00:00
|
|
|
private:
|
2017-01-10 16:58:39 +00:00
|
|
|
SkCanvas(const SkBitmap&, std::unique_ptr<SkRasterHandleAllocator>,
|
|
|
|
SkRasterHandleAllocator::Handle);
|
Revert of Revert of allow canvas to force conservative clips (for speed) (patchset #1 id:1 of https://codereview.chromium.org/554033003/)
Reason for revert:
May just rebaseline, plus want to see the results of the chrome tests, so re-trying this CL.
Original issue's description:
> Revert of allow canvas to force conservative clips (for speed) (patchset #7 id:120001 of https://codereview.chromium.org/541593005/)
>
> Reason for revert:
> multipicturedraw failed on nvprmsaa -- don't know why yet
>
> Original issue's description:
> > Allow SkCanvas to be initialized to force conservative rasterclips. This has the following effects:
> >
> > 1. Queries to the current clip will be conservatively large. This can mean the quickReject may return false more often.
> >
> > 2. The conservative clips mean less work is done.
> >
> > 3. Enabled by default for Gpu, Record, and NoSaveLayer canvases.
> >
> > 4. API is private for now.
> >
> > Committed: https://skia.googlesource.com/skia/+/27a5e656c3d6ef22f9cb34de18e1b960da3aa241
>
> TBR=robertphillips@google.com,bsalomon@google.com,mtklein@google.com,junov@google.com
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://skia.googlesource.com/skia/+/6f09709519b79a1159f3826645f1c5fbc101ee11
R=robertphillips@google.com, bsalomon@google.com, mtklein@google.com, junov@google.com, reed@google.com
TBR=bsalomon@google.com, junov@google.com, mtklein@google.com, reed@google.com, robertphillips@google.com
NOTREECHECKS=true
NOTRY=true
Author: reed@chromium.org
Review URL: https://codereview.chromium.org/560713002
2014-09-10 01:46:22 +00:00
|
|
|
|
2018-06-16 00:27:52 +00:00
|
|
|
SkCanvas(SkCanvas&&) = delete;
|
|
|
|
SkCanvas(const SkCanvas&) = delete;
|
|
|
|
SkCanvas& operator=(SkCanvas&&) = delete;
|
|
|
|
SkCanvas& operator=(const SkCanvas&) = delete;
|
|
|
|
|
2018-12-18 22:38:18 +00:00
|
|
|
/** Experimental
|
|
|
|
* Saves the specified subset of the current pixels in the current layer,
|
|
|
|
* and then clears those pixels to transparent black.
|
|
|
|
* Restores the pixels on restore() by drawing them in SkBlendMode::kDstOver.
|
|
|
|
*
|
|
|
|
* @param subset conservative bounds of the area to be saved / restored.
|
|
|
|
* @return depth of save state stack before this call was made.
|
|
|
|
*/
|
|
|
|
int only_axis_aligned_saveBehind(const SkRect* subset);
|
|
|
|
|
2019-04-19 19:00:47 +00:00
|
|
|
/**
|
|
|
|
* Like drawPaint, but magically clipped to the most recent saveBehind buffer rectangle.
|
|
|
|
* If there is no active saveBehind, then this draws nothing.
|
|
|
|
*/
|
|
|
|
void drawClippedToSaveBehind(const SkPaint&);
|
|
|
|
|
2015-04-08 18:25:48 +00:00
|
|
|
void resetForNextPicture(const SkIRect& bounds);
|
|
|
|
|
2014-09-04 19:45:18 +00:00
|
|
|
// needs gettotalclip()
|
2014-10-10 13:19:09 +00:00
|
|
|
friend class SkCanvasStateUtils;
|
2014-09-24 20:03:30 +00:00
|
|
|
|
2018-10-04 15:04:48 +00:00
|
|
|
void init(sk_sp<SkBaseDevice>);
|
2011-09-07 11:57:34 +00:00
|
|
|
|
2020-12-08 00:53:31 +00:00
|
|
|
// All base onDrawX() functions should call this and skip drawing if it returns true.
|
|
|
|
// If 'matrix' is non-null, it maps the paint's fast bounds before checking for quick rejection
|
|
|
|
bool internalQuickReject(const SkRect& bounds, const SkPaint& paint,
|
|
|
|
const SkMatrix* matrix = nullptr);
|
|
|
|
|
2011-10-05 19:57:55 +00:00
|
|
|
void internalDrawPaint(const SkPaint& paint);
|
2015-12-18 15:09:18 +00:00
|
|
|
void internalSaveLayer(const SaveLayerRec&, SaveLayerStrategy);
|
2018-12-18 22:38:18 +00:00
|
|
|
void internalSaveBehind(const SkRect*);
|
2021-01-02 17:57:04 +00:00
|
|
|
void internalDrawDevice(SkBaseDevice*, const SkSamplingOptions&, const SkPaint*);
|
2011-10-05 19:57:55 +00:00
|
|
|
|
2020-04-06 19:44:17 +00:00
|
|
|
void internalConcat44(const SkM44&);
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
// shared by save() and saveLayer()
|
2014-12-11 15:07:37 +00:00
|
|
|
void internalSave();
|
2008-12-17 15:59:43 +00:00
|
|
|
void internalRestore();
|
2011-01-11 18:32:13 +00:00
|
|
|
|
2015-07-16 14:40:45 +00:00
|
|
|
/*
|
|
|
|
* Returns true if drawing the specified rect (or all if it is null) with the specified
|
|
|
|
* paint (or default if null) would overwrite the entire root device of the canvas
|
|
|
|
* (i.e. the canvas' surface if it had one).
|
|
|
|
*/
|
|
|
|
bool wouldOverwriteEntireSurface(const SkRect*, const SkPaint*, ShaderOverrideOpacity) const;
|
|
|
|
|
2015-12-05 21:07:27 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the paint's imagefilter can be invoked directly, without needed a layer.
|
|
|
|
*/
|
2020-12-21 14:33:59 +00:00
|
|
|
bool canDrawBitmapAsSprite(SkScalar x, SkScalar y, int w, int h, const SkSamplingOptions&,
|
|
|
|
const SkPaint&);
|
2015-07-16 14:40:45 +00:00
|
|
|
|
2017-03-07 14:37:29 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the clip (for any active layer) contains antialiasing.
|
|
|
|
* If the clip is empty, this will return false.
|
2017-01-16 01:02:32 +00:00
|
|
|
*/
|
2017-03-07 14:37:29 +00:00
|
|
|
bool androidFramework_isClipAA() const;
|
2016-08-12 15:29:08 +00:00
|
|
|
|
2020-06-25 20:19:03 +00:00
|
|
|
/**
|
|
|
|
* Reset the clip to be just the intersection with the global-space 'rect'. This operates within
|
|
|
|
* the save/restore stack of the canvas, so restore() will bring back any saved clip. However,
|
|
|
|
* since 'rect' is already in global space, it is not modified by the canvas matrix.
|
|
|
|
*/
|
|
|
|
void androidFramework_replaceClip(const SkIRect& rect);
|
|
|
|
|
2019-03-28 20:39:58 +00:00
|
|
|
virtual SkPaintFilterCanvas* internal_private_asPaintFilterCanvas() const { return nullptr; }
|
|
|
|
|
2016-08-12 15:29:08 +00:00
|
|
|
/**
|
|
|
|
* Keep track of the device clip bounds and if the matrix is scale-translate. This allows
|
|
|
|
* us to do a fast quick reject in the common case.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2016-08-18 21:03:30 +00:00
|
|
|
bool fIsScaleTranslate;
|
2020-11-18 16:36:19 +00:00
|
|
|
SkRect fQuickRejectBounds;
|
2016-08-12 15:29:08 +00:00
|
|
|
|
Reland "Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice"
This reverts commit 8636e13c2d4e03e84fe6e66f71c932f3be30df35.
Reason for revert: recording canvases with really big float bounds could
produce a non-empty integer rect bounds that became empty after mapping
it to (0,0,w,h) for the device. This meant resetForNextPictures logic of
updating QR bounds directly from the input bounds allowed state to become
inconsistent with computeDevClipBounds().
PS1->PS4 shows the 1-liner to just compute bounds from the device. This
means that, for now, we preserve the behavior of setting the QR bounds to
be actually empty. skbug.com/10997 is added to fix the underlying issue
with recorders and excessively large float bounds. If that change landed
first, I'd be able to reland this w/o any modifications, but have decided
that it's better to have all locations that modify fQuickRejectBounds use
the exact same expression.
Original change's description:
> Revert "Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice"
>
> This reverts commit 11a394759a656154c877b610262e13f74e1022fe.
>
> Reason for revert: assert during google3 tests.
>
> Original change's description:
> > Move conservative bounds tracking from SkCanvas to SkNoPixelsDevice
> >
> > Change-Id: I56670b4a4159e21eaa1a58a9a3ee439298d5aa8e
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/335863
> > Reviewed-by: Mike Reed <reed@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
>
> TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com
>
> Change-Id: I7c3a8797460113d9a8ef18d82bbbd64aba2f439c
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338316
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
TBR=mtklein@google.com,bsalomon@google.com,reed@google.com,michaelludwig@google.com
# Not skipping CQ checks because this is a reland.
Change-Id: I1b33e128b4fb4e06b8c7a6ee9b9dcc67202674d8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338322
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
2020-11-25 14:21:10 +00:00
|
|
|
// Compute the clip's bounds based on all clipped SkDevice's reported device bounds transformed
|
|
|
|
// into the canvas' global space.
|
|
|
|
SkRect computeDeviceClipBounds() const;
|
|
|
|
|
2020-12-11 00:19:40 +00:00
|
|
|
class AutoUpdateQRBounds;
|
2011-02-22 19:12:23 +00:00
|
|
|
void validateClip() const;
|
2012-06-21 20:25:03 +00:00
|
|
|
|
2018-06-07 16:44:09 +00:00
|
|
|
std::unique_ptr<SkGlyphRunBuilder> fScratchGlyphRunBuilder;
|
2018-06-04 19:49:15 +00:00
|
|
|
|
2020-09-03 02:42:33 +00:00
|
|
|
using INHERITED = SkRefCnt;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** \class SkAutoCanvasRestore
|
2018-04-03 15:49:10 +00:00
|
|
|
Stack helper class calls SkCanvas::restoreToCount when SkAutoCanvasRestore
|
2017-10-30 15:48:35 +00:00
|
|
|
goes out of scope. Use this to guarantee that the canvas is restored to a known
|
|
|
|
state.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2018-06-14 18:57:12 +00:00
|
|
|
class SkAutoCanvasRestore {
|
2018-06-15 09:11:24 +00:00
|
|
|
public:
|
2018-07-02 19:20:10 +00:00
|
|
|
|
2018-11-07 19:59:03 +00:00
|
|
|
/** Preserves SkCanvas::save() count. Optionally saves SkCanvas clip and SkCanvas matrix.
|
2017-10-30 15:48:35 +00:00
|
|
|
|
|
|
|
@param canvas SkCanvas to guard
|
|
|
|
@param doSave call SkCanvas::save()
|
|
|
|
@return utility to restore SkCanvas state on destructor
|
|
|
|
*/
|
2013-10-14 15:28:01 +00:00
|
|
|
SkAutoCanvasRestore(SkCanvas* canvas, bool doSave) : fCanvas(canvas), fSaveCount(0) {
|
|
|
|
if (fCanvas) {
|
|
|
|
fSaveCount = canvas->getSaveCount();
|
|
|
|
if (doSave) {
|
|
|
|
canvas->save();
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
}
|
2017-10-30 15:48:35 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** Restores SkCanvas to saved state. Destructor is called when container goes out of
|
|
|
|
scope.
|
2017-10-30 15:48:35 +00:00
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
~SkAutoCanvasRestore() {
|
2012-11-20 15:12:21 +00:00
|
|
|
if (fCanvas) {
|
|
|
|
fCanvas->restoreToCount(fSaveCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** Restores SkCanvas to saved state immediately. Subsequent calls and
|
2018-11-29 17:05:25 +00:00
|
|
|
~SkAutoCanvasRestore() have no effect.
|
2017-10-30 15:48:35 +00:00
|
|
|
*/
|
2012-11-20 15:12:21 +00:00
|
|
|
void restore() {
|
|
|
|
if (fCanvas) {
|
|
|
|
fCanvas->restoreToCount(fSaveCount);
|
2017-08-28 14:34:05 +00:00
|
|
|
fCanvas = nullptr;
|
2012-11-20 15:12:21 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SkCanvas* fCanvas;
|
|
|
|
int fSaveCount;
|
2018-06-16 00:27:52 +00:00
|
|
|
|
|
|
|
SkAutoCanvasRestore(SkAutoCanvasRestore&&) = delete;
|
|
|
|
SkAutoCanvasRestore(const SkAutoCanvasRestore&) = delete;
|
|
|
|
SkAutoCanvasRestore& operator=(SkAutoCanvasRestore&&) = delete;
|
|
|
|
SkAutoCanvasRestore& operator=(const SkAutoCanvasRestore&) = delete;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
2018-11-29 17:05:25 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
#endif
|