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

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

Issue 247983003: Revert of make drawText calls non-virtual, to ease SkFont and TextBlob (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/pipe/SkGPipeWrite.cpp » ('j') | 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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
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 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 topbot[1] = bounds.fBottom; 1205 topbot[1] = bounds.fBottom;
1206 } 1206 }
1207 1207
1208 void SkPictureRecord::addFontMetricsTopBottom(const SkPaint& paint, const SkFlat Data& flat, 1208 void SkPictureRecord::addFontMetricsTopBottom(const SkPaint& paint, const SkFlat Data& flat,
1209 SkScalar minY, SkScalar maxY) { 1209 SkScalar minY, SkScalar maxY) {
1210 WriteTopBot(paint, flat); 1210 WriteTopBot(paint, flat);
1211 this->addScalar(flat.topBot()[0] + minY); 1211 this->addScalar(flat.topBot()[0] + minY);
1212 this->addScalar(flat.topBot()[1] + maxY); 1212 this->addScalar(flat.topBot()[1] + maxY);
1213 } 1213 }
1214 1214
1215 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x , SkScalar y, 1215 void SkPictureRecord::drawText(const void* text, size_t byteLength, SkScalar x,
1216 const SkPaint& paint) { 1216 SkScalar y, const SkPaint& paint) {
1217 1217
1218 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1218 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1219 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1219 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1220 #endif 1220 #endif
1221 1221
1222 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds(); 1222 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds();
1223 1223
1224 // op + paint index + length + 'length' worth of chars + x + y 1224 // op + paint index + length + 'length' worth of chars + x + y
1225 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar ); 1225 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar );
1226 if (fast) { 1226 if (fast) {
1227 size += 2 * sizeof(SkScalar); // + top & bottom 1227 size += 2 * sizeof(SkScalar); // + top & bottom
1228 } 1228 }
1229 1229
1230 DrawType op = fast ? DRAW_TEXT_TOP_BOTTOM : DRAW_TEXT; 1230 DrawType op = fast ? DRAW_TEXT_TOP_BOTTOM : DRAW_TEXT;
1231 size_t initialOffset = this->addDraw(op, &size); 1231 size_t initialOffset = this->addDraw(op, &size);
1232 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.bytesWritten()); 1232 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.bytesWritten());
1233 const SkFlatData* flatPaintData = addPaint(paint); 1233 const SkFlatData* flatPaintData = addPaint(paint);
1234 SkASSERT(flatPaintData); 1234 SkASSERT(flatPaintData);
1235 this->addText(text, byteLength); 1235 this->addText(text, byteLength);
1236 this->addScalar(x); 1236 this->addScalar(x);
1237 this->addScalar(y); 1237 this->addScalar(y);
1238 if (fast) { 1238 if (fast) {
1239 this->addFontMetricsTopBottom(paint, *flatPaintData, y, y); 1239 this->addFontMetricsTopBottom(paint, *flatPaintData, y, y);
1240 } 1240 }
1241 this->validate(initialOffset, size); 1241 this->validate(initialOffset, size);
1242 } 1242 }
1243 1243
1244 void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const S kPoint pos[], 1244 void SkPictureRecord::drawPosText(const void* text, size_t byteLength,
1245 const SkPaint& paint) { 1245 const SkPoint pos[], const SkPaint& paint) {
1246 1246
1247 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1247 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1248 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1248 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1249 #endif 1249 #endif
1250 1250
1251 size_t points = paint.countText(text, byteLength); 1251 size_t points = paint.countText(text, byteLength);
1252 if (0 == points) 1252 if (0 == points)
1253 return; 1253 return;
1254 1254
1255 bool canUseDrawH = true; 1255 bool canUseDrawH = true;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 this->addFontMetricsTopBottom(paint, *flatPaintData, minY, maxY); 1323 this->addFontMetricsTopBottom(paint, *flatPaintData, minY, maxY);
1324 } 1324 }
1325 } 1325 }
1326 #ifdef SK_DEBUG_SIZE 1326 #ifdef SK_DEBUG_SIZE
1327 fPointBytes += fWriter.bytesWritten() - start; 1327 fPointBytes += fWriter.bytesWritten() - start;
1328 fPointWrites += points; 1328 fPointWrites += points;
1329 #endif 1329 #endif
1330 this->validate(initialOffset, size); 1330 this->validate(initialOffset, size);
1331 } 1331 }
1332 1332
1333 void SkPictureRecord::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], 1333 void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength,
1334 SkScalar constY, const SkPaint& paint) { 1334 const SkScalar xpos[], SkScalar constY,
1335 const SkPaint& paint) {
1336
1335 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1337 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1336 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1338 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1337 #endif 1339 #endif
1338 1340
1339 const SkFlatData* flatPaintData = this->getFlatPaintData(paint); 1341 const SkFlatData* flatPaintData = this->getFlatPaintData(paint);
1340 this->drawPosTextHImpl(text, byteLength, xpos, constY, paint, flatPaintData) ; 1342 this->drawPosTextHImpl(text, byteLength, xpos, constY, paint, flatPaintData) ;
1341 } 1343 }
1342 1344
1343 void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength, 1345 void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength,
1344 const SkScalar xpos[], SkScalar constY, 1346 const SkScalar xpos[], SkScalar constY,
(...skipping 27 matching lines...) Expand all
1372 } 1374 }
1373 this->addScalar(constY); 1375 this->addScalar(constY);
1374 fWriter.writeMul4(xpos, points * sizeof(SkScalar)); 1376 fWriter.writeMul4(xpos, points * sizeof(SkScalar));
1375 #ifdef SK_DEBUG_SIZE 1377 #ifdef SK_DEBUG_SIZE
1376 fPointBytes += fWriter.bytesWritten() - start; 1378 fPointBytes += fWriter.bytesWritten() - start;
1377 fPointWrites += points; 1379 fPointWrites += points;
1378 #endif 1380 #endif
1379 this->validate(initialOffset, size); 1381 this->validate(initialOffset, size);
1380 } 1382 }
1381 1383
1382 void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons t SkPath& path, 1384 void SkPictureRecord::drawTextOnPath(const void* text, size_t byteLength,
1383 const SkMatrix* matrix, const SkPaint& pa int) { 1385 const SkPath& path, const SkMatrix* matrix,
1386 const SkPaint& paint) {
1387
1384 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1388 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1385 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1389 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1386 #endif 1390 #endif
1387 1391
1388 // op + paint index + length + 'length' worth of data + path index + matrix 1392 // op + paint index + length + 'length' worth of data + path index + matrix
1389 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); 1393 const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
1390 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.wri teToMemory(NULL); 1394 uint32_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.wri teToMemory(NULL);
1391 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); 1395 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size);
1392 SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.by tesWritten()); 1396 SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.by tesWritten());
1393 this->addPaint(paint); 1397 this->addPaint(paint);
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 void SkPictureRecord::validateRegions() const { 1814 void SkPictureRecord::validateRegions() const {
1811 int count = fRegions.count(); 1815 int count = fRegions.count();
1812 SkASSERT((unsigned) count < 0x1000); 1816 SkASSERT((unsigned) count < 0x1000);
1813 for (int index = 0; index < count; index++) { 1817 for (int index = 0; index < count; index++) {
1814 const SkFlatData* region = fRegions[index]; 1818 const SkFlatData* region = fRegions[index];
1815 SkASSERT(region); 1819 SkASSERT(region);
1816 // region->validate(); 1820 // region->validate();
1817 } 1821 }
1818 } 1822 }
1819 #endif 1823 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | src/pipe/SkGPipeWrite.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698