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

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

Issue 237013002: Remove currently unused code (Closed) Base URL: http://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') | 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 * 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"
11 #include "SkRRect.h" 11 #include "SkRRect.h"
12 #include "SkBBoxHierarchy.h" 12 #include "SkBBoxHierarchy.h"
13 #include "SkDevice.h" 13 #include "SkDevice.h"
14 #include "SkOffsetTable.h"
15 #include "SkPictureStateTree.h" 14 #include "SkPictureStateTree.h"
16 15
17 #define HEAP_BLOCK_SIZE 4096 16 #define HEAP_BLOCK_SIZE 4096
18 17
19 enum { 18 enum {
20 // just need a value that save or getSaveCount would never return 19 // just need a value that save or getSaveCount would never return
21 kNoInitialSave = -1, 20 kNoInitialSave = -1,
22 }; 21 };
23 22
24 // A lot of basic types get stored as a uint32_t: bools, ints, paint indices, et c. 23 // A lot of basic types get stored as a uint32_t: bools, ints, paint indices, et c.
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1090
1092 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1091 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1093 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1092 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1094 #endif 1093 #endif
1095 1094
1096 // op + paint index + bitmap index + left + top 1095 // op + paint index + bitmap index + left + top
1097 uint32_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar); 1096 uint32_t size = 3 * kUInt32Size + 2 * sizeof(SkScalar);
1098 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size); 1097 size_t initialOffset = this->addDraw(DRAW_BITMAP, &size);
1099 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWri tten()); 1098 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP, size) == fWriter.bytesWri tten());
1100 this->addPaintPtr(paint); 1099 this->addPaintPtr(paint);
1101 int bitmapID = this->addBitmap(bitmap); 1100 this->addBitmap(bitmap);
1102 this->addScalar(left); 1101 this->addScalar(left);
1103 this->addScalar(top); 1102 this->addScalar(top);
1104 this->validate(initialOffset, size); 1103 this->validate(initialOffset, size);
1105 this->trackBitmapUse(bitmapID, initialOffset);
1106 } 1104 }
1107 1105
1108 void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src, 1106 void SkPictureRecord::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect* src,
1109 const SkRect& dst, const SkPaint* pai nt, 1107 const SkRect& dst, const SkPaint* pai nt,
1110 DrawBitmapRectFlags flags) { 1108 DrawBitmapRectFlags flags) {
1111 if (bitmap.drawsNothing()) { 1109 if (bitmap.drawsNothing()) {
1112 return; 1110 return;
1113 } 1111 }
1114 1112
1115 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1113 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1116 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1114 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1117 #endif 1115 #endif
1118 // id + paint index + bitmap index + bool for 'src' + flags 1116 // id + paint index + bitmap index + bool for 'src' + flags
1119 uint32_t size = 5 * kUInt32Size; 1117 uint32_t size = 5 * kUInt32Size;
1120 if (NULL != src) { 1118 if (NULL != src) {
1121 size += sizeof(*src); // + rect 1119 size += sizeof(*src); // + rect
1122 } 1120 }
1123 size += sizeof(dst); // + rect 1121 size += sizeof(dst); // + rect
1124 1122
1125 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size); 1123 size_t initialOffset = this->addDraw(DRAW_BITMAP_RECT_TO_RECT, &size);
1126 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size) 1124 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_RECT_TO_RECT, size)
1127 == fWriter.bytesWritten()); 1125 == fWriter.bytesWritten());
1128 this->addPaintPtr(paint); 1126 this->addPaintPtr(paint);
1129 int bitmapID = this->addBitmap(bitmap); 1127 this->addBitmap(bitmap);
1130 this->addRectPtr(src); // may be null 1128 this->addRectPtr(src); // may be null
1131 this->addRect(dst); 1129 this->addRect(dst);
1132 this->addInt(flags); 1130 this->addInt(flags);
1133 this->validate(initialOffset, size); 1131 this->validate(initialOffset, size);
1134 this->trackBitmapUse(bitmapID, initialOffset);
1135 } 1132 }
1136 1133
1137 void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m atrix, 1134 void SkPictureRecord::drawBitmapMatrix(const SkBitmap& bitmap, const SkMatrix& m atrix,
1138 const SkPaint* paint) { 1135 const SkPaint* paint) {
1139 if (bitmap.drawsNothing()) { 1136 if (bitmap.drawsNothing()) {
1140 return; 1137 return;
1141 } 1138 }
1142 1139
1143 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1140 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1144 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1141 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1145 #endif 1142 #endif
1146 1143
1147 // id + paint index + bitmap index + matrix 1144 // id + paint index + bitmap index + matrix
1148 uint32_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL); 1145 uint32_t size = 3 * kUInt32Size + matrix.writeToMemory(NULL);
1149 size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size); 1146 size_t initialOffset = this->addDraw(DRAW_BITMAP_MATRIX, &size);
1150 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.b ytesWritten()); 1147 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_MATRIX, size) == fWriter.b ytesWritten());
1151 this->addPaintPtr(paint); 1148 this->addPaintPtr(paint);
1152 int bitmapID = this->addBitmap(bitmap); 1149 this->addBitmap(bitmap);
1153 this->addMatrix(matrix); 1150 this->addMatrix(matrix);
1154 this->validate(initialOffset, size); 1151 this->validate(initialOffset, size);
1155 this->trackBitmapUse(bitmapID, initialOffset);
1156 } 1152 }
1157 1153
1158 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent er, 1154 void SkPictureRecord::drawBitmapNine(const SkBitmap& bitmap, const SkIRect& cent er,
1159 const SkRect& dst, const SkPaint* paint) { 1155 const SkRect& dst, const SkPaint* paint) {
1160 if (bitmap.drawsNothing()) { 1156 if (bitmap.drawsNothing()) {
1161 return; 1157 return;
1162 } 1158 }
1163 1159
1164 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1160 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1165 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1161 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1166 #endif 1162 #endif
1167 1163
1168 // op + paint index + bitmap id + center + dst rect 1164 // op + paint index + bitmap id + center + dst rect
1169 uint32_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst); 1165 uint32_t size = 3 * kUInt32Size + sizeof(center) + sizeof(dst);
1170 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size); 1166 size_t initialOffset = this->addDraw(DRAW_BITMAP_NINE, &size);
1171 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.byt esWritten()); 1167 SkASSERT(initialOffset+getPaintOffset(DRAW_BITMAP_NINE, size) == fWriter.byt esWritten());
1172 this->addPaintPtr(paint); 1168 this->addPaintPtr(paint);
1173 int bitmapID = this->addBitmap(bitmap); 1169 this->addBitmap(bitmap);
1174 this->addIRect(center); 1170 this->addIRect(center);
1175 this->addRect(dst); 1171 this->addRect(dst);
1176 this->validate(initialOffset, size); 1172 this->validate(initialOffset, size);
1177 this->trackBitmapUse(bitmapID, initialOffset);
1178 } 1173 }
1179 1174
1180 void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top, 1175 void SkPictureRecord::drawSprite(const SkBitmap& bitmap, int left, int top,
1181 const SkPaint* paint = NULL) { 1176 const SkPaint* paint = NULL) {
1182 if (bitmap.drawsNothing()) { 1177 if (bitmap.drawsNothing()) {
1183 return; 1178 return;
1184 } 1179 }
1185 1180
1186 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE 1181 #ifdef SK_COLLAPSE_MATRIX_CLIP_STATE
1187 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType); 1182 fMCMgr.call(SkMatrixClipStateMgr::kOther_CallType);
1188 #endif 1183 #endif
1189 1184
1190 // op + paint index + bitmap index + left + top 1185 // op + paint index + bitmap index + left + top
1191 uint32_t size = 5 * kUInt32Size; 1186 uint32_t size = 5 * kUInt32Size;
1192 size_t initialOffset = this->addDraw(DRAW_SPRITE, &size); 1187 size_t initialOffset = this->addDraw(DRAW_SPRITE, &size);
1193 SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWri tten()); 1188 SkASSERT(initialOffset+getPaintOffset(DRAW_SPRITE, size) == fWriter.bytesWri tten());
1194 this->addPaintPtr(paint); 1189 this->addPaintPtr(paint);
1195 int bitmapID = this->addBitmap(bitmap); 1190 this->addBitmap(bitmap);
1196 this->addInt(left); 1191 this->addInt(left);
1197 this->addInt(top); 1192 this->addInt(top);
1198 this->validate(initialOffset, size); 1193 this->validate(initialOffset, size);
1199 this->trackBitmapUse(bitmapID, initialOffset);
1200 } 1194 }
1201 1195
1202 void SkPictureRecord::ComputeFontMetricsTopBottom(const SkPaint& paint, SkScalar topbot[2]) { 1196 void SkPictureRecord::ComputeFontMetricsTopBottom(const SkPaint& paint, SkScalar topbot[2]) {
1203 SkPaint::FontMetrics metrics; 1197 SkPaint::FontMetrics metrics;
1204 paint.getFontMetrics(&metrics); 1198 paint.getFontMetrics(&metrics);
1205 SkRect bounds; 1199 SkRect bounds;
1206 // construct a rect so we can see any adjustments from the paint. 1200 // construct a rect so we can see any adjustments from the paint.
1207 // we use 0,1 for left,right, just so the rect isn't empty 1201 // we use 0,1 for left,right, just so the rect isn't empty
1208 bounds.set(0, metrics.fTop, SK_Scalar1, metrics.fBottom); 1202 bounds.set(0, metrics.fTop, SK_Scalar1, metrics.fBottom);
1209 (void)paint.computeFastBounds(bounds, &bounds); 1203 (void)paint.computeFastBounds(bounds, &bounds);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 1560
1567 this->validate(initialOffset, size); 1561 this->validate(initialOffset, size);
1568 } 1562 }
1569 1563
1570 /////////////////////////////////////////////////////////////////////////////// 1564 ///////////////////////////////////////////////////////////////////////////////
1571 1565
1572 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info) { 1566 SkSurface* SkPictureRecord::onNewSurface(const SkImageInfo& info) {
1573 return NULL; 1567 return NULL;
1574 } 1568 }
1575 1569
1576 void SkPictureRecord::trackBitmapUse(int bitmapID, size_t offset) {
1577 #ifndef SK_ALLOW_BITMAP_TRACKING
1578 return;
1579 #endif
1580
1581 if (!(fRecordFlags & SkPicture::kOptimizeForClippedPlayback_RecordingFlag)) {
1582 return;
1583 }
1584
1585 if (SkBitmapHeap::INVALID_SLOT == bitmapID) {
1586 return;
1587 }
1588
1589 if (NULL == fBitmapUseOffsets) {
1590 fBitmapUseOffsets.reset(SkNEW(SkOffsetTable));
1591 }
1592
1593 fBitmapUseOffsets->add(bitmapID, offset);
1594 }
1595
1596 int SkPictureRecord::addBitmap(const SkBitmap& bitmap) { 1570 int SkPictureRecord::addBitmap(const SkBitmap& bitmap) {
1597 const int index = fBitmapHeap->insert(bitmap); 1571 const int index = fBitmapHeap->insert(bitmap);
1598 // In debug builds, a bad return value from insert() will crash, allowing fo r debugging. In 1572 // In debug builds, a bad return value from insert() will crash, allowing fo r debugging. In
1599 // release builds, the invalid value will be recorded so that the reader wil l know that there 1573 // release builds, the invalid value will be recorded so that the reader wil l know that there
1600 // was a problem. 1574 // was a problem.
1601 SkASSERT(index != SkBitmapHeap::INVALID_SLOT); 1575 SkASSERT(index != SkBitmapHeap::INVALID_SLOT);
1602 this->addInt(index); 1576 this->addInt(index);
1603 return index; 1577 return index;
1604 } 1578 }
1605 1579
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 void SkPictureRecord::validateRegions() const { 1814 void SkPictureRecord::validateRegions() const {
1841 int count = fRegions.count(); 1815 int count = fRegions.count();
1842 SkASSERT((unsigned) count < 0x1000); 1816 SkASSERT((unsigned) count < 0x1000);
1843 for (int index = 0; index < count; index++) { 1817 for (int index = 0; index < count; index++) {
1844 const SkFlatData* region = fRegions[index]; 1818 const SkFlatData* region = fRegions[index];
1845 SkASSERT(region); 1819 SkASSERT(region);
1846 // region->validate(); 1820 // region->validate();
1847 } 1821 }
1848 } 1822 }
1849 #endif 1823 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698