Chromium Code Reviews| 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 "SkRefCnt.h" | 14 #include "SkRefCnt.h" |
| 15 | 15 |
| 16 struct SkFILE; | 16 struct SkFILE; |
| 17 class SkStreamRewindable; | |
| 17 | 18 |
| 18 /** | 19 /** |
| 19 * SkData holds an immutable data buffer. Not only is the data immutable, | 20 * SkData holds an immutable data buffer. Not only is the data immutable, |
| 20 * but the actual ptr that is returned (by data() or bytes()) is guaranteed | 21 * but the actual ptr that is returned (by data() or bytes()) is guaranteed |
| 21 * to always be the same for the life of this instance. | 22 * to always be the same for the life of this instance. |
| 22 */ | 23 */ |
| 23 class SK_API SkData : public SkRefCnt { | 24 class SK_API SkData : public SkRefCnt { |
| 24 public: | 25 public: |
| 25 SK_DECLARE_INST_COUNT(SkData) | 26 SK_DECLARE_INST_COUNT(SkData) |
| 26 | 27 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 * of scope, allowing for custom allocation/freeing of the data. | 64 * of scope, allowing for custom allocation/freeing of the data. |
| 64 */ | 65 */ |
| 65 typedef void (*ReleaseProc)(const void* ptr, size_t length, void* context); | 66 typedef void (*ReleaseProc)(const void* ptr, size_t length, void* context); |
| 66 | 67 |
| 67 /** | 68 /** |
| 68 * Create a new dataref by copying the specified data | 69 * Create a new dataref by copying the specified data |
| 69 */ | 70 */ |
| 70 static SkData* NewWithCopy(const void* data, size_t length); | 71 static SkData* NewWithCopy(const void* data, size_t length); |
| 71 | 72 |
| 72 /** | 73 /** |
| 74 * Create a new dataref by copying the data out of the stream. | |
| 75 * The stream's position will be changed after this call. Only | |
| 76 * succeeds if stream->hasLength(), getLength() is non-zero, and | |
| 77 * sk_malloc) succeeds. Returns NULL on failure. | |
| 78 * | |
| 79 * You probably want to try stream->getData() first. | |
|
scroggo
2013/12/05 21:07:18
Can you specify why getData is better?
hal.canary
2013/12/05 22:29:29
Done.
| |
| 80 */ | |
| 81 static SkData* NewWithCopyFromStream(SkStreamRewindable* stream); | |
| 82 | |
| 83 /** | |
| 73 * Create a new dataref by copying the specified c-string | 84 * Create a new dataref by copying the specified c-string |
| 74 * (a null-terminated array of bytes). The returned SkData will have size() | 85 * (a null-terminated array of bytes). The returned SkData will have size() |
| 75 * equal to strlen(cstr) + 1. If cstr is NULL, it will be treated the same | 86 * equal to strlen(cstr) + 1. If cstr is NULL, it will be treated the same |
| 76 * as "". | 87 * as "". |
| 77 */ | 88 */ |
| 78 static SkData* NewWithCString(const char cstr[]); | 89 static SkData* NewWithCString(const char cstr[]); |
| 79 | 90 |
| 80 /** | 91 /** |
| 81 * Create a new dataref, taking the data ptr as is, and using the | 92 * Create a new dataref, taking the data ptr as is, and using the |
| 82 * releaseproc to free it. The proc may be NULL. | 93 * releaseproc to free it. The proc may be NULL. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 // Called the first time someone calls NewEmpty to initialize the singleton. | 150 // Called the first time someone calls NewEmpty to initialize the singleton. |
| 140 static void NewEmptyImpl(SkData**); | 151 static void NewEmptyImpl(SkData**); |
| 141 | 152 |
| 142 typedef SkRefCnt INHERITED; | 153 typedef SkRefCnt INHERITED; |
| 143 }; | 154 }; |
| 144 | 155 |
| 145 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ | 156 /** Typedef of SkAutoTUnref<SkData> for automatically unref-ing a SkData. */ |
| 146 typedef SkAutoTUnref<SkData> SkAutoDataUnref; | 157 typedef SkAutoTUnref<SkData> SkAutoDataUnref; |
| 147 | 158 |
| 148 #endif | 159 #endif |
| OLD | NEW |