OLD | NEW |
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 | 9 |
10 | 10 |
11 #ifndef SkData_DEFINED | 11 #ifndef SkData_DEFINED |
12 #define SkData_DEFINED | 12 #define SkData_DEFINED |
13 | 13 |
14 #include "SkFlattenable.h" | 14 #include "SkFlattenable.h" |
15 | 15 |
| 16 struct SkFILE; |
| 17 |
16 /** | 18 /** |
17 * SkData holds an immutable data buffer. Not only is the data immutable, | 19 * SkData holds an immutable data buffer. Not only is the data immutable, |
18 * but the actual ptr that is returned (by data() or bytes()) is guaranteed | 20 * but the actual ptr that is returned (by data() or bytes()) is guaranteed |
19 * to always be the same for the life of this instance. | 21 * to always be the same for the life of this instance. |
20 */ | 22 */ |
21 class SK_API SkData : public SkFlattenable { | 23 class SK_API SkData : public SkFlattenable { |
22 public: | 24 public: |
23 SK_DECLARE_INST_COUNT(SkData) | 25 SK_DECLARE_INST_COUNT(SkData) |
24 | 26 |
25 /** | 27 /** |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 static SkData* NewWithProc(const void* data, size_t length, | 84 static SkData* NewWithProc(const void* data, size_t length, |
83 ReleaseProc proc, void* context); | 85 ReleaseProc proc, void* context); |
84 | 86 |
85 /** | 87 /** |
86 * Create a new dataref from a pointer allocated by malloc. The Data object | 88 * Create a new dataref from a pointer allocated by malloc. The Data object |
87 * takes ownership of that allocation, and will handling calling sk_free. | 89 * takes ownership of that allocation, and will handling calling sk_free. |
88 */ | 90 */ |
89 static SkData* NewFromMalloc(const void* data, size_t length); | 91 static SkData* NewFromMalloc(const void* data, size_t length); |
90 | 92 |
91 /** | 93 /** |
92 * Create a new dataref from a pointer allocated by mmap. The Data object | 94 * Create a new dataref from a SkFILE. |
93 * will handle calling munmap(). | 95 * This does not take ownership of the SkFILE, nor close it. |
| 96 * The SkFILE must be open for reading only. |
| 97 * Returns NULL on failure. |
94 */ | 98 */ |
95 static SkData* NewFromMMap(const void* data, size_t length); | 99 static SkData* NewFromFILE(SkFILE* f); |
96 | 100 |
97 /** | 101 /** |
98 * Create a new dataref using a subset of the data in the specified | 102 * Create a new dataref using a subset of the data in the specified |
99 * src dataref. | 103 * src dataref. |
100 */ | 104 */ |
101 static SkData* NewSubset(const SkData* src, size_t offset, size_t length); | 105 static SkData* NewSubset(const SkData* src, size_t offset, size_t length); |
102 | 106 |
103 /** | 107 /** |
104 * Returns a new empty dataref (or a reference to a shared empty dataref). | 108 * Returns a new empty dataref (or a reference to a shared empty dataref). |
105 * New or shared, the caller must see that unref() is eventually called. | 109 * New or shared, the caller must see that unref() is eventually called. |
(...skipping 16 matching lines...) Expand all Loading... |
122 SkData(const void* ptr, size_t size, ReleaseProc, void* context); | 126 SkData(const void* ptr, size_t size, ReleaseProc, void* context); |
123 virtual ~SkData(); | 127 virtual ~SkData(); |
124 | 128 |
125 typedef SkFlattenable INHERITED; | 129 typedef SkFlattenable INHERITED; |
126 }; | 130 }; |
127 | 131 |
128 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ | 132 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ |
129 typedef SkAutoTUnref<SkData> SkAutoDataUnref; | 133 typedef SkAutoTUnref<SkData> SkAutoDataUnref; |
130 | 134 |
131 #endif | 135 #endif |
OLD | NEW |