47#include <initializer_list>
55#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
68#if defined(SK_GRAPHITE)
149template <
typename F>
static void multi_canvas_driver(
int w,
int h,
F proc) {
160const SkIRect gBaseRestrictedR = { 0, 0, 10, 10 };
165 const SkIRect restrictionR = { 2, 2, 8, 8 };
169 const SkIRect clipR = { 4, 4, 6, 6 };
183 multi_canvas_driver(gBaseRestrictedR.
width(), gBaseRestrictedR.
height(),
201 const size_t minRowBytes =
info.minRowBytes();
202 const size_t size =
info.computeByteSize(minRowBytes);
215 for (
int y = 0;
y <
info.height(); ++
y) {
216 for (
int x = 0;
x <
info.width(); ++
x) {
231 info =
info.makeWH(1 << 30, 1 << 30);
389 paint.setColor(0xFFFFFFFF);
412 SkCanvas referenceCanvas(referenceStore);
435 int n = canvas.
save();
484 canvas.
scale(0.5f, 0.75f);
486 MockFilterCanvas filterCanvas(&canvas);
491 filterCanvas.scale(0.75f, 0.5f);
502class LifeLineCanvas :
public SkCanvas {
505 LifeLineCanvas(
int w,
int h,
bool* lifeline) :
SkCanvas(
w,
h), fLifeLine(lifeline) {
508 ~LifeLineCanvas()
override {
521 LifeLineCanvas c0(
w,
h, &life[0]);
527 std::unique_ptr<SkCanvas> c0 = std::unique_ptr<SkCanvas>(
new LifeLineCanvas(
w,
h, &life[0]));
528 std::unique_ptr<SkCanvas> c1 = std::unique_ptr<SkCanvas>(
new LifeLineCanvas(
w,
h, &life[1]));
549 std::unique_ptr<SkCanvas> c0 = std::unique_ptr<SkCanvas>(
new LifeLineCanvas(
w,
h, &life[0]));
550 std::unique_ptr<SkCanvas> c1 = std::unique_ptr<SkCanvas>(
new LifeLineCanvas(
w,
h, &life[1]));
605#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
606DEF_TEST(Canvas_LegacyColorBehavior, r) {
613 bitmap.eraseColor(0xFF000000);
625DEF_TEST(Canvas_SaveLayerWithNullBoundsAndZeroBoundsImageFilter, r) {
644 const int big = 100 * 1024;
698 auto do_test = [&](
int saveCount,
int restoreCount) {
699 SkASSERT(restoreCount <= saveCount);
702 auto canvas = surf->getCanvas();
707 for (
int i = 0;
i < saveCount; ++
i) {
715 for (
int i = 0;
i < restoreCount; ++
i) {
742 auto canvas = surf->getCanvas();
759 for (
int i = 0;
i < 10000; ++
i) {
760 paint.setColor((0xFF << 24) |
i);
765#if defined(SK_GANESH)
779#if defined(SK_GRAPHITE)
786 std::unique_ptr<Recorder> recorder = context->makeRecorder();
void test_many_draws(skiatest::Reporter *reporter, SkSurface *surface)
static CanvasTest kCanvasTests[]
static void test_cliptype(SkCanvas *canvas, skiatest::Reporter *r)
static constexpr SkColor kColor
static SkRegion make_region_from_irect(SkIRect r)
static SkBitmap make_n32_bitmap(int w, int h, SkColor c=SK_ColorWHITE)
static constexpr SkRect kRect
static SkPath make_path_from_rect(SkRect r)
void(*)(SkCanvas *, skiatest::Reporter *) CanvasTest
static constexpr int kWidth
static constexpr int kHeight
DEF_TEST(canvas_unsorted_clip, r)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
sk_bzero(glyphs, sizeof(glyphs))
bool check_pixels(skiatest::Reporter *reporter, GrDirectContext *dContext, const GrBackendTexture &tex, const SkImageInfo &info, SkColor expectedColor)
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static SkPMColor SkSwizzle_BGRA_to_PMColor(uint32_t c)
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkColorType
uninitialized
SK_API SkPMColor SkPreMultiplyColor(SkColor c)
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
#define INHERITED(method,...)
#define SK_ScalarNearlyZero
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS(name, reporter, graphite_context, ctsEnforcement)
#define DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(name, reporter, context_info, ctsEnforcement)
void allocN32Pixels(int width, int height, bool isOpaque=false)
bool setInfo(const SkImageInfo &imageInfo, size_t rowBytes=0)
void eraseColor(SkColor4f) const
void pushCanvas(std::unique_ptr< SkCanvas >, const SkIPoint &origin)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
virtual bool isClipEmpty() const
void translate(SkScalar dx, SkScalar dy)
void androidFramework_setDeviceClipRestriction(const SkIRect &rect)
SkRect getLocalClipBounds() const
virtual bool isClipRect() const
void drawPaint(const SkPaint &paint)
virtual SkISize getBaseLayerSize() const
void clipRegion(const SkRegion &deviceRgn, SkClipOp op=SkClipOp::kIntersect)
void drawIRect(const SkIRect &rect, const SkPaint &paint)
void clear(SkColor color)
void rotate(SkScalar degrees)
void restoreToCount(int saveCount)
SkMatrix getTotalMatrix() const
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
SkIRect getDeviceClipBounds() const
void drawPath(const SkPath &path, const SkPaint &paint)
void setMatrix(const SkM44 &matrix)
void scale(SkScalar sx, SkScalar sy)
void concat(const SkMatrix &matrix)
void drawPicture(const SkPicture *picture)
static std::unique_ptr< SkCanvas > MakeRasterDirect(const SkImageInfo &info, void *pixels, size_t rowBytes, const SkSurfaceProps *props=nullptr)
void drawVertices(const SkVertices *vertices, SkBlendMode mode, const SkPaint &paint)
SkImageInfo imageInfo() const
void skew(SkScalar sx, SkScalar sy)
static sk_sp< SkColorSpace > MakeSRGB()
sk_sp< SkColorSpace > makeColorSpin() const
static sk_sp< SkColorSpace > MakeRGB(const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static sk_sp< SkImageFilter > Empty()
static sk_sp< SkImageFilter > Shader(sk_sp< SkShader > shader, const CropRect &cropRect={})
static SkMatrix Scale(SkScalar sx, SkScalar sy)
SkMatrix & setRotate(SkScalar degrees, SkScalar px, SkScalar py)
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
virtual void addCanvas(SkCanvas *)
SkPaintFilterCanvas(SkCanvas *canvas)
virtual bool onFilter(SkPaint &paint) const =0
@ kStroke_Style
set to stroke geometry
SkCanvas * beginRecording(const SkRect &bounds, sk_sp< SkBBoxHierarchy > bbh)
sk_sp< SkPicture > finishRecordingAsPicture()
SkColor getColor(int x, int y) const
const uint32_t * addr32() const
const SkImageInfo & info() const
auto visit(int i, F &&f) const -> decltype(f(SkRecords::NoOp()))
bool setRect(const SkIRect &rect)
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
@ kTriangleFan_VertexMode
static constexpr skcms_Matrix3x3 kAdobeRGB
static constexpr skcms_TransferFunction kSRGB
SK_API sk_sp< SkDocument > MakeDocument(SkWStream *stream, const Metadata &metadata)
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
ClipOpAndAA opAA SkRegion region
sk_sp< SkBlender > blender SkRect rect
SK_API sk_sp< SkShader > Color(SkColor)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SK_API sk_sp< SkSurface > WrapPixels(const SkImageInfo &imageInfo, void *pixels, size_t rowBytes, const SkSurfaceProps *surfaceProps=nullptr)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
SkRect operator()(const SkRecords::ClipRect &op)
SkRect operator()(const T &)
constexpr int32_t height() const
static constexpr SkIRect MakeEmpty()
constexpr int32_t width() const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
static constexpr SkISize MakeEmpty()
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
SkColorSpace * colorSpace() const
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
void set(float x, float y)
static SkRect Make(const SkISize &size)
static constexpr SkRect MakeEmpty()
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)