Flutter Engine
The Flutter Engine
SkBitmapDevice.h
Go to the documentation of this file.
1/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkBitmapDevice_DEFINED
9#define SkBitmapDevice_DEFINED
10
14#include "include/core/SkRect.h"
17#include "src/core/SkDevice.h"
20
21#include <cstddef>
22
23class SkBlender;
24class SkImage;
25class SkMatrix;
26class SkMesh;
27class SkPaint;
28class SkPath;
29class SkPixmap;
30class SkRRect;
32class SkRegion;
33class SkShader;
34class SkSpecialImage;
35class SkSurface;
36class SkSurfaceProps;
37class SkVertices;
38enum class SkClipOp;
39namespace sktext { class GlyphRunList; }
40struct SkImageInfo;
41struct SkPoint;
42struct SkRSXform;
43
44///////////////////////////////////////////////////////////////////////////////
45class SkBitmapDevice : public SkDevice {
46public:
47 /**
48 * Construct a new device with the specified bitmap as its backend. It is
49 * valid for the bitmap to have no pixels associated with it. In that case,
50 * any drawing to this device will have no effect.
51 */
53
54 /**
55 * Construct a new device with the specified bitmap as its backend. It is
56 * valid for the bitmap to have no pixels associated with it. In that case,
57 * any drawing to this device will have no effect.
58 */
60 void* externalHandle = nullptr);
61
63 SkRasterHandleAllocator* = nullptr);
64
65 void drawPaint(const SkPaint& paint) override;
67 const SkPoint[], const SkPaint& paint) override;
68 void drawRect(const SkRect& r, const SkPaint& paint) override;
69 void drawOval(const SkRect& oval, const SkPaint& paint) override;
70 void drawRRect(const SkRRect& rr, const SkPaint& paint) override;
71
72 void drawPath(const SkPath&, const SkPaint&, bool pathIsMutable) override;
73
74 void drawImageRect(const SkImage*, const SkRect* src, const SkRect& dst,
75 const SkSamplingOptions&, const SkPaint&,
77
78 void drawVertices(const SkVertices*, sk_sp<SkBlender>, const SkPaint&, bool) override;
79 // Implemented in src/sksl/SkBitmapDevice_mesh.cpp
80 void drawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
81
82 void drawAtlas(const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp<SkBlender>,
83 const SkPaint&) override;
84
85 ///////////////////////////////////////////////////////////////////////////
86
87 void pushClipStack() override;
88 void popClipStack() override;
89 void clipRect(const SkRect& rect, SkClipOp, bool aa) override;
90 void clipRRect(const SkRRect& rrect, SkClipOp, bool aa) override;
91 void clipPath(const SkPath& path, SkClipOp, bool aa) override;
92 void clipRegion(const SkRegion& deviceRgn, SkClipOp) override;
93 void replaceClip(const SkIRect& rect) override;
94 bool isClipAntiAliased() const override;
95 bool isClipEmpty() const override;
96 bool isClipRect() const override;
97 bool isClipWideOpen() const override;
98 void android_utils_clipAsRgn(SkRegion*) const override;
99 SkIRect devClipBounds() const override;
100
101 ///////////////////////////////////////////////////////////////////////////
102
104 const SkPaint&, SkCanvas::SrcRectConstraint) override;
105
108 sk_sp<SkSpecialImage> snapSpecial(const SkIRect&, bool forceCopy = false) override;
109
110 sk_sp<SkDevice> createDevice(const CreateInfo&, const SkPaint*) override;
111
113
114 void setImmutable() override { fBitmap.setImmutable(); }
115
116 void* getRasterHandle() const override { return fRasterHandle; }
117
118private:
119 // friend class SkCanvas;
120 friend class SkDraw;
121 friend class SkDrawBase;
122 friend class SkDrawTiler;
123 friend class SkSurface_Raster;
124
125 class BDDraw;
126
127 // Used to change the backend's pixels (and possibly config/rowbytes) but cannot change the
128 // width/height, so there should be no change to any clip information.
129 void replaceBitmapBackendForRasterSurface(const SkBitmap&);
130
131 void onClipShader(sk_sp<SkShader>) override;
132
133 void onDrawGlyphRunList(SkCanvas*, const sktext::GlyphRunList&, const SkPaint& paint) override;
134
135 bool onReadPixels(const SkPixmap&, int x, int y) override;
136 bool onWritePixels(const SkPixmap&, int, int) override;
137 bool onPeekPixels(SkPixmap*) override;
138 bool onAccessPixels(SkPixmap*) override;
139
140 void drawBitmap(const SkBitmap&, const SkMatrix&, const SkRect* dstOrNull,
141 const SkSamplingOptions&, const SkPaint&);
142
143 SkBitmap fBitmap;
144 void* fRasterHandle = nullptr;
145 SkRasterClipStack fRCStack;
146 SkGlyphRunListPainterCPU fGlyphPainter;
147};
148
149#endif // SkBitmapDevice_DEFINED
int count
Definition: FontMgrTest.cpp:50
SkClipOp
Definition: SkClipOp.h:13
uint32_t SkColor
Definition: SkColor.h:37
bool isClipEmpty() const override
void drawVertices(const SkVertices *, sk_sp< SkBlender >, const SkPaint &, bool) override
void drawMesh(const SkMesh &, sk_sp< SkBlender >, const SkPaint &) override
void drawPath(const SkPath &, const SkPaint &, bool pathIsMutable) override
void drawImageRect(const SkImage *, const SkRect *src, const SkRect &dst, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
bool isClipAntiAliased() const override
void popClipStack() override
void setImmutable() override
sk_sp< SkSurface > makeSurface(const SkImageInfo &, const SkSurfaceProps &) override
void android_utils_clipAsRgn(SkRegion *) const override
SkBitmapDevice(const SkBitmap &bitmap, const SkSurfaceProps &surfaceProps, void *externalHandle=nullptr)
sk_sp< SkSpecialImage > makeSpecial(const SkBitmap &) override
SkIRect devClipBounds() const override
void clipPath(const SkPath &path, SkClipOp, bool aa) override
void clipRegion(const SkRegion &deviceRgn, SkClipOp) override
sk_sp< SkDevice > createDevice(const CreateInfo &, const SkPaint *) override
static sk_sp< SkBitmapDevice > Create(const SkImageInfo &, const SkSurfaceProps &, SkRasterHandleAllocator *=nullptr)
void drawRRect(const SkRRect &rr, const SkPaint &paint) override
SkBitmapDevice(const SkBitmap &bitmap)
bool isClipRect() const override
void * getRasterHandle() const override
void drawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint[], const SkPaint &paint) override
void drawPaint(const SkPaint &paint) override
void drawOval(const SkRect &oval, const SkPaint &paint) override
void drawAtlas(const SkRSXform[], const SkRect[], const SkColor[], int count, sk_sp< SkBlender >, const SkPaint &) override
void drawSpecial(SkSpecialImage *, const SkMatrix &, const SkSamplingOptions &, const SkPaint &, SkCanvas::SrcRectConstraint) override
void clipRect(const SkRect &rect, SkClipOp, bool aa) override
bool isClipWideOpen() const override
void drawRect(const SkRect &r, const SkPaint &paint) override
void replaceClip(const SkIRect &rect) override
void pushClipStack() override
void clipRRect(const SkRRect &rrect, SkClipOp, bool aa) override
void setImmutable()
Definition: SkBitmap.cpp:400
SrcRectConstraint
Definition: SkCanvas.h:1541
sk_sp< SkSpecialImage > snapSpecial()
Definition: SkDevice.cpp:320
const SkSurfaceProps & surfaceProps() const
Definition: SkDevice.h:131
Definition: SkDraw.h:38
Definition: SkMesh.h:263
Definition: SkPath.h:59
const Paint & paint
Definition: color_source.cc:38
double y
double x
SkRRect rrect
Definition: SkRecords.h:232
SkRect oval
Definition: SkRecords.h:249
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
Definition: bitmap.py:1
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
Definition: switches.h:57
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 mode
Definition: switches.h:228
dst
Definition: cp.py:12
Definition: SkRect.h:32