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

Unified Diff: src/core/SkPaint.cpp

Issue 1744103002: move annotations to canvas virtual (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months 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 | « src/core/SkCanvas.cpp ('k') | src/core/SkPictureFlat.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPaint.cpp
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index 017662ff48bead0a00263c42336719f544d2475f..cdfb1104544eb15690ac5037057a570fcb3b4eb6 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -6,7 +6,6 @@
*/
#include "SkPaint.h"
-#include "SkAnnotation.h"
#include "SkAutoKern.h"
#include "SkChecksum.h"
#include "SkColorFilter.h"
@@ -54,7 +53,6 @@ SkPaint::SkPaint() {
fRasterizer = nullptr;
fLooper = nullptr;
fImageFilter = nullptr;
- fAnnotation = nullptr;
fTextSize = SkPaintDefaults_TextSize;
fTextScaleX = SK_Scalar1;
@@ -87,7 +85,6 @@ SkPaint::SkPaint(const SkPaint& src) {
REF_COPY(fRasterizer);
REF_COPY(fLooper);
REF_COPY(fImageFilter);
- REF_COPY(fAnnotation);
COPY(fTextSize);
COPY(fTextScaleX);
@@ -114,7 +111,6 @@ SkPaint::SkPaint(SkPaint&& src) {
REF_MOVE(fRasterizer);
REF_MOVE(fLooper);
REF_MOVE(fImageFilter);
- REF_MOVE(fAnnotation);
MOVE(fTextSize);
MOVE(fTextScaleX);
@@ -138,7 +134,6 @@ SkPaint::~SkPaint() {
SkSafeUnref(fRasterizer);
SkSafeUnref(fLooper);
SkSafeUnref(fImageFilter);
- SkSafeUnref(fAnnotation);
}
SkPaint& SkPaint::operator=(const SkPaint& src) {
@@ -158,7 +153,6 @@ SkPaint& SkPaint::operator=(const SkPaint& src) {
REF_COPY(fRasterizer);
REF_COPY(fLooper);
REF_COPY(fImageFilter);
- REF_COPY(fAnnotation);
COPY(fTextSize);
COPY(fTextScaleX);
@@ -191,7 +185,6 @@ SkPaint& SkPaint::operator=(SkPaint&& src) {
REF_MOVE(fRasterizer);
REF_MOVE(fLooper);
REF_MOVE(fImageFilter);
- REF_MOVE(fAnnotation);
MOVE(fTextSize);
MOVE(fTextScaleX);
@@ -218,7 +211,6 @@ bool operator==(const SkPaint& a, const SkPaint& b) {
&& EQUAL(fRasterizer)
&& EQUAL(fLooper)
&& EQUAL(fImageFilter)
- && EQUAL(fAnnotation)
&& EQUAL(fTextSize)
&& EQUAL(fTextScaleX)
&& EQUAL(fTextSkewX)
@@ -420,11 +412,6 @@ SkImageFilter* SkPaint::setImageFilter(SkImageFilter* imageFilter) {
return imageFilter;
}
-SkAnnotation* SkPaint::setAnnotation(SkAnnotation* annotation) {
- SkRefCnt_SafeAssign(fAnnotation, annotation);
- return annotation;
-}
-
///////////////////////////////////////////////////////////////////////////////
static SkScalar mag2(SkScalar x, SkScalar y) {
@@ -1897,7 +1884,6 @@ void SkPaint::flatten(SkWriteBuffer& buffer) const {
asint(this->getColorFilter()) |
asint(this->getRasterizer()) |
asint(this->getLooper()) |
- asint(this->getAnnotation()) |
asint(this->getImageFilter())) {
flatFlags |= kHasEffects_FlatFlag;
}
@@ -1931,13 +1917,6 @@ void SkPaint::flatten(SkWriteBuffer& buffer) const {
buffer.writeFlattenable(this->getRasterizer());
buffer.writeFlattenable(this->getLooper());
buffer.writeFlattenable(this->getImageFilter());
-
- if (fAnnotation) {
- buffer.writeBool(true);
- fAnnotation->writeToBuffer(buffer);
- } else {
- buffer.writeBool(false);
- }
}
}
@@ -1981,8 +1960,14 @@ void SkPaint::unflatten(SkReadBuffer& buffer) {
SkSafeUnref(this->setLooper(buffer.readDrawLooper()));
SkSafeUnref(this->setImageFilter(buffer.readImageFilter()));
- if (buffer.readBool()) {
- this->setAnnotation(SkAnnotation::Create(buffer))->unref();
+ if (buffer.isVersionLT(SkReadBuffer::kAnnotationsMovedToCanvas_Version)) {
+ // We used to store annotations here (string+skdata) if this bool was true
+ if (buffer.readBool()) {
+ // Annotations have moved to drawAnnotation, so we just drop this one on the floor.
+ SkString key;
+ buffer.readString(&key);
+ SkSafeUnref(buffer.readByteArrayAsData());
+ }
}
} else {
this->setPathEffect(nullptr);
@@ -2205,12 +2190,6 @@ void SkPaint::toString(SkString* str) const {
str->append("</dd>");
}
- SkAnnotation* annotation = this->getAnnotation();
- if (annotation) {
- str->append("<dt>Annotation:</dt><dd>");
- str->append("</dd>");
- }
-
str->append("<dt>Color:</dt><dd>0x");
SkColor color = this->getColor();
str->appendHex(color);
@@ -2437,7 +2416,7 @@ bool SkPaint::nothingToDraw() const {
uint32_t SkPaint::getHash() const {
// We're going to hash 10 pointers and 7 32-bit values, finishing up with fBitfields,
// so fBitfields should be 10 pointers and 6 32-bit values from the start.
- static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * sizeof(uint32_t),
+ static_assert(offsetof(SkPaint, fBitfields) == 9 * sizeof(void*) + 6 * sizeof(uint32_t),
"SkPaint_notPackedTightly");
return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
offsetof(SkPaint, fBitfields) + sizeof(fBitfields));
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkPictureFlat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698