OLD | NEW |
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 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 topbot[1] = bounds.fBottom; | 1202 topbot[1] = bounds.fBottom; |
1203 } | 1203 } |
1204 | 1204 |
1205 void SkPictureRecord::addFontMetricsTopBottom(const SkPaint& paint, const SkFlat
Data& flat, | 1205 void SkPictureRecord::addFontMetricsTopBottom(const SkPaint& paint, const SkFlat
Data& flat, |
1206 SkScalar minY, SkScalar maxY) { | 1206 SkScalar minY, SkScalar maxY) { |
1207 WriteTopBot(paint, flat); | 1207 WriteTopBot(paint, flat); |
1208 this->addScalar(flat.topBot()[0] + minY); | 1208 this->addScalar(flat.topBot()[0] + minY); |
1209 this->addScalar(flat.topBot()[1] + maxY); | 1209 this->addScalar(flat.topBot()[1] + maxY); |
1210 } | 1210 } |
1211 | 1211 |
1212 void SkPictureRecord::drawText(const void* text, size_t byteLength, SkScalar x, | 1212 void SkPictureRecord::onDrawText(const void* text, size_t byteLength, SkScalar x
, SkScalar y, |
1213 SkScalar y, const SkPaint& paint) { | 1213 const SkPaint& paint) { |
1214 | 1214 |
1215 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 1215 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
1216 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | 1216 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
1217 #endif | 1217 #endif |
1218 | 1218 |
1219 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds(); | 1219 bool fast = !paint.isVerticalText() && paint.canComputeFastBounds(); |
1220 | 1220 |
1221 // op + paint index + length + 'length' worth of chars + x + y | 1221 // op + paint index + length + 'length' worth of chars + x + y |
1222 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); | 1222 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + 2 * sizeof(SkScalar); |
1223 if (fast) { | 1223 if (fast) { |
1224 size += 2 * sizeof(SkScalar); // + top & bottom | 1224 size += 2 * sizeof(SkScalar); // + top & bottom |
1225 } | 1225 } |
1226 | 1226 |
1227 DrawType op = fast ? DRAW_TEXT_TOP_BOTTOM : DRAW_TEXT; | 1227 DrawType op = fast ? DRAW_TEXT_TOP_BOTTOM : DRAW_TEXT; |
1228 size_t initialOffset = this->addDraw(op, &size); | 1228 size_t initialOffset = this->addDraw(op, &size); |
1229 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.bytesWritten()); | 1229 SkASSERT(initialOffset+getPaintOffset(op, size) == fWriter.bytesWritten()); |
1230 const SkFlatData* flatPaintData = addPaint(paint); | 1230 const SkFlatData* flatPaintData = addPaint(paint); |
1231 SkASSERT(flatPaintData); | 1231 SkASSERT(flatPaintData); |
1232 this->addText(text, byteLength); | 1232 this->addText(text, byteLength); |
1233 this->addScalar(x); | 1233 this->addScalar(x); |
1234 this->addScalar(y); | 1234 this->addScalar(y); |
1235 if (fast) { | 1235 if (fast) { |
1236 this->addFontMetricsTopBottom(paint, *flatPaintData, y, y); | 1236 this->addFontMetricsTopBottom(paint, *flatPaintData, y, y); |
1237 } | 1237 } |
1238 this->validate(initialOffset, size); | 1238 this->validate(initialOffset, size); |
1239 } | 1239 } |
1240 | 1240 |
1241 void SkPictureRecord::drawPosText(const void* text, size_t byteLength, | 1241 void SkPictureRecord::onDrawPosText(const void* text, size_t byteLength, const S
kPoint pos[], |
1242 const SkPoint pos[], const SkPaint& paint) { | 1242 const SkPaint& paint) { |
1243 | 1243 |
1244 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 1244 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
1245 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | 1245 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
1246 #endif | 1246 #endif |
1247 | 1247 |
1248 int points = paint.countText(text, byteLength); | 1248 int points = paint.countText(text, byteLength); |
1249 if (0 == points) | 1249 if (0 == points) |
1250 return; | 1250 return; |
1251 | 1251 |
1252 bool canUseDrawH = true; | 1252 bool canUseDrawH = true; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 this->addFontMetricsTopBottom(paint, *flatPaintData, minY, maxY); | 1320 this->addFontMetricsTopBottom(paint, *flatPaintData, minY, maxY); |
1321 } | 1321 } |
1322 } | 1322 } |
1323 #ifdef SK_DEBUG_SIZE | 1323 #ifdef SK_DEBUG_SIZE |
1324 fPointBytes += fWriter.bytesWritten() - start; | 1324 fPointBytes += fWriter.bytesWritten() - start; |
1325 fPointWrites += points; | 1325 fPointWrites += points; |
1326 #endif | 1326 #endif |
1327 this->validate(initialOffset, size); | 1327 this->validate(initialOffset, size); |
1328 } | 1328 } |
1329 | 1329 |
1330 void SkPictureRecord::drawPosTextH(const void* text, size_t byteLength, | 1330 void SkPictureRecord::onDrawPosTextH(const void* text, size_t byteLength, const
SkScalar xpos[], |
1331 const SkScalar xpos[], SkScalar constY, | 1331 SkScalar constY, const SkPaint& paint) { |
1332 const SkPaint& paint) { | |
1333 | |
1334 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 1332 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
1335 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | 1333 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
1336 #endif | 1334 #endif |
1337 | 1335 |
1338 const SkFlatData* flatPaintData = this->getFlatPaintData(paint); | 1336 const SkFlatData* flatPaintData = this->getFlatPaintData(paint); |
1339 this->drawPosTextHImpl(text, byteLength, xpos, constY, paint, flatPaintData)
; | 1337 this->drawPosTextHImpl(text, byteLength, xpos, constY, paint, flatPaintData)
; |
1340 } | 1338 } |
1341 | 1339 |
1342 void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength, | 1340 void SkPictureRecord::drawPosTextHImpl(const void* text, size_t byteLength, |
1343 const SkScalar xpos[], SkScalar constY, | 1341 const SkScalar xpos[], SkScalar constY, |
(...skipping 27 matching lines...) Expand all Loading... |
1371 } | 1369 } |
1372 this->addScalar(constY); | 1370 this->addScalar(constY); |
1373 fWriter.writeMul4(xpos, points * sizeof(SkScalar)); | 1371 fWriter.writeMul4(xpos, points * sizeof(SkScalar)); |
1374 #ifdef SK_DEBUG_SIZE | 1372 #ifdef SK_DEBUG_SIZE |
1375 fPointBytes += fWriter.bytesWritten() - start; | 1373 fPointBytes += fWriter.bytesWritten() - start; |
1376 fPointWrites += points; | 1374 fPointWrites += points; |
1377 #endif | 1375 #endif |
1378 this->validate(initialOffset, size); | 1376 this->validate(initialOffset, size); |
1379 } | 1377 } |
1380 | 1378 |
1381 void SkPictureRecord::drawTextOnPath(const void* text, size_t byteLength, | 1379 void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, cons
t SkPath& path, |
1382 const SkPath& path, const SkMatrix* matrix, | 1380 const SkMatrix* matrix, const SkPaint& pa
int) { |
1383 const SkPaint& paint) { | |
1384 | |
1385 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE | 1381 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE |
1386 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); | 1382 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); |
1387 #endif | 1383 #endif |
1388 | 1384 |
1389 // op + paint index + length + 'length' worth of data + path index + matrix | 1385 // op + paint index + length + 'length' worth of data + path index + matrix |
1390 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); | 1386 const SkMatrix& m = matrix ? *matrix : SkMatrix::I(); |
1391 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.write
ToMemory(NULL); | 1387 size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size + m.write
ToMemory(NULL); |
1392 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); | 1388 size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size); |
1393 SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.by
tesWritten()); | 1389 SkASSERT(initialOffset+getPaintOffset(DRAW_TEXT_ON_PATH, size) == fWriter.by
tesWritten()); |
1394 this->addPaint(paint); | 1390 this->addPaint(paint); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 void SkPictureRecord::validateRegions() const { | 1807 void SkPictureRecord::validateRegions() const { |
1812 int count = fRegions.count(); | 1808 int count = fRegions.count(); |
1813 SkASSERT((unsigned) count < 0x1000); | 1809 SkASSERT((unsigned) count < 0x1000); |
1814 for (int index = 0; index < count; index++) { | 1810 for (int index = 0; index < count; index++) { |
1815 const SkFlatData* region = fRegions[index]; | 1811 const SkFlatData* region = fRegions[index]; |
1816 SkASSERT(region); | 1812 SkASSERT(region); |
1817 // region->validate(); | 1813 // region->validate(); |
1818 } | 1814 } |
1819 } | 1815 } |
1820 #endif | 1816 #endif |
OLD | NEW |