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

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

Issue 23001007: Remove the call to getFontMetrics from SkBBoxRecord (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 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
« src/core/SkPictureRecord.h ('K') | « src/core/SkPictureRecord.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
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 #include "SkPictureRecord.h" 8 #include "SkPictureRecord.h"
9 #include "SkTSearch.h" 9 #include "SkTSearch.h"
10 #include "SkPixelRef.h" 10 #include "SkPixelRef.h"
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 #ifdef SK_DEBUG_SIZE 1099 #ifdef SK_DEBUG_SIZE
1100 fPointBytes += fWriter.size() - start; 1100 fPointBytes += fWriter.size() - start;
1101 fPointWrites += points; 1101 fPointWrites += points;
1102 #endif 1102 #endif
1103 validate(initialOffset, size); 1103 validate(initialOffset, size);
1104 } 1104 }
1105 1105
1106 void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength, 1106 void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength,
1107 const SkScalar xpos[], SkScalar constY, 1107 const SkScalar xpos[], SkScalar constY,
1108 const SkPaint& paint) { 1108 const SkPaint& paint) {
1109 drawPosTextHImpl(text, byteLength, xpos, constY, paint, NULL);
reed1 2013/08/20 17:59:23 Might be clearer if we called getFlatPaintData her
1110
1111 }
1112 void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength,
1113 const SkScalar xpos[], SkScalar constY,
1114 const SkPaint& paint, const SkFlatData* flatPaintData) {
1109 size_t points = paint.countText(text, byteLength); 1115 size_t points = paint.countText(text, byteLength);
1110 if (0 == points) 1116 if (0 == points)
1111 return; 1117 return;
1112 1118
1113 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds(); 1119 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds();
1114 1120
1115 // op + paint index + length + 'length' worth of data + num points 1121 // op + paint index + length + 'length' worth of data + num points
1116 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size; 1122 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 1 * kUInt32Size;
1117 if (fast) { 1123 if (fast) {
1118 size += 2 * sizeof(SkScalar); // + top & bottom 1124 size += 2 * sizeof(SkScalar); // + top & bottom
1119 } 1125 }
1120 // + y + the actual points 1126 // + y + the actual points
1121 size += 1 * kUInt32Size + points * sizeof(SkScalar); 1127 size += 1 * kUInt32Size + points * sizeof(SkScalar);
1122
1123 uint32_t initialOffset = this->addDraw(fast ? DRAW_POS_TEXT_H_TOP_BOTTOM : D RAW_POS_TEXT_H, 1128 uint32_t initialOffset = this->addDraw(fast ? DRAW_POS_TEXT_H_TOP_BOTTOM : D RAW_POS_TEXT_H,
1124 &size); 1129 &size);
1125 const SkFlatData* flatPaintData = addPaint(paint); 1130 if (NULL == flatPaintData) {
1131 flatPaintData = addPaint(paint);
1132 } else {
1133 addFlatPaint(flatPaintData);
1134 }
1126 SkASSERT(flatPaintData); 1135 SkASSERT(flatPaintData);
1136
1127 addText(text, byteLength); 1137 addText(text, byteLength);
1128 addInt(points); 1138 addInt(points);
1129 1139
1130 #ifdef SK_DEBUG_SIZE 1140 #ifdef SK_DEBUG_SIZE
1131 size_t start = fWriter.size(); 1141 size_t start = fWriter.size();
1132 #endif 1142 #endif
1133 if (fast) { 1143 if (fast) {
1134 addFontMetricsTopBottom(paint, *flatPaintData, constY, constY); 1144 addFontMetricsTopBottom(paint, *flatPaintData, constY, constY);
1135 } 1145 }
1136 addScalar(constY); 1146 addScalar(constY);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 } 1271 }
1262 1272
1263 void SkPictureRecord::addMatrix(const SkMatrix& matrix) { 1273 void SkPictureRecord::addMatrix(const SkMatrix& matrix) {
1264 addMatrixPtr(&matrix); 1274 addMatrixPtr(&matrix);
1265 } 1275 }
1266 1276
1267 void SkPictureRecord::addMatrixPtr(const SkMatrix* matrix) { 1277 void SkPictureRecord::addMatrixPtr(const SkMatrix* matrix) {
1268 this->addInt(matrix ? fMatrices.find(*matrix) : 0); 1278 this->addInt(matrix ? fMatrices.find(*matrix) : 0);
1269 } 1279 }
1270 1280
1281 const SkFlatData* SkPictureRecord::getFlatPaintData(const SkPaint& paint) {
1282 return fPaints.findAndReturnFlat(paint);
1283 }
1284
1271 const SkFlatData* SkPictureRecord::addPaintPtr(const SkPaint* paint) { 1285 const SkFlatData* SkPictureRecord::addPaintPtr(const SkPaint* paint) {
1272 const SkFlatData* data = paint ? fPaints.findAndReturnFlat(*paint) : NULL; 1286 const SkFlatData* data = paint ? getFlatPaintData(*paint) : NULL;
1273 int index = data ? data->index() : 0; 1287 this->addFlatPaint(data);
1288 return data;
1289 }
1290
1291 void SkPictureRecord::addFlatPaint(const SkFlatData* flatPaint) {
1292 int index = flatPaint ? flatPaint->index() : 0;
1274 this->addInt(index); 1293 this->addInt(index);
1275 return data;
1276 } 1294 }
1277 1295
1278 void SkPictureRecord::addPath(const SkPath& path) { 1296 void SkPictureRecord::addPath(const SkPath& path) {
1279 if (NULL == fPathHeap) { 1297 if (NULL == fPathHeap) {
1280 fPathHeap = SkNEW(SkPathHeap); 1298 fPathHeap = SkNEW(SkPathHeap);
1281 } 1299 }
1282 addInt(fPathHeap->append(path)); 1300 addInt(fPathHeap->append(path));
1283 } 1301 }
1284 1302
1285 void SkPictureRecord::addPicture(SkPicture& picture) { 1303 void SkPictureRecord::addPicture(SkPicture& picture) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 void SkPictureRecord::validateRegions() const { 1503 void SkPictureRecord::validateRegions() const {
1486 int count = fRegions.count(); 1504 int count = fRegions.count();
1487 SkASSERT((unsigned) count < 0x1000); 1505 SkASSERT((unsigned) count < 0x1000);
1488 for (int index = 0; index < count; index++) { 1506 for (int index = 0; index < count; index++) {
1489 const SkFlatData* region = fRegions[index]; 1507 const SkFlatData* region = fRegions[index];
1490 SkASSERT(region); 1508 SkASSERT(region);
1491 // region->validate(); 1509 // region->validate();
1492 } 1510 }
1493 } 1511 }
1494 #endif 1512 #endif
OLDNEW
« src/core/SkPictureRecord.h ('K') | « src/core/SkPictureRecord.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698