Flutter Engine
The Flutter Engine
Functions
CanvasStateHelpers.cpp File Reference
#include "include/core/SkTypes.h"
#include "tests/CanvasStateHelpers.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkRegion.h"
#include "include/core/SkScalar.h"
#include "include/utils/SkCanvasStateUtils.h"
#include <memory>

Go to the source code of this file.

Functions

void complex_layers_draw (SkCanvas *canvas, float left, float top, float right, float bottom, int32_t spacer)
 
bool complex_layers_draw_from_canvas_state (SkCanvasState *state, float left, float top, float right, float bottom, int32_t spacer)
 
void complex_clips_draw (SkCanvas *canvas, int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t clipOp, const SkRegion &localRegion)
 
bool complex_clips_draw_from_canvas_state (SkCanvasState *state, int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t clipOp, int32_t regionRects, int32_t *rectCoords)
 

Function Documentation

◆ complex_clips_draw()

void complex_clips_draw ( SkCanvas canvas,
int32_t  left,
int32_t  top,
int32_t  right,
int32_t  bottom,
int32_t  clipOp,
const SkRegion localRegion 
)

Definition at line 48 of file CanvasStateHelpers.cpp.

49 {
50 canvas->save();
53 canvas->clipRect(clipRect, (SkRegion::Op) clipOp);
54 canvas->drawColor(SK_ColorBLUE);
55 canvas->restore();
56
57 canvas->clipRegion(localRegion, (SkClipOp) clipOp);
58 canvas->drawColor(SK_ColorBLUE);
59}
SkClipOp
Definition: SkClipOp.h:13
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
void clipRegion(const SkRegion &deviceRgn, SkClipOp op=SkClipOp::kIntersect)
Definition: SkCanvas.cpp:1510
int save()
Definition: SkCanvas.cpp:447
clipRect(r.rect, r.opAA.op(), r.opAA.aa())) template<> void Draw
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition: SkRect.h:646

◆ complex_clips_draw_from_canvas_state()

bool complex_clips_draw_from_canvas_state ( SkCanvasState state,
int32_t  left,
int32_t  top,
int32_t  right,
int32_t  bottom,
int32_t  clipOp,
int32_t  regionRects,
int32_t *  rectCoords 
)

Definition at line 61 of file CanvasStateHelpers.cpp.

63 {
64 std::unique_ptr<SkCanvas> canvas = SkCanvasStateUtils::MakeFromCanvasState(state);
65 if (!canvas) {
66 return false;
67 }
68
69 SkRegion localRegion;
70 for (int32_t i = 0; i < regionRects; ++i) {
71 localRegion.op({rectCoords[0], rectCoords[1], rectCoords[2], rectCoords[3]},
73 rectCoords += 4;
74 }
75
76 complex_clips_draw(canvas.get(), left, top, right, bottom, clipOp, localRegion);
77 return true;
78}
void complex_clips_draw(SkCanvas *canvas, int32_t left, int32_t top, int32_t right, int32_t bottom, int32_t clipOp, const SkRegion &localRegion)
static std::unique_ptr< SkCanvas > MakeFromCanvasState(const SkCanvasState *state)
@ kUnion_Op
target unioned with operand
Definition: SkRegion.h:369
bool op(const SkIRect &rect, Op op)
Definition: SkRegion.h:384
AtkStateType state

◆ complex_layers_draw()

void complex_layers_draw ( SkCanvas canvas,
float  left,
float  top,
float  right,
float  bottom,
int32_t  spacer 
)

Definition at line 26 of file CanvasStateHelpers.cpp.

27 {
28 SkPaint bluePaint;
29 bluePaint.setColor(SK_ColorBLUE);
31
32 SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
33 canvas->drawRect(rect, bluePaint);
34 canvas->translate(0, rect.height() + spacer);
35 canvas->drawRect(rect, bluePaint);
36}
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
void setStyle(Style style)
Definition: SkPaint.cpp:105
void setColor(SkColor color)
Definition: SkPaint.cpp:119
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ complex_layers_draw_from_canvas_state()

bool complex_layers_draw_from_canvas_state ( SkCanvasState state,
float  left,
float  top,
float  right,
float  bottom,
int32_t  spacer 
)

Definition at line 38 of file CanvasStateHelpers.cpp.

39 {
40 std::unique_ptr<SkCanvas> canvas = SkCanvasStateUtils::MakeFromCanvasState(state);
41 if (!canvas) {
42 return false;
43 }
44 complex_layers_draw(canvas.get(), left, top, right, bottom, spacer);
45 return true;
46}
void complex_layers_draw(SkCanvas *canvas, float left, float top, float right, float bottom, int32_t spacer)