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

Side by Side Diff: src/core/SkPaint.cpp

Issue 24075010: We don't flatten or unflatten SkPaintOptionsAndroid. Reproduce and fix. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: version that doesn't serialize default values Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 1996
1997 static uint32_t pack_4(unsigned a, unsigned b, unsigned c, unsigned d) { 1997 static uint32_t pack_4(unsigned a, unsigned b, unsigned c, unsigned d) {
1998 SkASSERT(a == (uint8_t)a); 1998 SkASSERT(a == (uint8_t)a);
1999 SkASSERT(b == (uint8_t)b); 1999 SkASSERT(b == (uint8_t)b);
2000 SkASSERT(c == (uint8_t)c); 2000 SkASSERT(c == (uint8_t)c);
2001 SkASSERT(d == (uint8_t)d); 2001 SkASSERT(d == (uint8_t)d);
2002 return (a << 24) | (b << 16) | (c << 8) | d; 2002 return (a << 24) | (b << 16) | (c << 8) | d;
2003 } 2003 }
2004 2004
2005 enum FlatFlags { 2005 enum FlatFlags {
2006 kHasTypeface_FlatFlag = 0x01, 2006 kHasTypeface_FlatFlag = 0x01,
2007 kHasEffects_FlatFlag = 0x02, 2007 kHasEffects_FlatFlag = 0x02,
2008 kHasNonDefaultPaintOptionsAndroid_FlatFlag = 0x04,
2008 }; 2009 };
2009 2010
2010 // The size of a flat paint's POD fields 2011 // The size of a flat paint's POD fields
2011 // Include an SkScalar for hinting scale factor whether it is 2012 // Include an SkScalar for hinting scale factor whether it is
2012 // supported or not so that an SKP is valid whether it was 2013 // supported or not so that an SKP is valid whether it was
2013 // created with support or not. 2014 // created with support or not.
2014 2015
2015 static const uint32_t kPODPaintSize = 6 * sizeof(SkScalar) + 2016 static const uint32_t kPODPaintSize = 6 * sizeof(SkScalar) +
2016 1 * sizeof(SkColor) + 2017 1 * sizeof(SkColor) +
2017 1 * sizeof(uint16_t) + 2018 1 * sizeof(uint16_t) +
(...skipping 11 matching lines...) Expand all
2029 asint(this->getShader()) | 2030 asint(this->getShader()) |
2030 asint(this->getXfermode()) | 2031 asint(this->getXfermode()) |
2031 asint(this->getMaskFilter()) | 2032 asint(this->getMaskFilter()) |
2032 asint(this->getColorFilter()) | 2033 asint(this->getColorFilter()) |
2033 asint(this->getRasterizer()) | 2034 asint(this->getRasterizer()) |
2034 asint(this->getLooper()) | 2035 asint(this->getLooper()) |
2035 asint(this->getAnnotation()) | 2036 asint(this->getAnnotation()) |
2036 asint(this->getImageFilter())) { 2037 asint(this->getImageFilter())) {
2037 flatFlags |= kHasEffects_FlatFlag; 2038 flatFlags |= kHasEffects_FlatFlag;
2038 } 2039 }
2039 2040 #if SK_BUILD_FOR_ANDROID
2041 if (this->getPaintOptionsAndroid() != SkPaintOptionsAndroid()) {
2042 flatFlags |= kHasNonDefaultPaintOptionsAndroid_FlatFlag;
2043 }
2044 #endif
2040 2045
2041 if (buffer.isOrderedBinaryBuffer()) { 2046 if (buffer.isOrderedBinaryBuffer()) {
2042 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); 2047 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize);
2043 uint32_t* ptr = buffer.getOrderedBinaryBuffer()->reserve(kPODPaintSize); 2048 uint32_t* ptr = buffer.getOrderedBinaryBuffer()->reserve(kPODPaintSize);
2044 2049
2045 ptr = write_scalar(ptr, this->getTextSize()); 2050 ptr = write_scalar(ptr, this->getTextSize());
2046 ptr = write_scalar(ptr, this->getTextScaleX()); 2051 ptr = write_scalar(ptr, this->getTextScaleX());
2047 ptr = write_scalar(ptr, this->getTextSkewX()); 2052 ptr = write_scalar(ptr, this->getTextSkewX());
2048 // Dummy value for obsolete hinting scale factor. TODO: remove with nex t picture version 2053 // Dummy value for obsolete hinting scale factor. TODO: remove with nex t picture version
2049 ptr = write_scalar(ptr, SK_Scalar1); 2054 ptr = write_scalar(ptr, SK_Scalar1);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 buffer.writeFlattenable(this->getPathEffect()); 2093 buffer.writeFlattenable(this->getPathEffect());
2089 buffer.writeFlattenable(this->getShader()); 2094 buffer.writeFlattenable(this->getShader());
2090 buffer.writeFlattenable(this->getXfermode()); 2095 buffer.writeFlattenable(this->getXfermode());
2091 buffer.writeFlattenable(this->getMaskFilter()); 2096 buffer.writeFlattenable(this->getMaskFilter());
2092 buffer.writeFlattenable(this->getColorFilter()); 2097 buffer.writeFlattenable(this->getColorFilter());
2093 buffer.writeFlattenable(this->getRasterizer()); 2098 buffer.writeFlattenable(this->getRasterizer());
2094 buffer.writeFlattenable(this->getLooper()); 2099 buffer.writeFlattenable(this->getLooper());
2095 buffer.writeFlattenable(this->getImageFilter()); 2100 buffer.writeFlattenable(this->getImageFilter());
2096 buffer.writeFlattenable(this->getAnnotation()); 2101 buffer.writeFlattenable(this->getAnnotation());
2097 } 2102 }
2103 #if SK_BUILD_FOR_ANDROID
2104 if (flatFlags & kHasNonDefaultPaintOptionsAndroid_FlatFlag) {
2105 this->getPaintOptionsAndroid().flatten(buffer);
2106 }
2107 #endif
2098 } 2108 }
2099 2109
2100 void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) { 2110 void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) {
2101 fPrivFlags = 0; 2111 fPrivFlags = 0;
2102 2112
2103 uint8_t flatFlags = 0; 2113 uint8_t flatFlags = 0;
2104 if (buffer.isOrderedBinaryBuffer()) { 2114 if (buffer.isOrderedBinaryBuffer()) {
2105 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); 2115 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize);
2106 const void* podData = buffer.getOrderedBinaryBuffer()->skip(kPODPaintSiz e); 2116 const void* podData = buffer.getOrderedBinaryBuffer()->skip(kPODPaintSiz e);
2107 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); 2117 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 } else { 2183 } else {
2174 this->setPathEffect(NULL); 2184 this->setPathEffect(NULL);
2175 this->setShader(NULL); 2185 this->setShader(NULL);
2176 this->setXfermode(NULL); 2186 this->setXfermode(NULL);
2177 this->setMaskFilter(NULL); 2187 this->setMaskFilter(NULL);
2178 this->setColorFilter(NULL); 2188 this->setColorFilter(NULL);
2179 this->setRasterizer(NULL); 2189 this->setRasterizer(NULL);
2180 this->setLooper(NULL); 2190 this->setLooper(NULL);
2181 this->setImageFilter(NULL); 2191 this->setImageFilter(NULL);
2182 } 2192 }
2193
2194 #if SK_BUILD_FOR_ANDROID
2195 this->setPaintOptionsAndroid(SkPaintOptionsAndroid());
2196 #endif
2197 if (flatFlags & kHasNonDefaultPaintOptionsAndroid_FlatFlag) {
2198 SkPaintOptionsAndroid options;
2199 options.unflatten(buffer);
2200 #if SK_BUILD_FOR_ANDROID
2201 this->setPaintOptionsAndroid(options);
2202 #endif
2203 }
2183 } 2204 }
2184 2205
2185 /////////////////////////////////////////////////////////////////////////////// 2206 ///////////////////////////////////////////////////////////////////////////////
2186 2207
2187 SkShader* SkPaint::setShader(SkShader* shader) { 2208 SkShader* SkPaint::setShader(SkShader* shader) {
2188 GEN_ID_INC_EVAL(shader != fShader); 2209 GEN_ID_INC_EVAL(shader != fShader);
2189 SkRefCnt_SafeAssign(fShader, shader); 2210 SkRefCnt_SafeAssign(fShader, shader);
2190 return shader; 2211 return shader;
2191 } 2212 }
2192 2213
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 case SkXfermode::kPlus_Mode: 2594 case SkXfermode::kPlus_Mode:
2574 return 0 == this->getAlpha(); 2595 return 0 == this->getAlpha();
2575 case SkXfermode::kDst_Mode: 2596 case SkXfermode::kDst_Mode:
2576 return true; 2597 return true;
2577 default: 2598 default:
2578 break; 2599 break;
2579 } 2600 }
2580 } 2601 }
2581 return false; 2602 return false;
2582 } 2603 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698