aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-26 15:16:12 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-09-26 15:16:12 +0000
commit97f8167622473edf2e4262fa619883e616574c19 (patch)
treeb3d543b7d4bedc136771b1bb56c2d3b787d52699 /src/core
parent562626a5cbc5e2d47731ec72f0b011624c84bdb5 (diff)
We don't flatten or unflatten SkPaintOptionsAndroid. Reproduce and fix.
BUG=skia:1625 R=djsollen@google.com, reed@google.com Author: mtklein@google.com Review URL: https://chromiumcodereview.appspot.com/24075010 git-svn-id: http://skia.googlecode.com/svn/trunk@11472 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkPaint.cpp28
-rw-r--r--src/core/SkPaintOptionsAndroid.cpp6
2 files changed, 26 insertions, 8 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index df8b292ced..8ca9880f21 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -21,6 +21,7 @@
#include "SkOrderedReadBuffer.h"
#include "SkOrderedWriteBuffer.h"
#include "SkPaintDefaults.h"
+#include "SkPaintOptionsAndroid.h"
#include "SkPathEffect.h"
#include "SkRasterizer.h"
#include "SkScalar.h"
@@ -2003,8 +2004,9 @@ static uint32_t pack_4(unsigned a, unsigned b, unsigned c, unsigned d) {
}
enum FlatFlags {
- kHasTypeface_FlatFlag = 0x01,
- kHasEffects_FlatFlag = 0x02,
+ kHasTypeface_FlatFlag = 0x01,
+ kHasEffects_FlatFlag = 0x02,
+ kHasNonDefaultPaintOptionsAndroid_FlatFlag = 0x04,
};
// The size of a flat paint's POD fields
@@ -2036,7 +2038,11 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const {
asint(this->getImageFilter())) {
flatFlags |= kHasEffects_FlatFlag;
}
-
+#if SK_BUILD_FOR_ANDROID
+ if (this->getPaintOptionsAndroid() != SkPaintOptionsAndroid()) {
+ flatFlags |= kHasNonDefaultPaintOptionsAndroid_FlatFlag;
+ }
+#endif
if (buffer.isOrderedBinaryBuffer()) {
SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize);
@@ -2095,6 +2101,11 @@ void SkPaint::flatten(SkFlattenableWriteBuffer& buffer) const {
buffer.writeFlattenable(this->getImageFilter());
buffer.writeFlattenable(this->getAnnotation());
}
+#if SK_BUILD_FOR_ANDROID
+ if (flatFlags & kHasNonDefaultPaintOptionsAndroid_FlatFlag) {
+ this->getPaintOptionsAndroid().flatten(buffer);
+ }
+#endif
}
void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) {
@@ -2180,6 +2191,17 @@ void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) {
this->setLooper(NULL);
this->setImageFilter(NULL);
}
+
+#if SK_BUILD_FOR_ANDROID
+ this->setPaintOptionsAndroid(SkPaintOptionsAndroid());
+#endif
+ if (flatFlags & kHasNonDefaultPaintOptionsAndroid_FlatFlag) {
+ SkPaintOptionsAndroid options;
+ options.unflatten(buffer);
+#if SK_BUILD_FOR_ANDROID
+ this->setPaintOptionsAndroid(options);
+#endif
+ }
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/SkPaintOptionsAndroid.cpp b/src/core/SkPaintOptionsAndroid.cpp
index 31f489cb72..f8a65e9d90 100644
--- a/src/core/SkPaintOptionsAndroid.cpp
+++ b/src/core/SkPaintOptionsAndroid.cpp
@@ -12,14 +12,12 @@
#include "SkThread.h"
#include <cstring>
-#ifdef SK_BUILD_FOR_ANDROID
-
SkLanguage SkLanguage::getParent() const {
SkASSERT(!fTag.isEmpty());
const char* tag = fTag.c_str();
// strip off the rightmost "-.*"
- char* parentTagEnd = strrchr(tag, '-');
+ const char* parentTagEnd = strrchr(tag, '-');
if (parentTagEnd == NULL) {
return SkLanguage();
}
@@ -40,5 +38,3 @@ void SkPaintOptionsAndroid::unflatten(SkFlattenableReadBuffer& buffer) {
fLanguage = SkLanguage(tag);
fUseFontFallbacks = buffer.readBool();
}
-
-#endif