Expose the owning surface to a canvas?
Handy if you want to flush, or otherwise understand the underlying buffer(s). Change-Id: I3d6610695c8603232192b26c687c6c74512165dd Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254803 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
67a625e51e
commit
a2b3b9efb8
@ -73,7 +73,9 @@ protected:
|
||||
}
|
||||
}
|
||||
// Prevent any batching between "frames".
|
||||
canvas->flush();
|
||||
if (auto surf = canvas->getSurface()) {
|
||||
surf->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,6 +286,11 @@ public:
|
||||
*/
|
||||
virtual GrContext* getGrContext();
|
||||
|
||||
/** Sometimes a canvas is owned by a surface. If it is, getSurface() will return a bare
|
||||
* pointer to that surface, else this will return nullptr.
|
||||
*/
|
||||
SkSurface* getSurface() const;
|
||||
|
||||
/** Returns the pixel base address, SkImageInfo, rowBytes, and origin if the pixels
|
||||
can be read directly. The returned address is only valid
|
||||
while SkCanvas is in scope and unchanged. Any SkCanvas call or SkSurface call
|
||||
|
@ -619,6 +619,10 @@ void SkCanvas::onFlush() {
|
||||
}
|
||||
}
|
||||
|
||||
SkSurface* SkCanvas::getSurface() const {
|
||||
return fSurfaceBase;
|
||||
}
|
||||
|
||||
SkISize SkCanvas::getBaseLayerSize() const {
|
||||
SkBaseDevice* d = this->getDevice();
|
||||
return d ? SkISize::Make(d->width(), d->height()) : SkISize::Make(0, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user