Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
skiagm::OffscreenShapeRenderer Class Reference
Inheritance diagram for skiagm::OffscreenShapeRenderer:
skiagm::ShapeRenderer SkRefCntBase

Public Member Functions

 ~OffscreenShapeRenderer () override=default
 
SkString name () override
 
sk_sp< ShapeRenderertoHairline () override
 
void draw (SkCanvas *canvas, SkPaint *paint, SkScalar tx, SkScalar ty, SkScalar angle) override
 
void prepareBuffer (SkCanvas *canvas, SkPaint *paint, SkScalar tx, SkScalar ty, SkScalar angle)
 
void redraw (SkCanvas *canvas, SkScalar scale=1.f, bool debugMode=false)
 
- Public Member Functions inherited from skiagm::ShapeRenderer
virtual void draw (SkCanvas *canvas, SkPaint *paint, SkScalar tx, SkScalar ty, SkScalar angle)=0
 
virtual SkString name ()=0
 
virtual sk_sp< ShapeRenderertoHairline ()=0
 
void applyLocalTransform (SkCanvas *canvas, SkScalar tx, SkScalar ty, SkScalar angle)
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< OffscreenShapeRendererMake (sk_sp< ShapeRenderer > renderer, int supersample, bool forceRaster=false)
 

Additional Inherited Members

- Static Public Attributes inherited from skiagm::ShapeRenderer
static constexpr SkScalar kTileWidth = 20.f
 
static constexpr SkScalar kTileHeight = 20.f
 

Detailed Description

Definition at line 154 of file ThinAASlide.cpp.

Constructor & Destructor Documentation

◆ ~OffscreenShapeRenderer()

skiagm::OffscreenShapeRenderer::~OffscreenShapeRenderer ( )
overridedefault

Member Function Documentation

◆ draw()

void skiagm::OffscreenShapeRenderer::draw ( SkCanvas canvas,
SkPaint paint,
SkScalar  tx,
SkScalar  ty,
SkScalar  angle 
)
inlineoverridevirtual

Implements skiagm::ShapeRenderer.

Definition at line 177 of file ThinAASlide.cpp.

177 {
178 // Subpixel translation+angle are applied in the offscreen buffer
179 this->prepareBuffer(canvas, paint, tx, ty, angle);
180 this->redraw(canvas);
181 }
void redraw(SkCanvas *canvas, SkScalar scale=1.f, bool debugMode=false)
void prepareBuffer(SkCanvas *canvas, SkPaint *paint, SkScalar tx, SkScalar ty, SkScalar angle)
const Paint & paint
Definition: color_source.cc:38

◆ Make()

static sk_sp< OffscreenShapeRenderer > skiagm::OffscreenShapeRenderer::Make ( sk_sp< ShapeRenderer renderer,
int  supersample,
bool  forceRaster = false 
)
inlinestatic

Definition at line 158 of file ThinAASlide.cpp.

159 {
160 SkASSERT(supersample > 0);
161 return sk_sp<OffscreenShapeRenderer>(new OffscreenShapeRenderer(std::move(renderer),
162 supersample, forceRaster));
163 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ name()

SkString skiagm::OffscreenShapeRenderer::name ( )
inlineoverridevirtual

Implements skiagm::ShapeRenderer.

Definition at line 165 of file ThinAASlide.cpp.

165 {
166 SkString name = fRenderer->name();
167 if (fSupersampleFactor != 1) {
168 name.prependf("%dx-", fSupersampleFactor * fSupersampleFactor);
169 }
170 return name;
171 }
void void void void void prependf(const char format[],...) SK_PRINTF_LIKE(2
Definition: SkString.cpp:570

◆ prepareBuffer()

void skiagm::OffscreenShapeRenderer::prepareBuffer ( SkCanvas canvas,
SkPaint paint,
SkScalar  tx,
SkScalar  ty,
SkScalar  angle 
)
inline

Definition at line 185 of file ThinAASlide.cpp.

185 {
186 auto info = SkImageInfo::Make(fSupersampleFactor * kTileWidth,
187 fSupersampleFactor * kTileHeight,
189 auto surface = fForceRasterBackend ? SkSurfaces::Raster(info) : canvas->makeSurface(info);
190
191 surface->getCanvas()->save();
192 // Make fully transparent so it is easy to determine pixels that are touched by partial cov.
193 surface->getCanvas()->clear(SK_ColorTRANSPARENT);
194 // Set up scaling to fit supersampling amount
195 surface->getCanvas()->scale(fSupersampleFactor, fSupersampleFactor);
196 fRenderer->draw(surface->getCanvas(), paint, tx, ty, angle);
197 surface->getCanvas()->restore();
198
199 // Save image so it can be drawn zoomed in or to visualize touched pixels; only valid until
200 // the next call to draw()
201 fLastRendered = surface->makeImageSnapshot();
202 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
constexpr SkColor SK_ColorTRANSPARENT
Definition: SkColor.h:99
static constexpr SkScalar kTileHeight
Definition: ThinAASlide.cpp:25
static constexpr SkScalar kTileWidth
Definition: ThinAASlide.cpp:24
VkSurfaceKHR surface
Definition: main.cc:49
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
sk_sp< SkSurface > makeSurface(SkCanvas *canvas, const SkImageInfo &info, const SkSurfaceProps *props)
Definition: ToolUtils.cpp:512
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ redraw()

void skiagm::OffscreenShapeRenderer::redraw ( SkCanvas canvas,
SkScalar  scale = 1.f,
bool  debugMode = false 
)
inline

Definition at line 204 of file ThinAASlide.cpp.

204 {
205 SkASSERT(fLastRendered);
206 // Use medium quality filter to get mipmaps when drawing smaller, or use nearest filtering
207 // when upscaling
208 SkPaint blit;
209 if (debugMode) {
210 // Makes anything that's > 1/255 alpha fully opaque and sets color to medium green.
211 static constexpr float kFilter[] = {
212 0.f, 0.f, 0.f, 0.f, 16.f/255,
213 0.f, 0.f, 0.f, 0.f, 200.f/255,
214 0.f, 0.f, 0.f, 0.f, 16.f/255,
215 0.f, 0.f, 0.f, 255.f, 0.f
216 };
217
219 }
220
224
225 canvas->scale(scale, scale);
226 canvas->drawImageRect(fLastRendered.get(),
230 }
SkFilterMode
SkMipmapMode
@ kFast_SrcRectConstraint
sample outside bounds; faster
Definition: SkCanvas.h:1543
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
Definition: SkCanvas.cpp:2333
void scale(SkScalar sx, SkScalar sy)
Definition: SkCanvas.cpp:1289
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
void setColorFilter(sk_sp< SkColorFilter > colorFilter)
T * get() const
Definition: SkRefCnt.h:303
SkSamplingOptions sampling
Definition: SkRecords.h:337
static SkPath scale(const SkPath &path, SkScalar scale)
Definition: patheffects.cpp:68
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ toHairline()

sk_sp< ShapeRenderer > skiagm::OffscreenShapeRenderer::toHairline ( )
inlineoverridevirtual

Implements skiagm::ShapeRenderer.

Definition at line 173 of file ThinAASlide.cpp.

173 {
174 return Make(fRenderer->toHairline(), fSupersampleFactor, fForceRasterBackend);
175 }
static sk_sp< OffscreenShapeRenderer > Make(sk_sp< ShapeRenderer > renderer, int supersample, bool forceRaster=false)

The documentation for this class was generated from the following file: