Skip to content

Commit 05174dc

Browse files
lhkbobSkCQ
authored and
SkCQ
committed
Rename base device to root device in SkCanvas
Change-Id: Iaf19645f4845114b79d23ead34cf4a11dfd400d9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/752539 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
1 parent 0ace46b commit 05174dc

7 files changed

+32
-32
lines changed

include/core/SkCanvas.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -2310,9 +2310,9 @@ class SK_API SkCanvas {
23102310

23112311
// The bottom-most device in the stack, only changed by init(). Image properties and the final
23122312
// canvas pixels are determined by this device.
2313-
SkDevice* baseDevice() const {
2314-
SkASSERT(fBaseDevice);
2315-
return fBaseDevice.get();
2313+
SkDevice* rootDevice() const {
2314+
SkASSERT(fRootDevice);
2315+
return fRootDevice.get();
23162316
}
23172317

23182318
// The top-most device in the stack, will change within saveLayer()'s. All drawing and clipping
@@ -2352,7 +2352,7 @@ class SK_API SkCanvas {
23522352
std::unique_ptr<Layer> fLayer;
23532353

23542354
// This points to the device of the top-most layer (which may be lower in the stack), or
2355-
// to the canvas's fBaseDevice. The MCRec does not own the device.
2355+
// to the canvas's fRootDevice. The MCRec does not own the device.
23562356
SkDevice* fDevice;
23572357

23582358
std::unique_ptr<BackImage> fBackImage;
@@ -2381,7 +2381,7 @@ class SK_API SkCanvas {
23812381
MCRec* fMCRec;
23822382

23832383
// Installed via init()
2384-
sk_sp<SkDevice> fBaseDevice;
2384+
sk_sp<SkDevice> fRootDevice;
23852385
const SkSurfaceProps fProps;
23862386

23872387
int fSaveCount; // value returned by getSaveCount()

src/android/SkAndroidFrameworkUtils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#if defined(SK_GANESH)
2121
bool SkAndroidFrameworkUtils::clipWithStencil(SkCanvas* canvas) {
22-
return canvas->baseDevice()->android_utils_clipWithStencil();
22+
return canvas->rootDevice()->android_utils_clipWithStencil();
2323
}
2424
#endif
2525

src/core/SkCanvas.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa
101101

102102
// if we're clipped at all, we can't overwrite the entire surface
103103
{
104-
const SkDevice* base = this->baseDevice();
104+
const SkDevice* root = this->rootDevice();
105105
const SkDevice* top = this->topDevice();
106-
if (base != top) {
106+
if (root != top) {
107107
return false; // we're in a saveLayer, so conservatively don't assume we'll overwrite
108108
}
109-
if (!base->isClipWideOpen()) {
109+
if (!root->isClipWideOpen()) {
110110
return false;
111111
}
112112
}
@@ -267,11 +267,11 @@ void SkCanvas::resetForNextPicture(const SkIRect& bounds) {
267267

268268
// We're peering through a lot of structs here. Only at this scope do we
269269
// know that the device is a SkNoPixelsDevice.
270-
SkASSERT(fBaseDevice->isNoPixelsDevice());
271-
fBaseDevice = sk_make_sp<SkNoPixelsDevice>(bounds,
272-
fBaseDevice->surfaceProps(),
273-
fBaseDevice->imageInfo().refColorSpace());
274-
fMCRec->reset(fBaseDevice.get());
270+
SkASSERT(fRootDevice->isNoPixelsDevice());
271+
fRootDevice = sk_make_sp<SkNoPixelsDevice>(bounds,
272+
fRootDevice->surfaceProps(),
273+
fRootDevice->imageInfo().refColorSpace());
274+
fMCRec->reset(fRootDevice.get());
275275
fQuickRejectBounds = this->computeDeviceClipBounds();
276276
}
277277

@@ -295,7 +295,7 @@ void SkCanvas::init(sk_sp<SkDevice> device) {
295295
SkASSERT(fProps.pixelGeometry() == device->surfaceProps().pixelGeometry());
296296

297297
fSurfaceBase = nullptr;
298-
fBaseDevice = std::move(device);
298+
fRootDevice = std::move(device);
299299
fScratchGlyphRunBuilder = std::make_unique<sktext::GlyphRunBuilder>();
300300
fQuickRejectBounds = this->computeDeviceClipBounds();
301301
}
@@ -346,7 +346,7 @@ SkSurface* SkCanvas::getSurface() const {
346346
}
347347

348348
SkISize SkCanvas::getBaseLayerSize() const {
349-
return this->baseDevice()->imageInfo().dimensions();
349+
return this->rootDevice()->imageInfo().dimensions();
350350
}
351351

352352
SkDevice* SkCanvas::topDevice() const {
@@ -355,7 +355,7 @@ SkDevice* SkCanvas::topDevice() const {
355355
}
356356

357357
bool SkCanvas::readPixels(const SkPixmap& pm, int x, int y) {
358-
return pm.addr() && this->baseDevice()->readPixels(pm, x, y);
358+
return pm.addr() && this->rootDevice()->readPixels(pm, x, y);
359359
}
360360

361361
bool SkCanvas::readPixels(const SkImageInfo& dstInfo, void* dstP, size_t rowBytes, int x, int y) {
@@ -377,7 +377,7 @@ bool SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) {
377377

378378
bool SkCanvas::writePixels(const SkImageInfo& srcInfo, const void* pixels, size_t rowBytes,
379379
int x, int y) {
380-
SkDevice* device = this->baseDevice();
380+
SkDevice* device = this->rootDevice();
381381

382382
// This check gives us an early out and prevents generation ID churn on the surface.
383383
// This is purely optional: it is a subset of the checks performed by SkWritePixelsRec.
@@ -1156,15 +1156,15 @@ sk_sp<SkSurface> SkCanvas::makeSurface(const SkImageInfo& info, const SkSurfaceP
11561156
}
11571157

11581158
sk_sp<SkSurface> SkCanvas::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
1159-
return this->baseDevice()->makeSurface(info, props);
1159+
return this->rootDevice()->makeSurface(info, props);
11601160
}
11611161

11621162
SkImageInfo SkCanvas::imageInfo() const {
11631163
return this->onImageInfo();
11641164
}
11651165

11661166
SkImageInfo SkCanvas::onImageInfo() const {
1167-
return this->baseDevice()->imageInfo();
1167+
return this->rootDevice()->imageInfo();
11681168
}
11691169

11701170
bool SkCanvas::getProps(SkSurfaceProps* props) const {
@@ -1195,7 +1195,7 @@ bool SkCanvas::peekPixels(SkPixmap* pmap) {
11951195
}
11961196

11971197
bool SkCanvas::onPeekPixels(SkPixmap* pmap) {
1198-
return this->baseDevice()->peekPixels(pmap);
1198+
return this->rootDevice()->peekPixels(pmap);
11991199
}
12001200

12011201
void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoint* origin) {
@@ -1354,7 +1354,7 @@ void SkCanvas::androidFramework_setDeviceClipRestriction(const SkIRect& rect) {
13541354
// - Historically, the empty rect would reset the clip restriction but it only could do so
13551355
// partially since the device's clips wasn't adjusted. Resetting is now handled
13561356
// automatically via SkCanvas::restore(), so empty input rects are skipped.
1357-
SkASSERT(this->topDevice() == this->baseDevice()); // shouldn't be in a nested layer
1357+
SkASSERT(this->topDevice() == this->rootDevice()); // shouldn't be in a nested layer
13581358
// and shouldn't already have a restriction
13591359
SkASSERT(fClipRestrictionSaveCount < 0 && fClipRestrictionRect.isEmpty());
13601360

@@ -1379,7 +1379,7 @@ void SkCanvas::internal_private_resetClip() {
13791379

13801380
void SkCanvas::onResetClip() {
13811381
SkIRect deviceRestriction = this->topDevice()->imageInfo().bounds();
1382-
if (fClipRestrictionSaveCount >= 0 && this->topDevice() == this->baseDevice()) {
1382+
if (fClipRestrictionSaveCount >= 0 && this->topDevice() == this->rootDevice()) {
13831383
// Respect the device clip restriction when resetting the clip if we're on the base device.
13841384
// If we're not on the base device, then the "reset" applies to the top device's clip stack,
13851385
// and the clip restriction will be respected automatically during a restore of the layer.

src/core/SkSpecialSurface.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ SkSpecialSurface::SkSpecialSurface(sk_sp<SkDevice> device, const SkIRect& subset
3737
sk_sp<SkSpecialImage> SkSpecialSurface::makeImageSnapshot() {
3838
fCanvas->restoreToCount(0);
3939

40-
// Because of the above 'restoreToCount(0)' we know we're getting the base device here.
41-
SkDevice* baseDevice = SkCanvasPriv::TopDevice(fCanvas.get());
42-
if (!baseDevice) {
40+
// Because of the above 'restoreToCount(0)' we know we're getting the root device here.
41+
SkDevice* rootDevice = SkCanvasPriv::TopDevice(fCanvas.get());
42+
if (!rootDevice) {
4343
return nullptr;
4444
}
4545

46-
sk_sp<SkSpecialImage> image = baseDevice->snapSpecial(this->subset());
46+
sk_sp<SkSpecialImage> image = rootDevice->snapSpecial(this->subset());
4747

4848
fCanvas.reset();
4949
return image;

src/image/SkSurface_Raster.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ bool SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
145145
// what is being used by the image. Next we update the canvas to use
146146
// this as its backend, so we can't modify the image's pixels anymore.
147147
SkASSERT(this->getCachedCanvas());
148-
SkBitmapDevice* bmDev = static_cast<SkBitmapDevice*>(this->getCachedCanvas()->baseDevice());
148+
SkBitmapDevice* bmDev = static_cast<SkBitmapDevice*>(this->getCachedCanvas()->rootDevice());
149149
bmDev->replaceBitmapBackendForRasterSurface(fBitmap);
150150
}
151151
return true;

src/utils/SkNWayCanvas.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void SkNWayCanvas::addCanvas(SkCanvas* canvas) {
5353
// We are using the nway canvas as a wrapper for the originally added canvas, and the device
5454
// on the nway may contradict calls for the device on this canvas. So, to add a second
5555
// canvas, the devices on the first canvas, and the nway base device must be different.
56-
SkASSERT(fList[0]->baseDevice() != this->baseDevice());
56+
SkASSERT(fList[0]->rootDevice() != this->rootDevice());
5757
}
5858
if (canvas) {
5959
*fList.append() = canvas;

src/utils/SkTestCanvas.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class SkPaint;
2929

3030
SkTestCanvas<SkSlugTestKey>::SkTestCanvas(SkCanvas* canvas)
31-
: SkCanvas(sk_ref_sp(canvas->baseDevice())) {}
31+
: SkCanvas(sk_ref_sp(canvas->rootDevice())) {}
3232

3333
void SkTestCanvas<SkSlugTestKey>::onDrawGlyphRunList(
3434
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) {
@@ -48,7 +48,7 @@ void SkTestCanvas<SkSlugTestKey>::onDrawGlyphRunList(
4848
}
4949

5050
SkTestCanvas<SkSerializeSlugTestKey>::SkTestCanvas(SkCanvas* canvas)
51-
: SkCanvas(sk_ref_sp(canvas->baseDevice())) {}
51+
: SkCanvas(sk_ref_sp(canvas->rootDevice())) {}
5252

5353
void SkTestCanvas<SkSerializeSlugTestKey>::onDrawGlyphRunList(
5454
const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) {
@@ -124,7 +124,7 @@ class ClientHandleManager : public SkStrikeClient::DiscardableHandleManager {
124124
};
125125

126126
SkTestCanvas<SkRemoteSlugTestKey>::SkTestCanvas(SkCanvas* canvas)
127-
: SkCanvas(sk_ref_sp(canvas->baseDevice()))
127+
: SkCanvas(sk_ref_sp(canvas->rootDevice()))
128128
, fServerHandleManager(new ServerHandleManager{})
129129
, fClientHandleManager(new ClientHandleManager{})
130130
, fStrikeServer(fServerHandleManager.get())

0 commit comments

Comments
 (0)