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

Side by Side Diff: src/core/SkPictureFlat.h

Issue 719113004: Followup: remove unnecessary SkTRefArray (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: count Created 6 years, 1 month 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/SkPictureData.cpp ('k') | src/core/SkTRefArray.h » ('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 #ifndef SkPictureFlat_DEFINED 8 #ifndef SkPictureFlat_DEFINED
9 #define SkPictureFlat_DEFINED 9 #define SkPictureFlat_DEFINED
10 10
11 11
12 #include "SkBitmapHeap.h" 12 #include "SkBitmapHeap.h"
13 #include "SkChecksum.h" 13 #include "SkChecksum.h"
14 #include "SkChunkAlloc.h" 14 #include "SkChunkAlloc.h"
15 #include "SkReadBuffer.h" 15 #include "SkReadBuffer.h"
16 #include "SkWriteBuffer.h" 16 #include "SkWriteBuffer.h"
17 #include "SkPaint.h" 17 #include "SkPaint.h"
18 #include "SkPicture.h" 18 #include "SkPicture.h"
19 #include "SkPtrRecorder.h" 19 #include "SkPtrRecorder.h"
20 #include "SkTDynamicHash.h" 20 #include "SkTDynamicHash.h"
21 #include "SkTRefArray.h"
22 21
23 enum DrawType { 22 enum DrawType {
24 UNUSED, 23 UNUSED,
25 CLIP_PATH, 24 CLIP_PATH,
26 CLIP_REGION, 25 CLIP_REGION,
27 CLIP_RECT, 26 CLIP_RECT,
28 CLIP_RRECT, 27 CLIP_RRECT,
29 CONCAT, 28 CONCAT,
30 DRAW_BITMAP, 29 DRAW_BITMAP,
31 DRAW_BITMAP_MATRIX, 30 DRAW_BITMAP_MATRIX,
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // findAndReturnMutableFlat already called fHash.add(), so we just clean up the old entry. 441 // findAndReturnMutableFlat already called fHash.add(), so we just clean up the old entry.
443 fHash.remove(*found); 442 fHash.remove(*found);
444 fController->unalloc((void*)found); 443 fController->unalloc((void*)found);
445 SkASSERT(this->count() == oldCount); 444 SkASSERT(this->count() == oldCount);
446 445
447 *replaced = true; 446 *replaced = true;
448 return flat; 447 return flat;
449 } 448 }
450 449
451 /** 450 /**
452 * Unflatten the objects and return them in SkTRefArray, or return NULL
453 * if there no objects. Caller takes ownership of result.
454 */
455 SkTRefArray<T>* unflattenToArray() const {
456 const int count = this->count();
457 if (count == 0) {
458 return NULL;
459 }
460 SkTRefArray<T>* array = SkTRefArray<T>::Create(count);
461 for (int i = 0; i < count; i++) {
462 this->unflatten(&array->writableAt(i), fIndexedData[i]);
463 }
464 return array;
465 }
466
467 /**
468 * Unflatten the specific object at the given index. 451 * Unflatten the specific object at the given index.
469 * Caller takes ownership of the result. 452 * Caller takes ownership of the result.
470 */ 453 */
471 T* unflatten(int index) const { 454 T* unflatten(int index) const {
472 // index is 1-based, while fIndexedData is 0-based. 455 // index is 1-based, while fIndexedData is 0-based.
473 const SkFlatData* element = fIndexedData[index-1]; 456 const SkFlatData* element = fIndexedData[index-1];
474 SkASSERT(index == element->index()); 457 SkASSERT(index == element->index());
475 458
476 T* dst = new T; 459 T* dst = new T;
477 this->unflatten(dst, element); 460 this->unflatten(dst, element);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 bool fReady; 547 bool fReady;
565 548
566 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas ed. Careful! 549 // For index -> SkFlatData. 0-based, while all indices in the API are 1-bas ed. Careful!
567 SkTDArray<const SkFlatData*> fIndexedData; 550 SkTDArray<const SkFlatData*> fIndexedData;
568 551
569 // For SkFlatData -> cached SkFlatData, which has index(). 552 // For SkFlatData -> cached SkFlatData, which has index().
570 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::HashTraits> fHash; 553 SkTDynamicHash<SkFlatData, SkFlatData, SkFlatData::HashTraits> fHash;
571 }; 554 };
572 555
573 #endif 556 #endif
OLDNEW
« no previous file with comments | « src/core/SkPictureData.cpp ('k') | src/core/SkTRefArray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698