aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/aaclip.cpp6
-rw-r--r--gm/savelayer.cpp7
-rw-r--r--include/core/SkCanvas.h3
-rw-r--r--src/core/SkCanvas.cpp2
-rw-r--r--src/core/SkCanvasPriv.h7
-rw-r--r--src/core/SkPicturePlayback.cpp6
-rw-r--r--src/core/SkRecordOpts.cpp6
-rw-r--r--src/pipe/SkPipeCanvas.cpp4
-rw-r--r--src/pipe/SkPipeReader.cpp2
-rw-r--r--tests/CanvasStateTest.cpp17
10 files changed, 35 insertions, 25 deletions
diff --git a/gm/aaclip.cpp b/gm/aaclip.cpp
index 129a95213a..5b85318e42 100644
--- a/gm/aaclip.cpp
+++ b/gm/aaclip.cpp
@@ -7,7 +7,7 @@
#include "gm.h"
#include "sk_tool_utils.h"
-#include "SkCanvas.h"
+#include "SkCanvasPriv.h"
#include "SkPath.h"
#include "SkMakeUnique.h"
@@ -65,7 +65,7 @@ static void do_draw(SkCanvas* canvas, const SkRect& r) {
}
/**
- * Exercise kDontClipToLayer_Legacy_SaveLayerFlag flag, which does not limit the clip to the
+ * Exercise SkCanvasPriv::kDontClipToLayer_SaveLayerFlag flag, which does not limit the clip to the
* layer's bounds. Thus when a draw occurs, it can (depending on "where" it is) draw into the layer
* and/or draw onto the surrounding portions of the canvas, or both.
*
@@ -105,7 +105,7 @@ DEF_SIMPLE_GM(dont_clip_to_layer, canvas, 120, 120) {
rec.fPaint = nullptr;
rec.fBounds = &r0;
rec.fBackdrop = nullptr;
- rec.fSaveLayerFlags = 1 << 31;//SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag;
+ rec.fSaveLayerFlags = SkCanvasPriv::kDontClipToLayer_SaveLayerFlag;
canvas->saveLayer(rec);
rec.fBounds = &r1;
canvas->saveLayer(rec);
diff --git a/gm/savelayer.cpp b/gm/savelayer.cpp
index a5b2f9c46d..32f95bfc7d 100644
--- a/gm/savelayer.cpp
+++ b/gm/savelayer.cpp
@@ -7,8 +7,8 @@
#include "gm.h"
#include "sk_tool_utils.h"
+#include "SkCanvasPriv.h"
-static const uint32_t SkCanvas_kDontClipToLayer_PrivateSaveLayerFlag = 1U << 31;
// This GM tests out the deprecated Android-specific unclipped saveLayer "feature".
// In particular, it attempts to compare the performance of unclipped saveLayers with alternatives.
@@ -17,7 +17,7 @@ static void save_layer_unclipped(SkCanvas* canvas,
SkScalar l, SkScalar t, SkScalar r, SkScalar b) {
SkRect rect = SkRect::MakeLTRB(l, t, r, b);
canvas->saveLayer({ &rect, nullptr, nullptr, nullptr, nullptr,
- SkCanvas_kDontClipToLayer_PrivateSaveLayerFlag });
+ (SkCanvas::SaveLayerFlags) SkCanvasPriv::kDontClipToLayer_SaveLayerFlag });
}
static void do_draw(SkCanvas* canvas) {
@@ -93,7 +93,8 @@ DEF_SIMPLE_GM(picture_savelayer, canvas, 320, 640) {
// In the future, we might also test the clipped case by allowing i = 0
for(int i = 1; i < 2; ++i) {
canvas->translate(100 * i, 0);
- auto flag = i ? SkCanvas_kDontClipToLayer_PrivateSaveLayerFlag : 0;
+ auto flag = i ?
+ (SkCanvas::SaveLayerFlags) SkCanvasPriv::kDontClipToLayer_SaveLayerFlag : 0;
canvas->saveLayer({ &rect1, &paint1, nullptr, nullptr, nullptr, flag});
canvas->saveLayer({ &rect2, &paint2, nullptr, nullptr, nullptr, flag});
canvas->drawRect(rect3, paint3);
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 6203665359..8c86cd2f13 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -2598,7 +2598,6 @@ private:
};
static bool BoundsAffectsClip(SaveLayerFlags);
- static SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFlags);
static void DrawDeviceWithFilter(SkBaseDevice* src, const SkImageFilter* filter,
SkBaseDevice* dst, const SkIPoint& dstOrigin,
@@ -2658,6 +2657,7 @@ private:
void internalSetMatrix(const SkMatrix&);
friend class SkAndroidFrameworkUtils;
+ friend class SkCanvasPriv; // needs kDontClipToLayer_PrivateSaveLayerFlag
friend class SkDrawIter; // needs setupDrawForLayerDevice()
friend class AutoDrawLooper;
friend class SkDebugCanvas; // needs experimental fAllowSimplifyClip
@@ -2665,7 +2665,6 @@ private:
friend class SkNoDrawCanvas; // InitFlags
friend class SkPictureImageFilter; // SkCanvas(SkBaseDevice*, SkSurfaceProps*, InitFlags)
friend class SkPictureRecord; // predrawNotify (why does it need it? <reed>)
- friend class SkPicturePlayback; // SaveFlagsToSaveLayerFlags
friend class SkOverdrawCanvas;
friend class SkRasterHandleAllocator;
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 94bc2a711c..2f31335286 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -924,7 +924,7 @@ void SkCanvas::internalSave() {
}
bool SkCanvas::BoundsAffectsClip(SaveLayerFlags saveLayerFlags) {
- return !(saveLayerFlags & SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag);
+ return !(saveLayerFlags & SkCanvasPriv::kDontClipToLayer_SaveLayerFlag);
}
bool SkCanvas::clipRectBounds(const SkRect* bounds, SaveLayerFlags saveLayerFlags,
diff --git a/src/core/SkCanvasPriv.h b/src/core/SkCanvasPriv.h
index 12d9fce027..3e1ca16413 100644
--- a/src/core/SkCanvasPriv.h
+++ b/src/core/SkCanvasPriv.h
@@ -25,6 +25,10 @@ private:
class SkCanvasPriv {
public:
+ enum {
+ kDontClipToLayer_SaveLayerFlag = SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag,
+ };
+
// The lattice has pointers directly into the readbuffer
static bool ReadLattice(SkReadBuffer&, SkCanvas::Lattice*);
@@ -33,6 +37,9 @@ public:
// return the byte-size of the lattice, even if the buffer is null
// storage must be 4-byte aligned
static size_t WriteLattice(void* storage, const SkCanvas::Lattice&);
+
+ static SkCanvas::SaveLayerFlags LegacySaveFlagsToSaveLayerFlags(uint32_t legacySaveFlags);
+
};
#endif
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 7b9e411764..9964c748fa 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -25,11 +25,11 @@ enum LegacySaveFlags {
kClipToLayer_LegacySaveFlags = 0x10,
};
-SkCanvas::SaveLayerFlags SkCanvas::LegacySaveFlagsToSaveLayerFlags(uint32_t flags) {
+SkCanvas::SaveLayerFlags SkCanvasPriv::LegacySaveFlagsToSaveLayerFlags(uint32_t flags) {
uint32_t layerFlags = 0;
if (0 == (flags & kClipToLayer_LegacySaveFlags)) {
- layerFlags |= SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag;
+ layerFlags |= kDontClipToLayer_SaveLayerFlag;
}
return layerFlags;
}
@@ -689,7 +689,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
SkRect storage;
const SkRect* boundsPtr = get_rect_ptr(reader, &storage);
const SkPaint* paint = fPictureData->getPaint(reader);
- auto flags = SkCanvas::LegacySaveFlagsToSaveLayerFlags(reader->readInt());
+ auto flags = SkCanvasPriv::LegacySaveFlagsToSaveLayerFlags(reader->readInt());
BREAK_ON_READ_ERROR(reader);
canvas->saveLayer(SkCanvas::SaveLayerRec(boundsPtr, paint, flags));
diff --git a/src/core/SkRecordOpts.cpp b/src/core/SkRecordOpts.cpp
index 8607471636..efd3d4e5bd 100644
--- a/src/core/SkRecordOpts.cpp
+++ b/src/core/SkRecordOpts.cpp
@@ -7,6 +7,7 @@
#include "SkRecordOpts.h"
+#include "SkCanvasPriv.h"
#include "SkRecordPattern.h"
#include "SkRecords.h"
#include "SkTDArray.h"
@@ -192,8 +193,9 @@ struct SaveLayerDrawRestoreNooper {
return false;
}
- if (match->first<SaveLayer>()->saveLayerFlags & (1U << 31)) {
- // can't throw away the layer if the kDontClipToLayer_PrivateSaveLayerFlag is set
+ if (match->first<SaveLayer>()->saveLayerFlags &
+ SkCanvasPriv::kDontClipToLayer_SaveLayerFlag) {
+ // can't throw away the layer if set
return false;
}
diff --git a/src/pipe/SkPipeCanvas.cpp b/src/pipe/SkPipeCanvas.cpp
index 7315f88dd4..911595c47c 100644
--- a/src/pipe/SkPipeCanvas.cpp
+++ b/src/pipe/SkPipeCanvas.cpp
@@ -226,8 +226,8 @@ SkCanvas::SaveLayerStrategy SkPipeCanvas::getSaveLayerStrategy(const SaveLayerRe
uint32_t extra = rec.fSaveLayerFlags;
// remap this wacky flag
- if (extra & (1 << 31)/*SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag*/) {
- extra &= ~(1 << 31);
+ if (extra & SkCanvasPriv::kDontClipToLayer_SaveLayerFlag) {
+ extra &= ~SkCanvasPriv::kDontClipToLayer_SaveLayerFlag;
extra |= kDontClipToLayer_SaveLayerMask;
}
diff --git a/src/pipe/SkPipeReader.cpp b/src/pipe/SkPipeReader.cpp
index 2c41453868..2614c4ecd5 100644
--- a/src/pipe/SkPipeReader.cpp
+++ b/src/pipe/SkPipeReader.cpp
@@ -246,7 +246,7 @@ static void saveLayer_handler(SkPipeReader& reader, uint32_t packedVerb, SkCanva
// unremap this wacky flag
if (extra & kDontClipToLayer_SaveLayerMask) {
- flags |= (1 << 31);//SkCanvas::kDontClipToLayer_PrivateSaveLayerFlag;
+ flags |= SkCanvasPriv::kDontClipToLayer_SaveLayerFlag;
}
canvas->saveLayer(SkCanvas::SaveLayerRec(bounds, paint, backdrop.get(), clipMask.get(),
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp
index 775c15a80d..a1c9df4682 100644
--- a/tests/CanvasStateTest.cpp
+++ b/tests/CanvasStateTest.cpp
@@ -7,7 +7,7 @@
#include "CanvasStateHelpers.h"
#include "SkBitmap.h"
-#include "SkCanvas.h"
+#include "SkCanvasPriv.h"
#include "SkCanvasStateUtils.h"
#include "SkClipOpPriv.h"
#include "SkColor.h"
@@ -85,9 +85,9 @@ DEF_TEST(CanvasState_test_complex_layers, reporter) {
const int layerAlpha[] = { 255, 255, 0 };
const SkCanvas::SaveLayerFlags flags[] = {
- static_cast<SkCanvas::SaveLayerFlags>(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag),
+ static_cast<SkCanvas::SaveLayerFlags>(SkCanvasPriv::kDontClipToLayer_SaveLayerFlag),
0,
- static_cast<SkCanvas::SaveLayerFlags>(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag),
+ static_cast<SkCanvas::SaveLayerFlags>(SkCanvasPriv::kDontClipToLayer_SaveLayerFlag),
};
REPORTER_ASSERT(reporter, sizeof(layerAlpha) == sizeof(flags));
@@ -192,9 +192,9 @@ DEF_TEST(CanvasState_test_complex_clips, reporter) {
SkRegion::kReplace_Op,
};
const SkCanvas::SaveLayerFlags flags[] = {
- static_cast<SkCanvas::SaveLayerFlags>(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag),
+ static_cast<SkCanvas::SaveLayerFlags>(SkCanvasPriv::kDontClipToLayer_SaveLayerFlag),
0,
- static_cast<SkCanvas::SaveLayerFlags>(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag),
+ static_cast<SkCanvas::SaveLayerFlags>(SkCanvasPriv::kDontClipToLayer_SaveLayerFlag),
};
REPORTER_ASSERT(reporter, sizeof(clipOps) == sizeof(flags));
@@ -319,9 +319,9 @@ DEF_TEST(CanvasState_test_soft_clips, reporter) {
}
DEF_TEST(CanvasState_test_saveLayer_clip, reporter) {
- const uint32_t dontSaveFlag = 1 << 31; // secret flag for don't save
#ifdef SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
- static_assert(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag == dontSaveFlag, "");
+ static_assert(SkCanvas::kDontClipToLayer_Legacy_SaveLayerFlag ==
+ SkCanvasPriv::kDontClipToLayer_SaveLayerFlag, "");
#endif
const int WIDTH = 100;
const int HEIGHT = 100;
@@ -337,7 +337,8 @@ DEF_TEST(CanvasState_test_saveLayer_clip, reporter) {
SkIRect devClip;
// Check that saveLayer without the kClipToLayer_SaveFlag leaves the clip unchanged.
- canvas.saveLayer(SkCanvas::SaveLayerRec(&bounds, nullptr, dontSaveFlag));
+ canvas.saveLayer(SkCanvas::SaveLayerRec(&bounds, nullptr,
+ (SkCanvas::SaveLayerFlags) SkCanvasPriv::kDontClipToLayer_SaveLayerFlag));
devClip = canvas.getDeviceClipBounds();
REPORTER_ASSERT(reporter, canvas.isClipRect());
REPORTER_ASSERT(reporter, devClip.width() == WIDTH);