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

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

Issue 158913005: Merge tomhudson and mtklein SkPaint shrinking approaches. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Don't unref typeface. Created 6 years, 10 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
« no previous file with comments | « src/core/SkPictureFlat.h ('k') | tests/PaintTest.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 /* 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 "SkPicturePlayback.h" 8 #include "SkPicturePlayback.h"
9 #include "SkPictureRecord.h" 9 #include "SkPictureRecord.h"
10 #include "SkTypeface.h" 10 #include "SkTypeface.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 deepCopyInfo->controller.setBitmapStorage(heap); 202 deepCopyInfo->controller.setBitmapStorage(heap);
203 heap->unref(); 203 heap->unref();
204 } else { 204 } else {
205 deepCopyInfo->controller.setBitmapStorage(fBitmapHeap); 205 deepCopyInfo->controller.setBitmapStorage(fBitmapHeap);
206 } 206 }
207 207
208 SkDEBUGCODE(int heapSize = SafeCount(fBitmapHeap.get());) 208 SkDEBUGCODE(int heapSize = SafeCount(fBitmapHeap.get());)
209 for (int i = 0; i < paintCount; i++) { 209 for (int i = 0; i < paintCount; i++) {
210 if (needs_deep_copy(src.fPaints->at(i))) { 210 if (needs_deep_copy(src.fPaints->at(i))) {
211 deepCopyInfo->paintData[i] = 211 deepCopyInfo->paintData[i] =
212 SkFlatData::Create<SkPaintTraits>(&deepCopyInfo->control ler, 212 SkFlatData::Create<SkPaint::FlatteningTraits>(&deepCopyI nfo->controller,
213 src.fPaints->at(i), 0) ; 213 src.fPaints->at(i), 0) ;
214 214
215 } else { 215 } else {
216 // this is our sentinel, which we use in the unflatten loop 216 // this is our sentinel, which we use in the unflatten loop
217 deepCopyInfo->paintData[i] = NULL; 217 deepCopyInfo->paintData[i] = NULL;
218 } 218 }
219 } 219 }
220 SkASSERT(SafeCount(fBitmapHeap.get()) == heapSize); 220 SkASSERT(SafeCount(fBitmapHeap.get()) == heapSize);
221 221
222 // needed to create typeface playback 222 // needed to create typeface playback
223 deepCopyInfo->controller.setupPlaybacks(); 223 deepCopyInfo->controller.setupPlaybacks();
224 deepCopyInfo->initialized = true; 224 deepCopyInfo->initialized = true;
225 } 225 }
226 226
227 fPaints = SkTRefArray<SkPaint>::Create(paintCount); 227 fPaints = SkTRefArray<SkPaint>::Create(paintCount);
228 SkASSERT(deepCopyInfo->paintData.count() == paintCount); 228 SkASSERT(deepCopyInfo->paintData.count() == paintCount);
229 SkBitmapHeap* bmHeap = deepCopyInfo->controller.getBitmapHeap(); 229 SkBitmapHeap* bmHeap = deepCopyInfo->controller.getBitmapHeap();
230 SkTypefacePlayback* tfPlayback = deepCopyInfo->controller.getTypefacePla yback(); 230 SkTypefacePlayback* tfPlayback = deepCopyInfo->controller.getTypefacePla yback();
231 for (int i = 0; i < paintCount; i++) { 231 for (int i = 0; i < paintCount; i++) {
232 if (deepCopyInfo->paintData[i]) { 232 if (deepCopyInfo->paintData[i]) {
233 deepCopyInfo->paintData[i]->unflatten<SkPaintTraits>(&fPaints->w ritableAt(i), 233 deepCopyInfo->paintData[i]->unflatten<SkPaint::FlatteningTraits> (
234 bmHeap, tfP layback); 234 &fPaints->writableAt(i), bmHeap, tfPlayback);
235 } else { 235 } else {
236 // needs_deep_copy was false, so just need to assign 236 // needs_deep_copy was false, so just need to assign
237 fPaints->writableAt(i) = src.fPaints->at(i); 237 fPaints->writableAt(i) = src.fPaints->at(i);
238 } 238 }
239 } 239 }
240 240
241 } else { 241 } else {
242 fBitmaps = SkSafeRef(src.fBitmaps); 242 fBitmaps = SkSafeRef(src.fBitmaps);
243 fPaints = SkSafeRef(src.fPaints); 243 fPaints = SkSafeRef(src.fPaints);
244 } 244 }
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 for (index = 0; index < fPictureCount; index++) 1630 for (index = 0; index < fPictureCount; index++)
1631 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ), 1631 bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer ),
1632 "picture%p, ", fPictureRefs[index]); 1632 "picture%p, ", fPictureRefs[index]);
1633 if (fPictureCount > 0) 1633 if (fPictureCount > 0)
1634 SkDebugf("%s0};\n", pBuffer); 1634 SkDebugf("%s0};\n", pBuffer);
1635 1635
1636 const_cast<SkPicturePlayback*>(this)->dumpStream(); 1636 const_cast<SkPicturePlayback*>(this)->dumpStream();
1637 } 1637 }
1638 1638
1639 #endif 1639 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureFlat.h ('k') | tests/PaintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698