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

Side by Side Diff: include/core/SkStream.h

Issue 1217573002: remove SkInstCnt (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 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
« no previous file with comments | « include/core/SkShader.h ('k') | include/core/SkSurface.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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 SkStream_DEFINED 8 #ifndef SkStream_DEFINED
9 #define SkStream_DEFINED 9 #define SkStream_DEFINED
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 class SK_API SkStreamMemory : public SkStreamAsset { 174 class SK_API SkStreamMemory : public SkStreamAsset {
175 public: 175 public:
176 SkStreamMemory* duplicate() const override = 0; 176 SkStreamMemory* duplicate() const override = 0;
177 SkStreamMemory* fork() const override = 0; 177 SkStreamMemory* fork() const override = 0;
178 178
179 const void* getMemoryBase() override = 0; 179 const void* getMemoryBase() override = 0;
180 }; 180 };
181 181
182 class SK_API SkWStream : SkNoncopyable { 182 class SK_API SkWStream : SkNoncopyable {
183 public: 183 public:
184 SK_DECLARE_INST_COUNT(SkWStream)
185
186 virtual ~SkWStream(); 184 virtual ~SkWStream();
187 185
188 /** Called to write bytes to a SkWStream. Returns true on success 186 /** Called to write bytes to a SkWStream. Returns true on success
189 @param buffer the address of at least size bytes to be written to the st ream 187 @param buffer the address of at least size bytes to be written to the st ream
190 @param size The number of bytes in buffer to write to the stream 188 @param size The number of bytes in buffer to write to the stream
191 @return true on success 189 @return true on success
192 */ 190 */
193 virtual bool write(const void* buffer, size_t size) = 0; 191 virtual bool write(const void* buffer, size_t size) = 0;
194 virtual void newline(); 192 virtual void newline();
195 virtual void flush(); 193 virtual void flush();
(...skipping 28 matching lines...) Expand all
224 //////////////////////////////////////////////////////////////////////////////// //////// 222 //////////////////////////////////////////////////////////////////////////////// ////////
225 223
226 #include "SkString.h" 224 #include "SkString.h"
227 #include <stdio.h> 225 #include <stdio.h>
228 226
229 struct SkFILE; 227 struct SkFILE;
230 228
231 /** A stream that wraps a C FILE* file stream. */ 229 /** A stream that wraps a C FILE* file stream. */
232 class SK_API SkFILEStream : public SkStreamAsset { 230 class SK_API SkFILEStream : public SkStreamAsset {
233 public: 231 public:
234 SK_DECLARE_INST_COUNT(SkFILEStream)
235
236 /** Initialize the stream by calling sk_fopen on the specified path. 232 /** Initialize the stream by calling sk_fopen on the specified path.
237 * This internal stream will be closed in the destructor. 233 * This internal stream will be closed in the destructor.
238 */ 234 */
239 explicit SkFILEStream(const char path[] = NULL); 235 explicit SkFILEStream(const char path[] = NULL);
240 236
241 enum Ownership { 237 enum Ownership {
242 kCallerPasses_Ownership, 238 kCallerPasses_Ownership,
243 kCallerRetains_Ownership 239 kCallerRetains_Ownership
244 }; 240 };
245 /** Initialize the stream with an existing C file stream. 241 /** Initialize the stream with an existing C file stream.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 SkString fName; 275 SkString fName;
280 Ownership fOwnership; 276 Ownership fOwnership;
281 // fData is lazilly initialized when needed. 277 // fData is lazilly initialized when needed.
282 mutable SkAutoTUnref<SkData> fData; 278 mutable SkAutoTUnref<SkData> fData;
283 279
284 typedef SkStreamAsset INHERITED; 280 typedef SkStreamAsset INHERITED;
285 }; 281 };
286 282
287 class SK_API SkMemoryStream : public SkStreamMemory { 283 class SK_API SkMemoryStream : public SkStreamMemory {
288 public: 284 public:
289 SK_DECLARE_INST_COUNT(SkMemoryStream)
290
291 SkMemoryStream(); 285 SkMemoryStream();
292 286
293 /** We allocate (and free) the memory. Write to it via getMemoryBase() */ 287 /** We allocate (and free) the memory. Write to it via getMemoryBase() */
294 SkMemoryStream(size_t length); 288 SkMemoryStream(size_t length);
295 289
296 /** If copyData is true, the stream makes a private copy of the data. */ 290 /** If copyData is true, the stream makes a private copy of the data. */
297 SkMemoryStream(const void* data, size_t length, bool copyData = false); 291 SkMemoryStream(const void* data, size_t length, bool copyData = false);
298 292
299 /** Use the specified data as the memory for this stream. 293 /** Use the specified data as the memory for this stream.
300 * The stream will call ref() on the data (assuming it is not NULL). 294 * The stream will call ref() on the data (assuming it is not NULL).
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 SkData* fData; 345 SkData* fData;
352 size_t fOffset; 346 size_t fOffset;
353 347
354 typedef SkStreamMemory INHERITED; 348 typedef SkStreamMemory INHERITED;
355 }; 349 };
356 350
357 //////////////////////////////////////////////////////////////////////////////// ///////////// 351 //////////////////////////////////////////////////////////////////////////////// /////////////
358 352
359 class SK_API SkFILEWStream : public SkWStream { 353 class SK_API SkFILEWStream : public SkWStream {
360 public: 354 public:
361 SK_DECLARE_INST_COUNT(SkFILEWStream)
362
363 SkFILEWStream(const char path[]); 355 SkFILEWStream(const char path[]);
364 virtual ~SkFILEWStream(); 356 virtual ~SkFILEWStream();
365 357
366 /** Returns true if the current path could be opened. 358 /** Returns true if the current path could be opened.
367 */ 359 */
368 bool isValid() const { return fFILE != NULL; } 360 bool isValid() const { return fFILE != NULL; }
369 361
370 bool write(const void* buffer, size_t size) override; 362 bool write(const void* buffer, size_t size) override;
371 void flush() override; 363 void flush() override;
372 size_t bytesWritten() const override; 364 size_t bytesWritten() const override;
373 365
374 private: 366 private:
375 SkFILE* fFILE; 367 SkFILE* fFILE;
376 368
377 typedef SkWStream INHERITED; 369 typedef SkWStream INHERITED;
378 }; 370 };
379 371
380 class SkMemoryWStream : public SkWStream { 372 class SkMemoryWStream : public SkWStream {
381 public: 373 public:
382 SK_DECLARE_INST_COUNT(SkMemoryWStream)
383
384 SkMemoryWStream(void* buffer, size_t size); 374 SkMemoryWStream(void* buffer, size_t size);
385 bool write(const void* buffer, size_t size) override; 375 bool write(const void* buffer, size_t size) override;
386 size_t bytesWritten() const override { return fBytesWritten; } 376 size_t bytesWritten() const override { return fBytesWritten; }
387 377
388 private: 378 private:
389 char* fBuffer; 379 char* fBuffer;
390 size_t fMaxLength; 380 size_t fMaxLength;
391 size_t fBytesWritten; 381 size_t fBytesWritten;
392 382
393 typedef SkWStream INHERITED; 383 typedef SkWStream INHERITED;
394 }; 384 };
395 385
396 class SK_API SkDynamicMemoryWStream : public SkWStream { 386 class SK_API SkDynamicMemoryWStream : public SkWStream {
397 public: 387 public:
398 SK_DECLARE_INST_COUNT(SkDynamicMemoryWStream)
399
400 SkDynamicMemoryWStream(); 388 SkDynamicMemoryWStream();
401 virtual ~SkDynamicMemoryWStream(); 389 virtual ~SkDynamicMemoryWStream();
402 390
403 bool write(const void* buffer, size_t size) override; 391 bool write(const void* buffer, size_t size) override;
404 size_t bytesWritten() const override { return fBytesWritten; } 392 size_t bytesWritten() const override { return fBytesWritten; }
405 // random access write 393 // random access write
406 // modifies stream and returns true if offset + size is less than or equal t o getOffset() 394 // modifies stream and returns true if offset + size is less than or equal t o getOffset()
407 bool write(const void* buffer, size_t offset, size_t size); 395 bool write(const void* buffer, size_t offset, size_t size);
408 bool read(void* buffer, size_t offset, size_t size); 396 bool read(void* buffer, size_t offset, size_t size);
409 size_t getOffset() const { return fBytesWritten; } 397 size_t getOffset() const { return fBytesWritten; }
(...skipping 27 matching lines...) Expand all
437 friend class SkBlockMemoryStream; 425 friend class SkBlockMemoryStream;
438 friend class SkBlockMemoryRefCnt; 426 friend class SkBlockMemoryRefCnt;
439 427
440 typedef SkWStream INHERITED; 428 typedef SkWStream INHERITED;
441 }; 429 };
442 430
443 431
444 class SK_API SkDebugWStream : public SkWStream { 432 class SK_API SkDebugWStream : public SkWStream {
445 public: 433 public:
446 SkDebugWStream() : fBytesWritten(0) {} 434 SkDebugWStream() : fBytesWritten(0) {}
447 SK_DECLARE_INST_COUNT(SkDebugWStream)
448 435
449 // overrides 436 // overrides
450 bool write(const void* buffer, size_t size) override; 437 bool write(const void* buffer, size_t size) override;
451 void newline() override; 438 void newline() override;
452 size_t bytesWritten() const override { return fBytesWritten; } 439 size_t bytesWritten() const override { return fBytesWritten; }
453 440
454 private: 441 private:
455 size_t fBytesWritten; 442 size_t fBytesWritten;
456 typedef SkWStream INHERITED; 443 typedef SkWStream INHERITED;
457 }; 444 };
458 445
459 // for now 446 // for now
460 typedef SkFILEStream SkURLStream; 447 typedef SkFILEStream SkURLStream;
461 448
462 #endif 449 #endif
OLDNEW
« no previous file with comments | « include/core/SkShader.h ('k') | include/core/SkSurface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698