Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: src/core/SkCanvas.cpp

Issue 1458153003: enable conservative raster clipping (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: change canvas::init to enforce the device's pref from the git-go Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkCanvas.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 7d71ffb13bdd573ea0b014e66975e4c81de9393b..895d36fe8c57d696a1effcff290fcd7608ed1a0d 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -627,7 +627,13 @@ void SkCanvas::resetForNextPicture(const SkIRect& bounds) {
}
SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
- fConservativeRasterClip = SkToBool(flags & kConservativeRasterClip_InitFlag);
+ if (device && device->forceConservativeRasterClip()) {
+ flags = InitFlags(flags | kConservativeRasterClip_InitFlag);
+ }
robertphillips 2015/11/20 19:45:47 Why don't we just do this inside the above else:
reed1 2015/11/20 20:46:34 doesn't seem smaller or clearer (to me) since it p
+ // Since init() is only called once by our constructors, it is safe to perform this
+ // const-cast.
+ *const_cast<bool*>(&fConservativeRasterClip) = SkToBool(flags & kConservativeRasterClip_InitFlag);
+
fCachedLocalClipBounds.setEmpty();
fCachedLocalClipBoundsDirty = true;
fAllowSoftClip = true;
@@ -652,9 +658,6 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
if (device) {
// The root device and the canvas should always have the same pixel geometry
SkASSERT(fProps.pixelGeometry() == device->surfaceProps().pixelGeometry());
- if (device->forceConservativeRasterClip()) {
- fConservativeRasterClip = true;
- }
device->onAttachToCanvas(this);
fMCRec->fLayer->fDevice = SkRef(device);
fMCRec->fRasterClip.setRect(device->getGlobalBounds());
@@ -665,6 +668,7 @@ SkBaseDevice* SkCanvas::init(SkBaseDevice* device, InitFlags flags) {
SkCanvas::SkCanvas()
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
+ , fConservativeRasterClip(false)
{
inc_canvas();
@@ -693,6 +697,7 @@ private:
SkCanvas::SkCanvas(int width, int height, const SkSurfaceProps* props)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(SkSurfacePropsCopyOrDefault(props))
+ , fConservativeRasterClip(false)
{
inc_canvas();
@@ -703,6 +708,7 @@ SkCanvas::SkCanvas(int width, int height, const SkSurfaceProps* props)
SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
+ , fConservativeRasterClip(false)
{
inc_canvas();
@@ -712,6 +718,7 @@ SkCanvas::SkCanvas(const SkIRect& bounds, InitFlags flags)
SkCanvas::SkCanvas(SkBaseDevice* device)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(device->surfaceProps())
+ , fConservativeRasterClip(false)
{
inc_canvas();
@@ -721,6 +728,7 @@ SkCanvas::SkCanvas(SkBaseDevice* device)
SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(device->surfaceProps())
+ , fConservativeRasterClip(false)
{
inc_canvas();
@@ -730,6 +738,7 @@ SkCanvas::SkCanvas(SkBaseDevice* device, InitFlags flags)
SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(props)
+ , fConservativeRasterClip(false)
{
inc_canvas();
@@ -740,6 +749,7 @@ SkCanvas::SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props)
SkCanvas::SkCanvas(const SkBitmap& bitmap)
: fMCStack(sizeof(MCRec), fMCRecStorage, sizeof(fMCRecStorage))
, fProps(SkSurfaceProps::kLegacyFontHost_InitType)
+ , fConservativeRasterClip(false)
{
inc_canvas();
« no previous file with comments | « include/core/SkCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698