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

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

Issue 19564007: Start from scratch on a faster SkFlatDictionary. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix windows build by making AllocScratch static Created 7 years, 5 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
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 8
9 #ifndef SkOrderedWriteBuffer_DEFINED 9 #ifndef SkOrderedWriteBuffer_DEFINED
10 #define SkOrderedWriteBuffer_DEFINED 10 #define SkOrderedWriteBuffer_DEFINED
11 11
12 #include "SkFlattenableBuffers.h" 12 #include "SkFlattenableBuffers.h"
13 13
14 #include "SkRefCnt.h" 14 #include "SkRefCnt.h"
15 #include "SkBitmapHeap.h" 15 #include "SkBitmapHeap.h"
16 #include "SkPath.h" 16 #include "SkPath.h"
17 #include "SkPicture.h" 17 #include "SkPicture.h"
18 #include "SkWriter32.h" 18 #include "SkWriter32.h"
19 19
20 class SkBitmap; 20 class SkBitmap;
21 class SkFlattenable; 21 class SkFlattenable;
22 class SkFactorySet; 22 class SkFactorySet;
23 class SkNamedFactorySet; 23 class SkNamedFactorySet;
24 class SkRefCntSet; 24 class SkRefCntSet;
25 25
26 class SkOrderedWriteBuffer : public SkFlattenableWriteBuffer { 26 class SkOrderedWriteBuffer : public SkFlattenableWriteBuffer {
27 public: 27 public:
28 SkOrderedWriteBuffer(size_t minSize); 28 SkOrderedWriteBuffer(size_t minSize);
29 SkOrderedWriteBuffer(size_t minSize, void* initialStorage, 29 SkOrderedWriteBuffer(size_t minSize, void* initialStorage, size_t storageSiz e);
30 size_t storageSize);
31 virtual ~SkOrderedWriteBuffer(); 30 virtual ~SkOrderedWriteBuffer();
32 31
33 virtual bool isOrderedBinaryBuffer() SK_OVERRIDE { return true; } 32 virtual bool isOrderedBinaryBuffer() SK_OVERRIDE { return true; }
34 virtual SkOrderedWriteBuffer* getOrderedBinaryBuffer() SK_OVERRIDE { return this; } 33 virtual SkOrderedWriteBuffer* getOrderedBinaryBuffer() SK_OVERRIDE { return this; }
35 34
36 SkWriter32* getWriter32() { return &fWriter; } 35 SkWriter32* getWriter32() { return &fWriter; }
36 void reset(void* storage, size_t storageSize) { fWriter.reset(storage, stora geSize); }
37
38 // Returns true if we've written only into the storage passed into construct or or reset.
39 // (You may be able to use this to avoid a call to writeToMemory.)
40 bool wroteOnlyToStorage() const { return fWriter.wroteOnlyToStorage(); }
37 41
38 void writeToMemory(void* dst) { fWriter.flatten(dst); } 42 void writeToMemory(void* dst) { fWriter.flatten(dst); }
39 uint32_t* reserve(size_t size) { return fWriter.reserve(size); } 43 uint32_t* reserve(size_t size) { return fWriter.reserve(size); }
40 uint32_t size() { return fWriter.size(); } 44
45 uint32_t bytesWritten() const { return fWriter.bytesWritten(); }
46 // Deprecated. Please call bytesWritten instead. TODO(mtklein): clean up
47 uint32_t size() const { return this->bytesWritten(); }
41 48
42 virtual void writeByteArray(const void* data, size_t size) SK_OVERRIDE; 49 virtual void writeByteArray(const void* data, size_t size) SK_OVERRIDE;
43 virtual void writeBool(bool value) SK_OVERRIDE; 50 virtual void writeBool(bool value) SK_OVERRIDE;
44 virtual void writeFixed(SkFixed value) SK_OVERRIDE; 51 virtual void writeFixed(SkFixed value) SK_OVERRIDE;
45 virtual void writeScalar(SkScalar value) SK_OVERRIDE; 52 virtual void writeScalar(SkScalar value) SK_OVERRIDE;
46 virtual void writeScalarArray(const SkScalar* value, uint32_t count) SK_OVER RIDE; 53 virtual void writeScalarArray(const SkScalar* value, uint32_t count) SK_OVER RIDE;
47 virtual void writeInt(int32_t value) SK_OVERRIDE; 54 virtual void writeInt(int32_t value) SK_OVERRIDE;
48 virtual void writeIntArray(const int32_t* value, uint32_t count) SK_OVERRIDE ; 55 virtual void writeIntArray(const int32_t* value, uint32_t count) SK_OVERRIDE ;
49 virtual void writeUInt(uint32_t value) SK_OVERRIDE; 56 virtual void writeUInt(uint32_t value) SK_OVERRIDE;
50 virtual void write32(int32_t value) SK_OVERRIDE; 57 virtual void write32(int32_t value) SK_OVERRIDE;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 108
102 SkBitmapHeap* fBitmapHeap; 109 SkBitmapHeap* fBitmapHeap;
103 SkRefCntSet* fTFSet; 110 SkRefCntSet* fTFSet;
104 111
105 SkPicture::EncodeBitmap fBitmapEncoder; 112 SkPicture::EncodeBitmap fBitmapEncoder;
106 113
107 typedef SkFlattenableWriteBuffer INHERITED; 114 typedef SkFlattenableWriteBuffer INHERITED;
108 }; 115 };
109 116
110 #endif // SkOrderedWriteBuffer_DEFINED 117 #endif // SkOrderedWriteBuffer_DEFINED
OLDNEW
« no previous file with comments | « include/core/SkWriter32.h ('k') | src/core/SkPictureFlat.h » ('j') | src/core/SkPictureFlat.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698