Revert "Reland "Rename getTopDevice/getDevice to topDevice/baseDevice""

This reverts commit 7839f66540.

Reason for revert: another android-framework only compiler issue, this time around 'const'-ness

Original change's description:
> Reland "Rename getTopDevice/getDevice to topDevice/baseDevice"
>
> This reverts commit d8b939e0b4.
>
> Reason for revert: fix SkAndroidFrameworkUtils getDevice() reference
>
> Original change's description:
> > Revert "Rename getTopDevice/getDevice to topDevice/baseDevice"
> >
> > This reverts commit 632a23afa4.
> >
> > Reason for revert: breaking android roll
> >
> > Original change's description:
> > > Rename getTopDevice/getDevice to topDevice/baseDevice
> > >
> > > This addresses nit from https://skia-review.googlesource.com/c/skia/+/344663
> > > and also moves topDevice() to be private, since it's not really meant
> > > for arbitrary subclasses to access anyways. Classes outside of SkCanvas
> > > that need topDevice/baseDevice are already friended anyways.
> > >
> > > Bug: skia:10987
> > > Change-Id: Ib0b0dffb5b1c35d5a0c78aeb8903e4cf0b8810a9
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344960
> > > Reviewed-by: Mike Klein <mtklein@google.com>
> > > Reviewed-by: Mike Reed <reed@google.com>
> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> >
> > TBR=mtklein@google.com,reed@google.com,michaelludwig@google.com
> >
> > Change-Id: I9b70230f7db5d31cede2ea03e7abc7c154021204
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: skia:10987
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345158
> > Reviewed-by: Derek Sollenberger <djsollen@google.com>
> > Commit-Queue: Derek Sollenberger <djsollen@google.com>
>
> TBR=djsollen@google.com,mtklein@google.com,reed@google.com,michaelludwig@google.com
>
> # Not skipping CQ checks because this is a reland.
>
> Bug: skia:10987
> Change-Id: Ibf6397b54655c25ef3d348210de5eb6dab416723
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345165
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

TBR=djsollen@google.com,mtklein@google.com,reed@google.com,michaelludwig@google.com

Change-Id: Ib97ee3c349eee90d27bf22f4d43d29d24ca68f27
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10987
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/345282
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Michael Ludwig 2020-12-17 14:23:06 +00:00 committed by Skia Commit-Bot
parent 4052510f0b
commit 9e230d8136
5 changed files with 85 additions and 91 deletions

View File

@ -2573,6 +2573,8 @@ protected:
bool clipRectBounds(const SkRect* bounds, SkIRect* intersection,
const SkImageFilter* imageFilter = nullptr);
SkBaseDevice* getTopDevice() const;
private:
static void DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* filter,
SkBaseDevice* dst, const SkIPoint& dstOrigin,
@ -2589,15 +2591,7 @@ private:
void predrawNotify(bool willOverwritesEntireSurface = false);
void predrawNotify(const SkRect* rect, const SkPaint* paint, ShaderOverrideOpacity);
// The bottom-most device in the stack, only changed by init(). Image properties and the final
// canvas pixels are determined by this device.
SkBaseDevice* baseDevice();
const SkBaseDevice* baseDevice() const;
// The top-most device in the stack, will change within saveLayer()'s. All drawing and clipping
// operations should route to this device.
SkBaseDevice* topDevice();
const SkBaseDevice* topDevice() const;
SkBaseDevice* getDevice() const;
class MCRec;

View File

@ -17,7 +17,8 @@
#if SK_SUPPORT_GPU
bool SkAndroidFrameworkUtils::clipWithStencil(SkCanvas* canvas) {
return canvas->baseDevice()->android_utils_clipWithStencil();
SkBaseDevice* device = canvas->getDevice();
return device && device->android_utils_clipWithStencil();
}
#endif

View File

@ -89,8 +89,8 @@ bool SkCanvas::wouldOverwriteEntireSurface(const SkRect* rect, const SkPaint* pa
// if we're clipped at all, we can't overwrite the entire surface
{
const SkBaseDevice* base = this->baseDevice();
const SkBaseDevice* top = this->topDevice();
SkBaseDevice* base = this->getDevice();
SkBaseDevice* top = this->getTopDevice();
if (base != top) {
return false; // we're in a saveLayer, so conservatively don't assume we'll overwrite
}
@ -553,33 +553,25 @@ SkSurface* SkCanvas::getSurface() const {
}
SkISize SkCanvas::getBaseLayerSize() const {
return this->baseDevice()->imageInfo().dimensions();
return this->getDevice()->imageInfo().dimensions();
}
SkIRect SkCanvas::internalGetTopLayerBounds() const {
return this->topDevice()->getGlobalBounds();
return this->getTopDevice()->getGlobalBounds();
}
const SkBaseDevice* SkCanvas::baseDevice() const {
SkASSERT(fBaseDevice);
return fBaseDevice.get();
}
SkBaseDevice* SkCanvas::baseDevice() {
SkBaseDevice* SkCanvas::getDevice() const {
SkASSERT(fBaseDevice);
return fBaseDevice.get();
}
const SkBaseDevice* SkCanvas::topDevice() const {
SkASSERT(fMCRec->fDevice);
return fMCRec->fDevice;
}
SkBaseDevice* SkCanvas::topDevice() {
SkBaseDevice* SkCanvas::getTopDevice() const {
SkASSERT(fMCRec->fDevice);
return fMCRec->fDevice;
}
bool SkCanvas::readPixels(const SkPixmap& pm, int x, int y) {
return pm.addr() && this->baseDevice()->readPixels(pm, x, y);
return pm.addr() && this->getDevice()->readPixels(pm, x, y);
}
bool SkCanvas::readPixels(const SkImageInfo& dstInfo, void* dstP, size_t rowBytes, int x, int y) {
@ -601,7 +593,7 @@ bool SkCanvas::writePixels(const SkBitmap& bitmap, int x, int y) {
bool SkCanvas::writePixels(const SkImageInfo& srcInfo, const void* pixels, size_t rowBytes,
int x, int y) {
SkBaseDevice* device = this->baseDevice();
SkBaseDevice* device = this->getDevice();
// This check gives us an early out and prevents generation ID churn on the surface.
// This is purely optional: it is a subset of the checks performed by SkWritePixelsRec.
@ -692,7 +684,7 @@ void SkCanvas::restoreToCount(int count) {
void SkCanvas::internalSave() {
fMCRec = new (fMCStack.push_back()) MCRec(*fMCRec);
this->topDevice()->save();
this->getTopDevice()->save();
}
bool SkCanvas::clipRectBounds(const SkRect* bounds, SkIRect* intersection,
@ -1030,7 +1022,7 @@ void SkCanvas::internalSaveLayer(const SaveLayerRec& rec, SaveLayerStrategy stra
strategy = kNoLayer_SaveLayerStrategy;
}
SkBaseDevice* priorDevice = this->topDevice();
SkBaseDevice* priorDevice = this->getTopDevice();
sk_sp<SkBaseDevice> newDevice;
if (strategy == kFullLayer_SaveLayerStrategy) {
SkASSERT(!ir.isEmpty());
@ -1091,7 +1083,7 @@ int SkCanvas::saveLayerAlpha(const SkRect* bounds, U8CPU alpha) {
}
void SkCanvas::internalSaveBehind(const SkRect* localBounds) {
SkBaseDevice* device = this->topDevice();
SkBaseDevice* device = this->getTopDevice();
// Map the local bounds into the top device's coordinate space (this is not
// necessarily the full global CTM transform).
@ -1148,12 +1140,12 @@ void SkCanvas::internalRestore() {
return;
}
this->topDevice()->restore(fMCRec->fMatrix);
this->getTopDevice()->restore(fMCRec->fMatrix);
if (backImage) {
SkPaint paint;
paint.setBlendMode(SkBlendMode::kDstOver);
this->topDevice()->drawSpecial(backImage->fImage.get(),
this->getTopDevice()->drawSpecial(backImage->fImage.get(),
SkMatrix::Translate(backImage->fLoc.x(),
backImage->fLoc.y()),
paint);
@ -1185,7 +1177,7 @@ sk_sp<SkSurface> SkCanvas::makeSurface(const SkImageInfo& info, const SkSurfaceP
}
sk_sp<SkSurface> SkCanvas::onNewSurface(const SkImageInfo& info, const SkSurfaceProps& props) {
return this->baseDevice()->makeSurface(info, props);
return this->getDevice()->makeSurface(info, props);
}
SkImageInfo SkCanvas::imageInfo() const {
@ -1193,7 +1185,7 @@ SkImageInfo SkCanvas::imageInfo() const {
}
SkImageInfo SkCanvas::onImageInfo() const {
return this->baseDevice()->imageInfo();
return this->getDevice()->imageInfo();
}
bool SkCanvas::getProps(SkSurfaceProps* props) const {
@ -1201,10 +1193,15 @@ bool SkCanvas::getProps(SkSurfaceProps* props) const {
}
bool SkCanvas::onGetProps(SkSurfaceProps* props) const {
if (props) {
*props = fProps;
SkBaseDevice* dev = this->getDevice();
if (dev) {
if (props) {
*props = fProps;
}
return true;
} else {
return false;
}
return true;
}
bool SkCanvas::peekPixels(SkPixmap* pmap) {
@ -1212,7 +1209,7 @@ bool SkCanvas::peekPixels(SkPixmap* pmap) {
}
bool SkCanvas::onPeekPixels(SkPixmap* pmap) {
return this->baseDevice()->peekPixels(pmap);
return this->getDevice()->peekPixels(pmap);
}
void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoint* origin) {
@ -1233,8 +1230,8 @@ void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoi
// instead of an origin, just don't expose the pixels in that case. Note that this means
// that layers with complex coordinate spaces can still report their pixels if the caller
// does not ask for the origin (e.g. just to dump its output to a file, etc).
if (this->topDevice()->isPixelAlignedToGlobal()) {
*origin = this->topDevice()->getOrigin();
if (this->getTopDevice()->isPixelAlignedToGlobal()) {
*origin = this->getTopDevice()->getOrigin();
} else {
return nullptr;
}
@ -1243,7 +1240,7 @@ void* SkCanvas::accessTopLayerPixels(SkImageInfo* info, size_t* rowBytes, SkIPoi
}
bool SkCanvas::onAccessTopLayerPixels(SkPixmap* pmap) {
return this->topDevice()->accessPixels(pmap);
return this->getTopDevice()->accessPixels(pmap);
}
/////////////////////////////////////////////////////////////////////////////
@ -1271,7 +1268,7 @@ void SkCanvas::internalDrawDevice(SkBaseDevice* srcDev, const SkPaint* paint) {
}
SkASSERT(!noFilterPaint.getImageFilter());
SkBaseDevice* dstDev = this->topDevice();
SkBaseDevice* dstDev = this->getTopDevice();
check_drawdevice_colorspaces(dstDev->imageInfo().colorSpace(),
srcDev->imageInfo().colorSpace());
@ -1313,7 +1310,7 @@ void SkCanvas::translate(SkScalar dx, SkScalar dy) {
// so we still have to compute this.
fIsScaleTranslate = SkMatrixPriv::IsScaleTranslateAsM33(fMCRec->fMatrix);
this->topDevice()->setGlobalCTM(fMCRec->fMatrix);
this->getTopDevice()->setGlobalCTM(fMCRec->fMatrix);
this->didTranslate(dx,dy);
}
@ -1328,7 +1325,7 @@ void SkCanvas::scale(SkScalar sx, SkScalar sy) {
// but pre-scaling by a non-finite does change it, so we have to recompute.
fIsScaleTranslate = SkMatrixPriv::IsScaleTranslateAsM33(fMCRec->fMatrix);
this->topDevice()->setGlobalCTM(fMCRec->fMatrix);
this->getTopDevice()->setGlobalCTM(fMCRec->fMatrix);
this->didScale(sx, sy);
}
@ -1366,7 +1363,7 @@ void SkCanvas::internalConcat44(const SkM44& m) {
fIsScaleTranslate = SkMatrixPriv::IsScaleTranslateAsM33(fMCRec->fMatrix);
this->topDevice()->setGlobalCTM(fMCRec->fMatrix);
this->getTopDevice()->setGlobalCTM(fMCRec->fMatrix);
}
void SkCanvas::concat(const SkM44& m) {
@ -1379,7 +1376,7 @@ void SkCanvas::internalSetMatrix(const SkM44& m) {
fMCRec->fMatrix = m;
fIsScaleTranslate = SkMatrixPriv::IsScaleTranslateAsM33(m);
this->topDevice()->setGlobalCTM(fMCRec->fMatrix);
this->getTopDevice()->setGlobalCTM(fMCRec->fMatrix);
}
void SkCanvas::setMatrix(const SkMatrix& matrix) {
@ -1425,7 +1422,7 @@ void SkCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeSty
const bool isAA = kSoft_ClipEdgeStyle == edgeStyle;
AutoUpdateQRBounds aqr(this);
this->topDevice()->clipRect(rect, op, isAA);
this->getTopDevice()->clipRect(rect, op, isAA);
}
void SkCanvas::androidFramework_setDeviceClipRestriction(const SkIRect& rect) {
@ -1437,14 +1434,14 @@ void SkCanvas::androidFramework_setDeviceClipRestriction(const SkIRect& rect) {
}
AutoUpdateQRBounds aqr(this);
this->topDevice()->androidFramework_setDeviceClipRestriction(&fClipRestrictionRect);
this->getTopDevice()->androidFramework_setDeviceClipRestriction(&fClipRestrictionRect);
}
void SkCanvas::androidFramework_replaceClip(const SkIRect& rect) {
this->checkForDeferredSave();
AutoUpdateQRBounds aqr(this);
this->topDevice()->replaceClip(rect);
this->getTopDevice()->replaceClip(rect);
}
void SkCanvas::clipRRect(const SkRRect& rrect, SkClipOp op, bool doAA) {
@ -1461,7 +1458,7 @@ void SkCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edge
bool isAA = kSoft_ClipEdgeStyle == edgeStyle;
AutoUpdateQRBounds aqr(this);
this->topDevice()->clipRRect(rrect, op, isAA);
this->getTopDevice()->clipRRect(rrect, op, isAA);
}
void SkCanvas::clipPath(const SkPath& path, SkClipOp op, bool doAA) {
@ -1493,7 +1490,7 @@ void SkCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeSty
bool isAA = kSoft_ClipEdgeStyle == edgeStyle;
AutoUpdateQRBounds aqr(this);
this->topDevice()->clipPath(path, op, isAA);
this->getTopDevice()->clipPath(path, op, isAA);
}
void SkCanvas::clipShader(sk_sp<SkShader> sh, SkClipOp op) {
@ -1515,7 +1512,7 @@ void SkCanvas::clipShader(sk_sp<SkShader> sh, SkClipOp op) {
void SkCanvas::onClipShader(sk_sp<SkShader> sh, SkClipOp op) {
AutoUpdateQRBounds aqr(this);
this->topDevice()->clipShader(sh, op);
this->getTopDevice()->clipShader(sh, op);
}
void SkCanvas::clipRegion(const SkRegion& rgn, SkClipOp op) {
@ -1525,7 +1522,7 @@ void SkCanvas::clipRegion(const SkRegion& rgn, SkClipOp op) {
void SkCanvas::onClipRegion(const SkRegion& rgn, SkClipOp op) {
AutoUpdateQRBounds aqr(this);
this->topDevice()->clipRegion(rgn, op);
this->getTopDevice()->clipRegion(rgn, op);
}
void SkCanvas::validateClip() const {
@ -1540,12 +1537,12 @@ void SkCanvas::validateClip() const {
}
bool SkCanvas::androidFramework_isClipAA() const {
return this->topDevice()->onClipIsAA();
return this->getTopDevice()->onClipIsAA();
}
void SkCanvas::temporary_internal_getRgnClip(SkRegion* rgn) {
rgn->setEmpty();
SkBaseDevice* device = this->topDevice();
SkBaseDevice* device = this->getTopDevice();
if (device && device->isPixelAlignedToGlobal()) {
device->onAsRgnClip(rgn);
SkIPoint origin = device->getOrigin();
@ -1558,11 +1555,11 @@ void SkCanvas::temporary_internal_getRgnClip(SkRegion* rgn) {
///////////////////////////////////////////////////////////////////////////////
bool SkCanvas::isClipEmpty() const {
return this->topDevice()->onGetClipType() == SkBaseDevice::ClipType::kEmpty;
return this->getTopDevice()->onGetClipType() == SkBaseDevice::ClipType::kEmpty;
}
bool SkCanvas::isClipRect() const {
return this->topDevice()->onGetClipType() == SkBaseDevice::ClipType::kRect;
return this->getTopDevice()->onGetClipType() == SkBaseDevice::ClipType::kRect;
}
static inline bool is_nan_or_clipped(const Sk4f& devRect, const Sk4f& devClip) {
@ -1674,7 +1671,7 @@ SkIRect SkCanvas::getDeviceClipBounds() const {
}
SkRect SkCanvas::computeDeviceClipBounds() const {
const SkBaseDevice* dev = this->topDevice();
const SkBaseDevice* dev = this->getTopDevice();
if (dev->onGetClipType() == SkBaseDevice::ClipType::kEmpty) {
return SkRect::MakeEmpty();
} else {
@ -1694,7 +1691,7 @@ SkM44 SkCanvas::getLocalToDevice() const {
}
GrSurfaceDrawContext* SkCanvas::internal_private_accessTopLayerRenderTargetContext() {
return this->topDevice()->accessRenderTargetContext();
return this->getTopDevice()->accessRenderTargetContext();
}
#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && SK_SUPPORT_GPU
@ -1704,7 +1701,7 @@ GrSurfaceDrawContext* SkCanvas::internal_private_accessTopLayerRenderTargetConte
#include "src/gpu/GrSurfaceDrawContext.h"
GrBackendRenderTarget SkCanvas::topLayerBackendRenderTarget() const {
GrSurfaceDrawContext* sdc = this->topDevice()->accessRenderTargetContext();
GrSurfaceDrawContext* sdc = this->getTopDevice()->accessRenderTargetContext();
if (!sdc) {
return {};
}
@ -1716,7 +1713,7 @@ GrBackendRenderTarget SkCanvas::topLayerBackendRenderTarget() const {
#endif
GrRecordingContext* SkCanvas::recordingContext() {
return this->topDevice()->recordingContext();
return this->getTopDevice()->recordingContext();
}
void SkCanvas::drawDRRect(const SkRRect& outer, const SkRRect& inner,
@ -2011,7 +2008,7 @@ void SkCanvas::onDrawShadowRec(const SkPath& path, const SkDrawShadowRec& rec) {
// We don't test quickReject because the shadow outsets the path's bounds.
// TODO(michaelludwig): Is it worth calling SkDrawShadowMetrics::GetLocalBounds here?
this->predrawNotify();
this->topDevice()->drawShadow(path, rec);
this->getTopDevice()->drawShadow(path, rec);
}
void SkCanvas::experimental_DrawEdgeAAQuad(const SkRect& rect, const SkPoint clip[4],
@ -2053,7 +2050,7 @@ void SkCanvas::internalDrawPaint(const SkPaint& paint) {
}
AutoLayerForImageFilter layer(this, paint, nullptr, CheckForOverwrite::kYes);
this->topDevice()->drawPaint(layer.paint());
this->getTopDevice()->drawPaint(layer.paint());
}
void SkCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
@ -2079,7 +2076,7 @@ void SkCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[],
}
AutoLayerForImageFilter layer(this, strokePaint, &bounds);
this->topDevice()->drawPoints(mode, count, pts, layer.paint());
this->getTopDevice()->drawPoints(mode, count, pts, layer.paint());
}
void SkCanvas::onDrawRect(const SkRect& r, const SkPaint& paint) {
@ -2089,7 +2086,7 @@ void SkCanvas::onDrawRect(const SkRect& r, const SkPaint& paint) {
}
AutoLayerForImageFilter layer(this, paint, &r, CheckForOverwrite::kYes);
this->topDevice()->drawRect(r, layer.paint());
this->getTopDevice()->drawRect(r, layer.paint());
}
void SkCanvas::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
@ -2099,11 +2096,11 @@ void SkCanvas::onDrawRegion(const SkRegion& region, const SkPaint& paint) {
}
AutoLayerForImageFilter layer(this, paint, &bounds);
this->topDevice()->drawRegion(region, layer.paint());
this->getTopDevice()->drawRegion(region, layer.paint());
}
void SkCanvas::onDrawBehind(const SkPaint& paint) {
SkBaseDevice* dev = this->topDevice();
SkBaseDevice* dev = this->getTopDevice();
if (!dev) {
return;
}
@ -2139,7 +2136,7 @@ void SkCanvas::onDrawBehind(const SkPaint& paint) {
}
AutoLayerForImageFilter layer(this, paint);
this->topDevice()->drawPaint(layer.paint());
this->getTopDevice()->drawPaint(layer.paint());
dev->restore(fMCRec->fMatrix);
}
@ -2151,7 +2148,7 @@ void SkCanvas::onDrawOval(const SkRect& oval, const SkPaint& paint) {
}
AutoLayerForImageFilter layer(this, paint, &oval);
this->topDevice()->drawOval(oval, layer.paint());
this->getTopDevice()->drawOval(oval, layer.paint());
}
void SkCanvas::onDrawArc(const SkRect& oval, SkScalar startAngle,
@ -2163,7 +2160,7 @@ void SkCanvas::onDrawArc(const SkRect& oval, SkScalar startAngle,
}
AutoLayerForImageFilter layer(this, paint, &oval);
this->topDevice()->drawArc(oval, startAngle, sweepAngle, useCenter, layer.paint());
this->getTopDevice()->drawArc(oval, startAngle, sweepAngle, useCenter, layer.paint());
}
void SkCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
@ -2185,7 +2182,7 @@ void SkCanvas::onDrawRRect(const SkRRect& rrect, const SkPaint& paint) {
}
AutoLayerForImageFilter layer(this, paint, &bounds);
this->topDevice()->drawRRect(rrect, layer.paint());
this->getTopDevice()->drawRRect(rrect, layer.paint());
}
void SkCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const SkPaint& paint) {
@ -2195,7 +2192,7 @@ void SkCanvas::onDrawDRRect(const SkRRect& outer, const SkRRect& inner, const Sk
}
AutoLayerForImageFilter layer(this, paint, &bounds);
this->topDevice()->drawDRRect(outer, inner, layer.paint());
this->getTopDevice()->drawDRRect(outer, inner, layer.paint());
}
void SkCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
@ -2213,7 +2210,7 @@ void SkCanvas::onDrawPath(const SkPath& path, const SkPaint& paint) {
}
AutoLayerForImageFilter layer(this, paint, &pathBounds);
this->topDevice()->drawPath(path, layer.paint());
this->getTopDevice()->drawPath(path, layer.paint());
}
bool SkCanvas::canDrawBitmapAsSprite(SkScalar x, SkScalar y, int w, int h, const SkPaint& paint) {
@ -2269,7 +2266,7 @@ void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S
!image_to_color_filter(&realPaint)) {
// Evaluate the image filter directly on the input image and then draw the result, instead
// of first drawing the image to a temporary layer and filtering.
SkBaseDevice* device = this->topDevice();
SkBaseDevice* device = this->getTopDevice();
sk_sp<SkSpecialImage> special;
if ((special = device->makeSpecial(image))) {
sk_sp<SkImageFilter> filter = realPaint.refImageFilter();
@ -2292,7 +2289,7 @@ void SkCanvas::onDrawImage(const SkImage* image, SkScalar x, SkScalar y, const S
}
AutoLayerForImageFilter layer(this, realPaint, &bounds);
this->topDevice()->drawImageRect(image, nullptr, bounds, layer.paint(),
this->getTopDevice()->drawImageRect(image, nullptr, bounds, layer.paint(),
kStrict_SrcRectConstraint);
}
@ -2307,7 +2304,7 @@ void SkCanvas::onDrawImageRect(const SkImage* image, const SkRect* src, const Sk
AutoLayerForImageFilter layer(this, realPaint, &dst, CheckForOverwrite::kYes,
image->isOpaque() ? kOpaque_ShaderOverrideOpacity
: kNotOpaque_ShaderOverrideOpacity);
this->topDevice()->drawImageRect(image, src, dst, layer.paint(), constraint);
this->getTopDevice()->drawImageRect(image, src, dst, layer.paint(), constraint);
}
void SkCanvas::drawImage(const SkImage* image, SkScalar x, SkScalar y,
@ -2346,7 +2343,7 @@ void SkCanvas::onDrawImageNine(const SkImage* image, const SkIRect& center, cons
}
AutoLayerForImageFilter layer(this, realPaint, &dst);
this->topDevice()->drawImageNine(image, center, dst, layer.paint());
this->getTopDevice()->drawImageNine(image, center, dst, layer.paint());
}
void SkCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice, const SkRect& dst,
@ -2358,7 +2355,7 @@ void SkCanvas::onDrawImageLattice(const SkImage* image, const Lattice& lattice,
}
AutoLayerForImageFilter layer(this, realPaint, &dst);
this->topDevice()->drawImageLattice(image, lattice, dst, layer.paint());
this->getTopDevice()->drawImageLattice(image, lattice, dst, layer.paint());
}
void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
@ -2369,7 +2366,7 @@ void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
}
AutoLayerForImageFilter layer(this, paint, &bounds);
fScratchGlyphRunBuilder->drawTextBlob(layer.paint(), *blob, {x, y}, this->topDevice());
fScratchGlyphRunBuilder->drawTextBlob(layer.paint(), *blob, {x, y}, this->getTopDevice());
}
// These call the (virtual) onDraw... method
@ -2422,7 +2419,7 @@ void SkCanvas::onDrawVerticesObject(const SkVertices* vertices, SkBlendMode bmod
}
AutoLayerForImageFilter layer(this, simplePaint, &bounds);
this->topDevice()->drawVertices(vertices, bmode, layer.paint());
this->getTopDevice()->drawVertices(vertices, bmode, layer.paint());
}
void SkCanvas::drawPatch(const SkPoint cubics[12], const SkColor colors[4],
@ -2451,7 +2448,7 @@ void SkCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
}
AutoLayerForImageFilter layer(this, simplePaint, &bounds);
this->topDevice()->drawPatch(cubics, colors, texCoords, bmode, layer.paint());
this->getTopDevice()->drawPatch(cubics, colors, texCoords, bmode, layer.paint());
}
void SkCanvas::drawDrawable(SkDrawable* dr, SkScalar x, SkScalar y) {
@ -2482,7 +2479,7 @@ void SkCanvas::onDrawDrawable(SkDrawable* dr, const SkMatrix* matrix) {
// drawable bounds are no longer reliable (e.g. android displaylist)
// so don't use them for quick-reject
this->predrawNotify();
this->baseDevice()->drawDrawable(dr, matrix, this);
this->getDevice()->drawDrawable(dr, matrix, this);
}
void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const SkRect tex[],
@ -2496,14 +2493,14 @@ void SkCanvas::onDrawAtlas(const SkImage* atlas, const SkRSXform xform[], const
}
AutoLayerForImageFilter layer(this, realPaint);
this->topDevice()->drawAtlas(atlas, xform, tex, colors, count, bmode, layer.paint());
this->getTopDevice()->drawAtlas(atlas, xform, tex, colors, count, bmode, layer.paint());
}
void SkCanvas::onDrawAnnotation(const SkRect& rect, const char key[], SkData* value) {
SkASSERT(key);
this->predrawNotify();
this->topDevice()->drawAnnotation(rect, key, value);
this->getTopDevice()->drawAnnotation(rect, key, value);
}
void SkCanvas::onDrawEdgeAAQuad(const SkRect& r, const SkPoint clip[4], QuadAAFlags edgeAA,
@ -2517,7 +2514,7 @@ void SkCanvas::onDrawEdgeAAQuad(const SkRect& r, const SkPoint clip[4], QuadAAFl
}
this->predrawNotify();
this->topDevice()->drawEdgeAAQuad(r, clip, edgeAA, color, mode);
this->getTopDevice()->drawEdgeAAQuad(r, clip, edgeAA, color, mode);
}
void SkCanvas::onDrawEdgeAAImageSet(const ImageSetEntry imageSet[], int count,
@ -2557,7 +2554,7 @@ void SkCanvas::onDrawEdgeAAImageSet(const ImageSetEntry imageSet[], int count,
}
AutoLayerForImageFilter layer(this, realPaint, setBoundsValid ? &setBounds : nullptr);
this->topDevice()->drawEdgeAAImageSet(imageSet, count, dstClips, preViewMatrices,
this->getTopDevice()->drawEdgeAAImageSet(imageSet, count, dstClips, preViewMatrices,
layer.paint(), constraint);
}
@ -2727,7 +2724,7 @@ static_assert((int)SkRegion::kReplace_Op == (int)kReplace_SkClipOp, "
///////////////////////////////////////////////////////////////////////////////////////////////////
SkRasterHandleAllocator::Handle SkCanvas::accessTopRasterHandle() const {
const SkBaseDevice* dev = this->topDevice();
const SkBaseDevice* dev = this->getTopDevice();
if (fAllocator) {
SkRasterHandleAllocator::Handle handle = dev->getRasterHandle();
SkIRect clip = dev->devClipBounds();

View File

@ -144,7 +144,7 @@ void SkSurface_Raster::onCopyOnWrite(ContentChangeMode mode) {
// what is being used by the image. Next we update the canvas to use
// this as its backend, so we can't modify the image's pixels anymore.
SkASSERT(this->getCachedCanvas());
this->getCachedCanvas()->baseDevice()->replaceBitmapBackendForRasterSurface(fBitmap);
this->getCachedCanvas()->getDevice()->replaceBitmapBackendForRasterSurface(fBitmap);
}
}

View File

@ -176,10 +176,12 @@ SkCanvasState* SkCanvasStateUtils::CaptureCanvasState(SkCanvas* canvas) {
setup_MC_state(&canvasState->mcState, canvas->getTotalMatrix(), canvas->getDeviceClipBounds());
// Historically, the canvas state could report multiple top-level layers because SkCanvas
// supported unclipped layers. With that feature removed, all required information is contained
// by the canvas' top-most device.
SkBaseDevice* device = canvas->topDevice();
SkASSERT(device);
// supported unclipped layers. With that feature removed, there is only ever 0 to 1 "layers",
// and all required information is contained by the canvas' top-most device.
SkBaseDevice* device = canvas->getTopDevice();
if (!device) {
return nullptr;
}
SkSWriter32<sizeof(SkCanvasLayerState)> layerWriter;
// we currently only work for bitmap backed devices