Flutter Engine
The Flutter Engine
SkScan.h
Go to the documentation of this file.
1/*
2 * Copyright 2011 The Android Open Source Project
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
9#ifndef SkScan_DEFINED
10#define SkScan_DEFINED
11
13#include "include/core/SkRect.h"
15
16class SkBlitter;
17class SkPath;
18class SkRasterClip;
19class SkRegion;
20
21/** Defines a fixed-point rectangle, identical to the integer SkIRect, but its
22 coordinates are treated as SkFixed rather than int32_t.
23*/
25
26class SkScan {
27public:
28 /*
29 * Draws count-1 line segments, one at a time:
30 * line(pts[0], pts[1])
31 * line(pts[1], pts[2])
32 * line(......, pts[count - 1])
33 */
34 typedef void (*HairRgnProc)(const SkPoint[], int count, const SkRegion*, SkBlitter*);
35 typedef void (*HairRCProc)(const SkPoint[], int count, const SkRasterClip&, SkBlitter*);
36
37 static void FillPath(const SkPath&, const SkIRect&, SkBlitter*);
38
39 // Paths of a certain size cannot be anti-aliased unless externally tiled (handled by SkDraw).
40 // SkBitmapDevice automatically tiles, SkAAClip does not so SkRasterClipStack converts AA clips
41 // to BW clips if that's the case. SkRegion uses this to know when to tile and union smaller
42 // SkRegions together.
43 static bool PathRequiresTiling(const SkIRect& bounds);
44
45 ///////////////////////////////////////////////////////////////////////////
46 // rasterclip
47
48 static void FillIRect(const SkIRect&, const SkRasterClip&, SkBlitter*);
49 static void FillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*);
50 static void FillRect(const SkRect&, const SkRasterClip&, SkBlitter*);
51 static void AntiFillRect(const SkRect&, const SkRasterClip&, SkBlitter*);
52 static void AntiFillXRect(const SkXRect&, const SkRasterClip&, SkBlitter*);
53 static void FillPath(const SkPath&, const SkRasterClip&, SkBlitter*);
54 static void AntiFillPath(const SkPath&, const SkRasterClip&, SkBlitter*);
55 static void FrameRect(const SkRect&, const SkPoint& strokeSize,
56 const SkRasterClip&, SkBlitter*);
57 static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize,
58 const SkRasterClip&, SkBlitter*);
59 static void FillTriangle(const SkPoint pts[], const SkRasterClip&, SkBlitter*);
60 static void HairLine(const SkPoint[], int count, const SkRasterClip&, SkBlitter*);
61 static void AntiHairLine(const SkPoint[], int count, const SkRasterClip&, SkBlitter*);
62 static void HairRect(const SkRect&, const SkRasterClip&, SkBlitter*);
63 static void AntiHairRect(const SkRect&, const SkRasterClip&, SkBlitter*);
64 static void HairPath(const SkPath&, const SkRasterClip&, SkBlitter*);
65 static void AntiHairPath(const SkPath&, const SkRasterClip&, SkBlitter*);
66 static void HairSquarePath(const SkPath&, const SkRasterClip&, SkBlitter*);
67 static void AntiHairSquarePath(const SkPath&, const SkRasterClip&, SkBlitter*);
68 static void HairRoundPath(const SkPath&, const SkRasterClip&, SkBlitter*);
69 static void AntiHairRoundPath(const SkPath&, const SkRasterClip&, SkBlitter*);
70
71 // Needed by SkRegion::setPath
72 static void FillPath(const SkPath&, const SkRegion& clip, SkBlitter*);
73
74private:
75 friend class SkAAClip;
76 friend class SkRegion;
77
78 static void FillIRect(const SkIRect&, const SkRegion* clip, SkBlitter*);
79 static void FillXRect(const SkXRect&, const SkRegion* clip, SkBlitter*);
80 static void FillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
81 static void AntiFillRect(const SkRect&, const SkRegion* clip, SkBlitter*);
82 static void AntiFillXRect(const SkXRect&, const SkRegion*, SkBlitter*);
83 static void AntiFillPath(const SkPath&, const SkRegion& clip, SkBlitter*, bool forceRLE);
84 static void FillTriangle(const SkPoint pts[], const SkRegion*, SkBlitter*);
85
86 static void AntiFrameRect(const SkRect&, const SkPoint& strokeSize,
87 const SkRegion*, SkBlitter*);
88 static void HairLineRgn(const SkPoint[], int count, const SkRegion*, SkBlitter*);
89 static void AntiHairLineRgn(const SkPoint[], int count, const SkRegion*, SkBlitter*);
90 static void AAAFillPath(const SkPath& path, SkBlitter* blitter, const SkIRect& pathIR,
91 const SkIRect& clipBounds, bool forceRLE);
92};
93
94/** Assign an SkXRect from a SkIRect, by promoting the src rect's coordinates
95 from int to SkFixed. Does not check for overflow if the src coordinates
96 exceed 32K
97*/
98static inline void XRect_set(SkXRect* xr, const SkIRect& src) {
99 xr->fLeft = SkIntToFixed(src.fLeft);
100 xr->fTop = SkIntToFixed(src.fTop);
101 xr->fRight = SkIntToFixed(src.fRight);
102 xr->fBottom = SkIntToFixed(src.fBottom);
103}
104
105/** Assign an SkXRect from a SkRect, by promoting the src rect's coordinates
106 from SkScalar to SkFixed. Does not check for overflow if the src coordinates
107 exceed 32K
108*/
109static inline void XRect_set(SkXRect* xr, const SkRect& src) {
110 xr->fLeft = SkScalarToFixed(src.fLeft);
111 xr->fTop = SkScalarToFixed(src.fTop);
112 xr->fRight = SkScalarToFixed(src.fRight);
113 xr->fBottom = SkScalarToFixed(src.fBottom);
114}
115
116/** Round the SkXRect coordinates, and store the result in the SkIRect.
117*/
118static inline void XRect_round(const SkXRect& xr, SkIRect* dst) {
119 dst->fLeft = SkFixedRoundToInt(xr.fLeft);
120 dst->fTop = SkFixedRoundToInt(xr.fTop);
121 dst->fRight = SkFixedRoundToInt(xr.fRight);
122 dst->fBottom = SkFixedRoundToInt(xr.fBottom);
123}
124
125/** Round the SkXRect coordinates out (i.e. use floor for left/top, and ceiling
126 for right/bottom), and store the result in the SkIRect.
127*/
128static inline void XRect_roundOut(const SkXRect& xr, SkIRect* dst) {
129 dst->fLeft = SkFixedFloorToInt(xr.fLeft);
130 dst->fTop = SkFixedFloorToInt(xr.fTop);
131 dst->fRight = SkFixedCeilToInt(xr.fRight);
132 dst->fBottom = SkFixedCeilToInt(xr.fBottom);
133}
134
135#endif
int count
Definition: FontMgrTest.cpp:50
#define SkFixedCeilToInt(x)
Definition: SkFixed.h:77
#define SkScalarToFixed(x)
Definition: SkFixed.h:125
#define SkIntToFixed(n)
Definition: SkFixed.h:73
#define SkFixedFloorToInt(x)
Definition: SkFixed.h:78
#define SkFixedRoundToInt(x)
Definition: SkFixed.h:76
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
static void XRect_set(SkXRect *xr, const SkIRect &src)
Definition: SkScan.h:98
static void XRect_roundOut(const SkXRect &xr, SkIRect *dst)
Definition: SkScan.h:128
SkIRect SkXRect
Definition: SkScan.h:24
static void XRect_round(const SkXRect &xr, SkIRect *dst)
Definition: SkScan.h:118
Definition: SkPath.h:59
Definition: SkScan.h:26
static bool PathRequiresTiling(const SkIRect &bounds)
static void HairLine(const SkPoint[], int count, const SkRasterClip &, SkBlitter *)
static void FillXRect(const SkXRect &, const SkRasterClip &, SkBlitter *)
Definition: SkScan.cpp:80
static void HairRoundPath(const SkPath &, const SkRasterClip &, SkBlitter *)
static void HairPath(const SkPath &, const SkRasterClip &, SkBlitter *)
static void HairSquarePath(const SkPath &, const SkRasterClip &, SkBlitter *)
static void AntiHairRect(const SkRect &, const SkRasterClip &, SkBlitter *)
static void AntiFillRect(const SkRect &, const SkRasterClip &, SkBlitter *)
static void FillRect(const SkRect &, const SkRasterClip &, SkBlitter *)
Definition: SkScan.cpp:95
static void AntiFillPath(const SkPath &, const SkRasterClip &, SkBlitter *)
static void AntiHairPath(const SkPath &, const SkRasterClip &, SkBlitter *)
static void FrameRect(const SkRect &, const SkPoint &strokeSize, const SkRasterClip &, SkBlitter *)
static void AntiHairRoundPath(const SkPath &, const SkRasterClip &, SkBlitter *)
static void AntiHairLine(const SkPoint[], int count, const SkRasterClip &, SkBlitter *)
static void FillPath(const SkPath &, const SkIRect &, SkBlitter *)
static void AntiHairSquarePath(const SkPath &, const SkRasterClip &, SkBlitter *)
void(* HairRCProc)(const SkPoint[], int count, const SkRasterClip &, SkBlitter *)
Definition: SkScan.h:35
void(* HairRgnProc)(const SkPoint[], int count, const SkRegion *, SkBlitter *)
Definition: SkScan.h:34
static void AntiFrameRect(const SkRect &, const SkPoint &strokeSize, const SkRasterClip &, SkBlitter *)
static void FillTriangle(const SkPoint pts[], const SkRasterClip &, SkBlitter *)
static void FillIRect(const SkIRect &, const SkRasterClip &, SkBlitter *)
Definition: SkScan.cpp:65
static void AntiFillXRect(const SkXRect &, const SkRasterClip &, SkBlitter *)
static void HairRect(const SkRect &, const SkRasterClip &, SkBlitter *)
Optional< SkRect > bounds
Definition: SkRecords.h:189
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
dst
Definition: cp.py:12
Definition: SkRect.h:32
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition: SkRect.h:35