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

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: 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 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 } 2038 }
2039 2039
2040 2040
2041 if (buffer.isOrderedBinaryBuffer()) { 2041 if (buffer.isOrderedBinaryBuffer()) {
2042 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); 2042 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize);
2043 uint32_t* ptr = buffer.getOrderedBinaryBuffer()->reserve(kPODPaintSize); 2043 uint32_t* ptr = buffer.getOrderedBinaryBuffer()->reserve(kPODPaintSize);
2044 2044
2045 ptr = write_scalar(ptr, this->getTextSize()); 2045 ptr = write_scalar(ptr, this->getTextSize());
2046 ptr = write_scalar(ptr, this->getTextScaleX()); 2046 ptr = write_scalar(ptr, this->getTextScaleX());
2047 ptr = write_scalar(ptr, this->getTextSkewX()); 2047 ptr = write_scalar(ptr, this->getTextSkewX());
2048 // Dummy value for obsolete hinting scale factor. TODO: remove with nex t picture version
2049 ptr = write_scalar(ptr, SK_Scalar1);
2050 ptr = write_scalar(ptr, this->getStrokeWidth()); 2048 ptr = write_scalar(ptr, this->getStrokeWidth());
2051 ptr = write_scalar(ptr, this->getStrokeMiter()); 2049 ptr = write_scalar(ptr, this->getStrokeMiter());
2052 *ptr++ = this->getColor(); 2050 *ptr++ = this->getColor();
2053 // previously flags:16, textAlign:8, flatFlags:8 2051 // previously flags:16, textAlign:8, flatFlags:8
2054 // now flags:16, hinting:4, textAlign:4, flatFlags:8 2052 // now flags:16, hinting:4, textAlign:4, flatFlags:8
2055 *ptr++ = (this->getFlags() << 16) | 2053 *ptr++ = (this->getFlags() << 16) |
2056 // hinting added later. 0 in this nibble means use the default. 2054 // hinting added later. 0 in this nibble means use the default.
2057 ((this->getHinting()+1) << 12) | 2055 ((this->getHinting()+1) << 12) |
2058 (this->getTextAlign() << 8) | 2056 (this->getTextAlign() << 8) |
2059 flatFlags; 2057 flatFlags;
2060 *ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(), 2058 *ptr++ = pack_4(this->getStrokeCap(), this->getStrokeJoin(),
2061 this->getStyle(), this->getTextEncoding()); 2059 this->getStyle(), this->getTextEncoding());
2062 } else { 2060 } else {
2063 buffer.writeScalar(fTextSize); 2061 buffer.writeScalar(fTextSize);
2064 buffer.writeScalar(fTextScaleX); 2062 buffer.writeScalar(fTextScaleX);
2065 buffer.writeScalar(fTextSkewX); 2063 buffer.writeScalar(fTextSkewX);
2066 // Dummy value for obsolete hinting scale factor. TODO: remove with nex t picture version
2067 buffer.writeScalar(SK_Scalar1);
2068 buffer.writeScalar(fWidth); 2064 buffer.writeScalar(fWidth);
2069 buffer.writeScalar(fMiterLimit); 2065 buffer.writeScalar(fMiterLimit);
2070 buffer.writeColor(fColor); 2066 buffer.writeColor(fColor);
2071 buffer.writeUInt(fFlags); 2067 buffer.writeUInt(fFlags);
2072 buffer.writeUInt(fHinting); 2068 buffer.writeUInt(fHinting);
2073 buffer.writeUInt(fTextAlign); 2069 buffer.writeUInt(fTextAlign);
2074 buffer.writeUInt(flatFlags); 2070 buffer.writeUInt(flatFlags);
2075 2071
2076 buffer.writeUInt(fCapType); 2072 buffer.writeUInt(fCapType);
2077 buffer.writeUInt(fJoinType); 2073 buffer.writeUInt(fJoinType);
(...skipping 10 matching lines...) Expand all
2088 buffer.writeFlattenable(this->getPathEffect()); 2084 buffer.writeFlattenable(this->getPathEffect());
2089 buffer.writeFlattenable(this->getShader()); 2085 buffer.writeFlattenable(this->getShader());
2090 buffer.writeFlattenable(this->getXfermode()); 2086 buffer.writeFlattenable(this->getXfermode());
2091 buffer.writeFlattenable(this->getMaskFilter()); 2087 buffer.writeFlattenable(this->getMaskFilter());
2092 buffer.writeFlattenable(this->getColorFilter()); 2088 buffer.writeFlattenable(this->getColorFilter());
2093 buffer.writeFlattenable(this->getRasterizer()); 2089 buffer.writeFlattenable(this->getRasterizer());
2094 buffer.writeFlattenable(this->getLooper()); 2090 buffer.writeFlattenable(this->getLooper());
2095 buffer.writeFlattenable(this->getImageFilter()); 2091 buffer.writeFlattenable(this->getImageFilter());
2096 buffer.writeFlattenable(this->getAnnotation()); 2092 buffer.writeFlattenable(this->getAnnotation());
2097 } 2093 }
2094
2095 #if SK_BUILD_FOR_ANDROID
2096 this->getPaintOptionsAndroid().flatten(buffer);
2097 #endif
2098 } 2098 }
2099 2099
2100 void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) { 2100 void SkPaint::unflatten(SkFlattenableReadBuffer& buffer) {
2101 fPrivFlags = 0; 2101 fPrivFlags = 0;
2102 2102
2103 uint8_t flatFlags = 0; 2103 uint8_t flatFlags = 0;
2104 if (buffer.isOrderedBinaryBuffer()) { 2104 if (buffer.isOrderedBinaryBuffer()) {
2105 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); 2105 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize);
2106 const void* podData = buffer.getOrderedBinaryBuffer()->skip(kPODPaintSiz e); 2106 const void* podData = buffer.getOrderedBinaryBuffer()->skip(kPODPaintSiz e);
2107 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); 2107 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData);
2108 2108
2109 // the order we read must match the order we wrote in flatten() 2109 // the order we read must match the order we wrote in flatten()
2110 this->setTextSize(read_scalar(pod)); 2110 this->setTextSize(read_scalar(pod));
2111 this->setTextScaleX(read_scalar(pod)); 2111 this->setTextScaleX(read_scalar(pod));
2112 this->setTextSkewX(read_scalar(pod)); 2112 this->setTextSkewX(read_scalar(pod));
2113 // Skip the hinting scalar factor, which is not supported.
2114 read_scalar(pod);
2115 this->setStrokeWidth(read_scalar(pod)); 2113 this->setStrokeWidth(read_scalar(pod));
2116 this->setStrokeMiter(read_scalar(pod)); 2114 this->setStrokeMiter(read_scalar(pod));
2117 this->setColor(*pod++); 2115 this->setColor(*pod++);
2118 2116
2119 // previously flags:16, textAlign:8, flatFlags:8 2117 // previously flags:16, textAlign:8, flatFlags:8
2120 // now flags:16, hinting:4, textAlign:4, flatFlags:8 2118 // now flags:16, hinting:4, textAlign:4, flatFlags:8
2121 uint32_t tmp = *pod++; 2119 uint32_t tmp = *pod++;
2122 this->setFlags(tmp >> 16); 2120 this->setFlags(tmp >> 16);
2123 2121
2124 // hinting added later. 0 in this nibble means use the default. 2122 // hinting added later. 0 in this nibble means use the default.
2125 uint32_t hinting = (tmp >> 12) & 0xF; 2123 uint32_t hinting = (tmp >> 12) & 0xF;
2126 this->setHinting(0 == hinting ? kNormal_Hinting : static_cast<Hinting>(h inting-1)); 2124 this->setHinting(0 == hinting ? kNormal_Hinting : static_cast<Hinting>(h inting-1));
2127 2125
2128 this->setTextAlign(static_cast<Align>((tmp >> 8) & 0xF)); 2126 this->setTextAlign(static_cast<Align>((tmp >> 8) & 0xF));
2129 2127
2130 flatFlags = tmp & 0xFF; 2128 flatFlags = tmp & 0xFF;
2131 2129
2132 tmp = *pod++; 2130 tmp = *pod++;
2133 this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF)); 2131 this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF));
2134 this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF)); 2132 this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF));
2135 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); 2133 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF));
2136 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); 2134 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF));
2137 } else { 2135 } else {
2138 this->setTextSize(buffer.readScalar()); 2136 this->setTextSize(buffer.readScalar());
2139 this->setTextScaleX(buffer.readScalar()); 2137 this->setTextScaleX(buffer.readScalar());
2140 this->setTextSkewX(buffer.readScalar()); 2138 this->setTextSkewX(buffer.readScalar());
2141 // Skip the hinting scalar factor, which is not supported.
2142 buffer.readScalar();
2143 this->setStrokeWidth(buffer.readScalar()); 2139 this->setStrokeWidth(buffer.readScalar());
2144 this->setStrokeMiter(buffer.readScalar()); 2140 this->setStrokeMiter(buffer.readScalar());
2145 this->setColor(buffer.readColor()); 2141 this->setColor(buffer.readColor());
2146 this->setFlags(buffer.readUInt()); 2142 this->setFlags(buffer.readUInt());
2147 this->setHinting(static_cast<SkPaint::Hinting>(buffer.readUInt())); 2143 this->setHinting(static_cast<SkPaint::Hinting>(buffer.readUInt()));
2148 this->setTextAlign(static_cast<SkPaint::Align>(buffer.readUInt())); 2144 this->setTextAlign(static_cast<SkPaint::Align>(buffer.readUInt()));
2149 flatFlags = buffer.readUInt(); 2145 flatFlags = buffer.readUInt();
2150 2146
2151 this->setStrokeCap(static_cast<SkPaint::Cap>(buffer.readUInt())); 2147 this->setStrokeCap(static_cast<SkPaint::Cap>(buffer.readUInt()));
2152 this->setStrokeJoin(static_cast<SkPaint::Join>(buffer.readUInt())); 2148 this->setStrokeJoin(static_cast<SkPaint::Join>(buffer.readUInt()));
(...skipping 20 matching lines...) Expand all
2173 } else { 2169 } else {
2174 this->setPathEffect(NULL); 2170 this->setPathEffect(NULL);
2175 this->setShader(NULL); 2171 this->setShader(NULL);
2176 this->setXfermode(NULL); 2172 this->setXfermode(NULL);
2177 this->setMaskFilter(NULL); 2173 this->setMaskFilter(NULL);
2178 this->setColorFilter(NULL); 2174 this->setColorFilter(NULL);
2179 this->setRasterizer(NULL); 2175 this->setRasterizer(NULL);
2180 this->setLooper(NULL); 2176 this->setLooper(NULL);
2181 this->setImageFilter(NULL); 2177 this->setImageFilter(NULL);
2182 } 2178 }
2179 #if SK_BUILD_FOR_ANDROID
2180 SkPaintOptionsAndroid options;
2181 options.unflatten(buffer);
2182 this->setPaintOptionsAndroid(options);
2183 #endif
2183 } 2184 }
2184 2185
2185 /////////////////////////////////////////////////////////////////////////////// 2186 ///////////////////////////////////////////////////////////////////////////////
2186 2187
2187 SkShader* SkPaint::setShader(SkShader* shader) { 2188 SkShader* SkPaint::setShader(SkShader* shader) {
2188 GEN_ID_INC_EVAL(shader != fShader); 2189 GEN_ID_INC_EVAL(shader != fShader);
2189 SkRefCnt_SafeAssign(fShader, shader); 2190 SkRefCnt_SafeAssign(fShader, shader);
2190 return shader; 2191 return shader;
2191 } 2192 }
2192 2193
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 case SkXfermode::kPlus_Mode: 2574 case SkXfermode::kPlus_Mode:
2574 return 0 == this->getAlpha(); 2575 return 0 == this->getAlpha();
2575 case SkXfermode::kDst_Mode: 2576 case SkXfermode::kDst_Mode:
2576 return true; 2577 return true;
2577 default: 2578 default:
2578 break; 2579 break;
2579 } 2580 }
2580 } 2581 }
2581 return false; 2582 return false;
2582 } 2583 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698