Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SkDrawTiler Class Reference

Public Member Functions

 SkDrawTiler (SkBitmapDevice *dev, const SkRect *bounds)
 
bool needsTiling () const
 
const SkDrawnext ()
 

Static Public Member Functions

static bool NeedsTiling (SkBitmapDevice *dev)
 

Detailed Description

Definition at line 60 of file SkBitmapDevice.cpp.

Constructor & Destructor Documentation

◆ SkDrawTiler()

SkDrawTiler::SkDrawTiler ( SkBitmapDevice dev,
const SkRect bounds 
)
inline

Definition at line 85 of file SkBitmapDevice.cpp.

85 : fDevice(dev) {
86 fDone = false;
87
88 // we need fDst to be set, and if we're actually drawing, to dirty the genID
89 if (!dev->accessPixels(&fRootPixmap)) {
90 // NoDrawDevice uses us (why?) so we have to catch this case w/ no pixels
91 fRootPixmap.reset(dev->imageInfo(), nullptr, 0);
92 }
93
94 // do a quick check, so we don't even have to process "bounds" if there is no need
95 const SkIRect clipR = dev->fRCStack.rc().getBounds();
96 fNeedsTiling = clipR.right() > kMaxDim || clipR.bottom() > kMaxDim;
97 if (fNeedsTiling) {
98 if (bounds) {
99 // Make sure we round first, and then intersect. We can't rely on promoting the
100 // clipR to floats (and then intersecting with devBounds) since promoting
101 // int --> float can make the float larger than the int.
102 // rounding(out) first runs the risk of clamping if the float is larger an intmax
103 // but our roundOut() is saturating, which is fine for this use case
104 //
105 // e.g. the older version of this code did this:
106 // devBounds = mapRect(bounds);
107 // if (devBounds.intersect(SkRect::Make(clipR))) {
108 // fSrcBounds = devBounds.roundOut();
109 // The problem being that the promotion of clipR to SkRect was unreliable
110 //
111 fSrcBounds = dev->localToDevice().mapRect(*bounds).roundOut();
112 if (fSrcBounds.intersect(clipR)) {
113 // Check again, now that we have computed srcbounds.
114 fNeedsTiling = fSrcBounds.right() > kMaxDim || fSrcBounds.bottom() > kMaxDim;
115 } else {
116 fNeedsTiling = false;
117 fDone = true;
118 }
119 } else {
120 fSrcBounds = clipR;
121 }
122 }
123
124 if (fNeedsTiling) {
125 // fDraw.fDst and fCTM are reset each time in setupTileDraw()
126 fDraw.fRC = &fTileRC;
127 // we'll step/increase it before using it
128 fOrigin.set(fSrcBounds.fLeft - kMaxDim, fSrcBounds.fTop);
129 } else {
130 // don't reference fSrcBounds, as it may not have been set
131 fDraw.fDst = fRootPixmap;
132 fDraw.fCTM = &dev->localToDevice();
133 fDraw.fRC = &dev->fRCStack.rc();
134 fOrigin.set(0, 0);
135 }
136
137 fDraw.fProps = &fDevice->surfaceProps();
138 }
const SkImageInfo & imageInfo() const
Definition SkDevice.h:117
bool accessPixels(SkPixmap *pmap)
Definition SkDevice.cpp:388
const SkMatrix & localToDevice() const
Definition SkDevice.h:179
const SkSurfaceProps & surfaceProps() const
Definition SkDevice.h:131
const SkSurfaceProps * fProps
Definition SkDrawBase.h:155
const SkRasterClip * fRC
Definition SkDrawBase.h:154
SkPixmap fDst
Definition SkDrawBase.h:151
const SkMatrix * fCTM
Definition SkDrawBase.h:153
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
void reset()
Definition SkPixmap.cpp:32
const SkRasterClip & rc() const
const SkIRect & getBounds() const
void set(int32_t x, int32_t y)
bool intersect(const SkIRect &r)
Definition SkRect.h:513
constexpr int32_t bottom() const
Definition SkRect.h:134
constexpr int32_t right() const
Definition SkRect.h:127
int32_t fTop
smaller y-axis bounds
Definition SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition SkRect.h:33

Member Function Documentation

◆ needsTiling()

bool SkDrawTiler::needsTiling ( ) const
inline

Definition at line 140 of file SkBitmapDevice.cpp.

140{ return fNeedsTiling; }

◆ NeedsTiling()

static bool SkDrawTiler::NeedsTiling ( SkBitmapDevice dev)
inlinestatic

Definition at line 81 of file SkBitmapDevice.cpp.

81 {
82 return dev->width() > kMaxDim || dev->height() > kMaxDim;
83 }
int height() const
Definition SkDevice.h:120
int width() const
Definition SkDevice.h:119

◆ next()

const SkDraw * SkDrawTiler::next ( )
inline

Definition at line 142 of file SkBitmapDevice.cpp.

142 {
143 if (fDone) {
144 return nullptr;
145 }
146 if (fNeedsTiling) {
147 do {
148 this->stepAndSetupTileDraw(); // might set the clip to empty and fDone to true
149 } while (!fDone && fTileRC.isEmpty());
150 // if we exit the loop and we're still empty, we're (past) done
151 if (fTileRC.isEmpty()) {
152 SkASSERT(fDone);
153 return nullptr;
154 }
155 SkASSERT(!fTileRC.isEmpty());
156 } else {
157 fDone = true; // only draw untiled once
158 }
159 return &fDraw;
160 }
#define SkASSERT(cond)
Definition SkAssert.h:116
bool isEmpty() const

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