OLD | NEW |
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 #ifndef SkData_DEFINED | 8 #ifndef SkData_DEFINED |
9 #define SkData_DEFINED | 9 #define SkData_DEFINED |
10 | 10 |
| 11 #include <stdio.h> |
| 12 |
11 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
12 | 14 |
13 struct SkFILE; | |
14 class SkStream; | 15 class SkStream; |
15 | 16 |
16 /** | 17 /** |
17 * SkData holds an immutable data buffer. Not only is the data immutable, | 18 * 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 | 19 * 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. | 20 * to always be the same for the life of this instance. |
20 */ | 21 */ |
21 class SK_API SkData : public SkRefCnt { | 22 class SK_API SkData : public SkRefCnt { |
22 public: | 23 public: |
23 /** | 24 /** |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 */ | 113 */ |
113 static SkData* NewFromMalloc(const void* data, size_t length); | 114 static SkData* NewFromMalloc(const void* data, size_t length); |
114 | 115 |
115 /** | 116 /** |
116 * Create a new dataref the file with the specified path. | 117 * Create a new dataref the file with the specified path. |
117 * If the file cannot be opened, this returns NULL. | 118 * If the file cannot be opened, this returns NULL. |
118 */ | 119 */ |
119 static SkData* NewFromFileName(const char path[]); | 120 static SkData* NewFromFileName(const char path[]); |
120 | 121 |
121 /** | 122 /** |
122 * Create a new dataref from a SkFILE. | 123 * Create a new dataref from a stdio FILE. |
123 * This does not take ownership of the SkFILE, nor close it. | 124 * This does not take ownership of the FILE, nor close it. |
124 * The caller is free to close the SkFILE at its convenience. | 125 * The caller is free to close the FILE at its convenience. |
125 * The SkFILE must be open for reading only. | 126 * The FILE must be open for reading only. |
126 * Returns NULL on failure. | 127 * Returns NULL on failure. |
127 */ | 128 */ |
128 static SkData* NewFromFILE(SkFILE* f); | 129 static SkData* NewFromFILE(FILE* f); |
129 | 130 |
130 /** | 131 /** |
131 * Create a new dataref from a file descriptor. | 132 * Create a new dataref from a file descriptor. |
132 * This does not take ownership of the file descriptor, nor close it. | 133 * This does not take ownership of the file descriptor, nor close it. |
133 * The caller is free to close the file descriptor at its convenience. | 134 * The caller is free to close the file descriptor at its convenience. |
134 * The file descriptor must be open for reading only. | 135 * The file descriptor must be open for reading only. |
135 * Returns NULL on failure. | 136 * Returns NULL on failure. |
136 */ | 137 */ |
137 static SkData* NewFromFD(int fd); | 138 static SkData* NewFromFD(int fd); |
138 | 139 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 183 |
183 static void DummyReleaseProc(const void*, void*) {} | 184 static void DummyReleaseProc(const void*, void*) {} |
184 | 185 |
185 typedef SkRefCnt INHERITED; | 186 typedef SkRefCnt INHERITED; |
186 }; | 187 }; |
187 | 188 |
188 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ | 189 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ |
189 typedef SkAutoTUnref<SkData> SkAutoDataUnref; | 190 typedef SkAutoTUnref<SkData> SkAutoDataUnref; |
190 | 191 |
191 #endif | 192 #endif |
OLD | NEW |