Add a way to get 'active' props from SkCanvas
This CL adds two new APIs to SkCanvas: getBaseProps, and getTopProps. SkCavas::getBaseProps is functionally identical to getProps, but returns the SkSurfaceProps by value, rather than via an 'out' parameter. SkCanvas::getProps is now considered deprecated. SkCanvas::getTopProps returns the 'currently active' SkSurfaceProps, i.e., it returns the props from the "top device". This is useful because the SkSurfaceProps can change when creating new layers. Bug: skia:13483 Change-Id: Ia1d9a10ffdd929427f1f2c0a7c4ba6965d4bd3c0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/554736 Commit-Queue: Brian Osman <brianosman@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Auto-Submit: Ian Prest <iapres@microsoft.com>
This commit is contained in:
parent
72a08f4b8a
commit
94e34f7a1b
@ -10,6 +10,9 @@ Milestone 104
|
||||
* SkImage::MakeFromPicture and SkImageGenerator::MakeFromPicture now take an optional
|
||||
SkSurfaceProps to use when rasterizing the picture.
|
||||
* skcms.h has been relocated to //modules/skcms/skcms.h (was //include/third_party/skcms/skcms.h)
|
||||
* New functions SkCanvas::getBaseProps and SkCanvas::getTopProps; SkCanvas::getBaseProps is a
|
||||
direct replacement for the (now deprecated) SkCanvas::getProps function, while getTopProps is
|
||||
a variant that returns the SkSurfaceProps that are active in the current layer.
|
||||
|
||||
* * *
|
||||
|
||||
|
@ -263,10 +263,27 @@ public:
|
||||
@param props storage for writable SkSurfaceProps
|
||||
@return true if SkSurfaceProps was copied
|
||||
|
||||
DEPRECATED: Replace usage with getBaseProps() or getTopProps()
|
||||
|
||||
example: https://fiddle.skia.org/c/@Canvas_getProps
|
||||
*/
|
||||
bool getProps(SkSurfaceProps* props) const;
|
||||
|
||||
/** Returns the SkSurfaceProps associated with the canvas (i.e., at the base of the layer
|
||||
stack).
|
||||
|
||||
@return base SkSurfaceProps
|
||||
*/
|
||||
SkSurfaceProps getBaseProps() const;
|
||||
|
||||
/** Returns the SkSurfaceProps associated with the canvas that are currently active (i.e., at
|
||||
the top of the layer stack). This can differ from getBaseProps depending on the flags
|
||||
passed to saveLayer (see SaveLayerFlagsSet).
|
||||
|
||||
@return SkSurfaceProps active in the current/top layer
|
||||
*/
|
||||
SkSurfaceProps getTopProps() const;
|
||||
|
||||
/** Triggers the immediate execution of all pending draw operations.
|
||||
If SkCanvas is associated with GPU surface, resolves all pending GPU operations.
|
||||
If SkCanvas is associated with raster surface, has no effect; raster draw
|
||||
@ -2179,7 +2196,7 @@ protected:
|
||||
virtual bool onPeekPixels(SkPixmap* pixmap);
|
||||
virtual bool onAccessTopLayerPixels(SkPixmap* pixmap);
|
||||
virtual SkImageInfo onImageInfo() const;
|
||||
virtual bool onGetProps(SkSurfaceProps* props) const;
|
||||
virtual bool onGetProps(SkSurfaceProps* props, bool top) const;
|
||||
virtual void onFlush();
|
||||
|
||||
// Subclass save/restore notifiers.
|
||||
|
@ -124,7 +124,7 @@ protected:
|
||||
bool onPeekPixels(SkPixmap* pixmap) override;
|
||||
bool onAccessTopLayerPixels(SkPixmap* pixmap) override;
|
||||
SkImageInfo onImageInfo() const override;
|
||||
bool onGetProps(SkSurfaceProps* props) const override;
|
||||
bool onGetProps(SkSurfaceProps* props, bool top) const override;
|
||||
|
||||
private:
|
||||
class AutoPaintFilter;
|
||||
|
@ -1284,12 +1284,24 @@ SkImageInfo SkCanvas::onImageInfo() const {
|
||||
}
|
||||
|
||||
bool SkCanvas::getProps(SkSurfaceProps* props) const {
|
||||
return this->onGetProps(props);
|
||||
return this->onGetProps(props, /*top=*/false);
|
||||
}
|
||||
|
||||
bool SkCanvas::onGetProps(SkSurfaceProps* props) const {
|
||||
SkSurfaceProps SkCanvas::getBaseProps() const {
|
||||
SkSurfaceProps props;
|
||||
this->onGetProps(&props, /*top=*/false);
|
||||
return props;
|
||||
}
|
||||
|
||||
SkSurfaceProps SkCanvas::getTopProps() const {
|
||||
SkSurfaceProps props;
|
||||
this->onGetProps(&props, /*top=*/true);
|
||||
return props;
|
||||
}
|
||||
|
||||
bool SkCanvas::onGetProps(SkSurfaceProps* props, bool top) const {
|
||||
if (props) {
|
||||
*props = fProps;
|
||||
*props = top ? topDevice()->surfaceProps() : fProps;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "include/core/SkPoint.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "include/core/SkSurface.h" // IWYU pragma: keep
|
||||
#include "include/core/SkSurfaceProps.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
@ -23,7 +24,6 @@ class SkPath;
|
||||
class SkPicture;
|
||||
class SkRRect;
|
||||
class SkRegion;
|
||||
class SkSurfaceProps;
|
||||
class SkTextBlob;
|
||||
class SkVertices;
|
||||
struct SkDrawShadowRec;
|
||||
@ -292,6 +292,9 @@ SkImageInfo SkPaintFilterCanvas::onImageInfo() const {
|
||||
return this->proxy()->imageInfo();
|
||||
}
|
||||
|
||||
bool SkPaintFilterCanvas::onGetProps(SkSurfaceProps* props) const {
|
||||
return this->proxy()->getProps(props);
|
||||
bool SkPaintFilterCanvas::onGetProps(SkSurfaceProps* props, bool top) const {
|
||||
if (props) {
|
||||
*props = top ? this->proxy()->getTopProps() : this->proxy()->getBaseProps();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user