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

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

Issue 806653007: Fix up all the easy virtual ... SK_OVERRIDE cases. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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/SkTypes.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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 //TODO: replace with virtual const SkData* getData() 126 //TODO: replace with virtual const SkData* getData()
127 virtual const void* getMemoryBase() { return NULL; } 127 virtual const void* getMemoryBase() { return NULL; }
128 128
129 private: 129 private:
130 typedef SkRefCnt INHERITED; 130 typedef SkRefCnt INHERITED;
131 }; 131 };
132 132
133 /** SkStreamRewindable is a SkStream for which rewind and duplicate are required . */ 133 /** SkStreamRewindable is a SkStream for which rewind and duplicate are required . */
134 class SK_API SkStreamRewindable : public SkStream { 134 class SK_API SkStreamRewindable : public SkStream {
135 public: 135 public:
136 virtual bool rewind() SK_OVERRIDE = 0; 136 bool rewind() SK_OVERRIDE = 0;
137 virtual SkStreamRewindable* duplicate() const SK_OVERRIDE = 0; 137 SkStreamRewindable* duplicate() const SK_OVERRIDE = 0;
138 }; 138 };
139 139
140 /** SkStreamSeekable is a SkStreamRewindable for which position, seek, move, and fork are required. */ 140 /** SkStreamSeekable is a SkStreamRewindable for which position, seek, move, and fork are required. */
141 class SK_API SkStreamSeekable : public SkStreamRewindable { 141 class SK_API SkStreamSeekable : public SkStreamRewindable {
142 public: 142 public:
143 virtual SkStreamSeekable* duplicate() const SK_OVERRIDE = 0; 143 SkStreamSeekable* duplicate() const SK_OVERRIDE = 0;
144 144
145 virtual bool hasPosition() const SK_OVERRIDE { return true; } 145 bool hasPosition() const SK_OVERRIDE { return true; }
146 virtual size_t getPosition() const SK_OVERRIDE = 0; 146 size_t getPosition() const SK_OVERRIDE = 0;
147 virtual bool seek(size_t position) SK_OVERRIDE = 0; 147 bool seek(size_t position) SK_OVERRIDE = 0;
148 virtual bool move(long offset) SK_OVERRIDE = 0; 148 bool move(long offset) SK_OVERRIDE = 0;
149 virtual SkStreamSeekable* fork() const SK_OVERRIDE = 0; 149 SkStreamSeekable* fork() const SK_OVERRIDE = 0;
150 }; 150 };
151 151
152 /** SkStreamAsset is a SkStreamSeekable for which getLength is required. */ 152 /** SkStreamAsset is a SkStreamSeekable for which getLength is required. */
153 class SK_API SkStreamAsset : public SkStreamSeekable { 153 class SK_API SkStreamAsset : public SkStreamSeekable {
154 public: 154 public:
155 virtual SkStreamAsset* duplicate() const SK_OVERRIDE = 0; 155 SkStreamAsset* duplicate() const SK_OVERRIDE = 0;
156 virtual SkStreamAsset* fork() const SK_OVERRIDE = 0; 156 SkStreamAsset* fork() const SK_OVERRIDE = 0;
157 157
158 virtual bool hasLength() const SK_OVERRIDE { return true; } 158 bool hasLength() const SK_OVERRIDE { return true; }
159 virtual size_t getLength() const SK_OVERRIDE = 0; 159 size_t getLength() const SK_OVERRIDE = 0;
160 }; 160 };
161 161
162 /** SkStreamMemory is a SkStreamAsset for which getMemoryBase is required. */ 162 /** SkStreamMemory is a SkStreamAsset for which getMemoryBase is required. */
163 class SK_API SkStreamMemory : public SkStreamAsset { 163 class SK_API SkStreamMemory : public SkStreamAsset {
164 public: 164 public:
165 virtual SkStreamMemory* duplicate() const SK_OVERRIDE = 0; 165 SkStreamMemory* duplicate() const SK_OVERRIDE = 0;
166 virtual SkStreamMemory* fork() const SK_OVERRIDE = 0; 166 SkStreamMemory* fork() const SK_OVERRIDE = 0;
167 167
168 virtual const void* getMemoryBase() SK_OVERRIDE = 0; 168 const void* getMemoryBase() SK_OVERRIDE = 0;
169 }; 169 };
170 170
171 class SK_API SkWStream : SkNoncopyable { 171 class SK_API SkWStream : SkNoncopyable {
172 public: 172 public:
173 SK_DECLARE_INST_COUNT_ROOT(SkWStream) 173 SK_DECLARE_INST_COUNT_ROOT(SkWStream)
174 174
175 virtual ~SkWStream(); 175 virtual ~SkWStream();
176 176
177 /** Called to write bytes to a SkWStream. Returns true on success 177 /** Called to write bytes to a SkWStream. Returns true on success
178 @param buffer the address of at least size bytes to be written to the st ream 178 @param buffer the address of at least size bytes to be written to the st ream
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 virtual ~SkFILEStream(); 241 virtual ~SkFILEStream();
242 242
243 /** Returns true if the current path could be opened. */ 243 /** Returns true if the current path could be opened. */
244 bool isValid() const { return fFILE != NULL; } 244 bool isValid() const { return fFILE != NULL; }
245 245
246 /** Close the current file, and open a new file with the specified path. 246 /** Close the current file, and open a new file with the specified path.
247 * If path is NULL, just close the current file. 247 * If path is NULL, just close the current file.
248 */ 248 */
249 void setPath(const char path[]); 249 void setPath(const char path[]);
250 250
251 virtual size_t read(void* buffer, size_t size) SK_OVERRIDE; 251 size_t read(void* buffer, size_t size) SK_OVERRIDE;
252 virtual bool isAtEnd() const SK_OVERRIDE; 252 bool isAtEnd() const SK_OVERRIDE;
253 253
254 virtual bool rewind() SK_OVERRIDE; 254 bool rewind() SK_OVERRIDE;
255 virtual SkStreamAsset* duplicate() const SK_OVERRIDE; 255 SkStreamAsset* duplicate() const SK_OVERRIDE;
256 256
257 virtual size_t getPosition() const SK_OVERRIDE; 257 size_t getPosition() const SK_OVERRIDE;
258 virtual bool seek(size_t position) SK_OVERRIDE; 258 bool seek(size_t position) SK_OVERRIDE;
259 virtual bool move(long offset) SK_OVERRIDE; 259 bool move(long offset) SK_OVERRIDE;
260 virtual SkStreamAsset* fork() const SK_OVERRIDE; 260 SkStreamAsset* fork() const SK_OVERRIDE;
261 261
262 virtual size_t getLength() const SK_OVERRIDE; 262 size_t getLength() const SK_OVERRIDE;
263 263
264 virtual const void* getMemoryBase() SK_OVERRIDE; 264 const void* getMemoryBase() SK_OVERRIDE;
265 265
266 private: 266 private:
267 SkFILE* fFILE; 267 SkFILE* fFILE;
268 SkString fName; 268 SkString fName;
269 Ownership fOwnership; 269 Ownership fOwnership;
270 // fData is lazilly initialized when needed. 270 // fData is lazilly initialized when needed.
271 mutable SkAutoTUnref<SkData> fData; 271 mutable SkAutoTUnref<SkData> fData;
272 272
273 typedef SkStreamAsset INHERITED; 273 typedef SkStreamAsset INHERITED;
274 }; 274 };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 * Use the specified data as the memory for this stream. 313 * Use the specified data as the memory for this stream.
314 * The stream will call ref() on the data (assuming it is not NULL). 314 * The stream will call ref() on the data (assuming it is not NULL).
315 * The function returns the data parameter as a convenience. 315 * The function returns the data parameter as a convenience.
316 */ 316 */
317 SkData* setData(SkData*); 317 SkData* setData(SkData*);
318 318
319 void skipToAlign4(); 319 void skipToAlign4();
320 const void* getAtPos(); 320 const void* getAtPos();
321 size_t peek() const { return fOffset; } 321 size_t peek() const { return fOffset; }
322 322
323 virtual size_t read(void* buffer, size_t size) SK_OVERRIDE; 323 size_t read(void* buffer, size_t size) SK_OVERRIDE;
324 virtual bool isAtEnd() const SK_OVERRIDE; 324 bool isAtEnd() const SK_OVERRIDE;
325 325
326 virtual bool rewind() SK_OVERRIDE; 326 bool rewind() SK_OVERRIDE;
327 virtual SkMemoryStream* duplicate() const SK_OVERRIDE; 327 SkMemoryStream* duplicate() const SK_OVERRIDE;
328 328
329 virtual size_t getPosition() const SK_OVERRIDE; 329 size_t getPosition() const SK_OVERRIDE;
330 virtual bool seek(size_t position) SK_OVERRIDE; 330 bool seek(size_t position) SK_OVERRIDE;
331 virtual bool move(long offset) SK_OVERRIDE; 331 bool move(long offset) SK_OVERRIDE;
332 virtual SkMemoryStream* fork() const SK_OVERRIDE; 332 SkMemoryStream* fork() const SK_OVERRIDE;
333 333
334 virtual size_t getLength() const SK_OVERRIDE; 334 size_t getLength() const SK_OVERRIDE;
335 335
336 virtual const void* getMemoryBase() SK_OVERRIDE; 336 const void* getMemoryBase() SK_OVERRIDE;
337 337
338 private: 338 private:
339 SkData* fData; 339 SkData* fData;
340 size_t fOffset; 340 size_t fOffset;
341 341
342 typedef SkStreamMemory INHERITED; 342 typedef SkStreamMemory INHERITED;
343 }; 343 };
344 344
345 //////////////////////////////////////////////////////////////////////////////// ///////////// 345 //////////////////////////////////////////////////////////////////////////////// /////////////
346 346
347 class SK_API SkFILEWStream : public SkWStream { 347 class SK_API SkFILEWStream : public SkWStream {
348 public: 348 public:
349 SK_DECLARE_INST_COUNT(SkFILEWStream) 349 SK_DECLARE_INST_COUNT(SkFILEWStream)
350 350
351 SkFILEWStream(const char path[]); 351 SkFILEWStream(const char path[]);
352 virtual ~SkFILEWStream(); 352 virtual ~SkFILEWStream();
353 353
354 /** Returns true if the current path could be opened. 354 /** Returns true if the current path could be opened.
355 */ 355 */
356 bool isValid() const { return fFILE != NULL; } 356 bool isValid() const { return fFILE != NULL; }
357 357
358 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 358 bool write(const void* buffer, size_t size) SK_OVERRIDE;
359 virtual void flush() SK_OVERRIDE; 359 void flush() SK_OVERRIDE;
360 virtual size_t bytesWritten() const SK_OVERRIDE; 360 size_t bytesWritten() const SK_OVERRIDE;
361 361
362 private: 362 private:
363 SkFILE* fFILE; 363 SkFILE* fFILE;
364 364
365 typedef SkWStream INHERITED; 365 typedef SkWStream INHERITED;
366 }; 366 };
367 367
368 class SkMemoryWStream : public SkWStream { 368 class SkMemoryWStream : public SkWStream {
369 public: 369 public:
370 SK_DECLARE_INST_COUNT(SkMemoryWStream) 370 SK_DECLARE_INST_COUNT(SkMemoryWStream)
371 371
372 SkMemoryWStream(void* buffer, size_t size); 372 SkMemoryWStream(void* buffer, size_t size);
373 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 373 bool write(const void* buffer, size_t size) SK_OVERRIDE;
374 virtual size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; } 374 size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; }
375 375
376 private: 376 private:
377 char* fBuffer; 377 char* fBuffer;
378 size_t fMaxLength; 378 size_t fMaxLength;
379 size_t fBytesWritten; 379 size_t fBytesWritten;
380 380
381 typedef SkWStream INHERITED; 381 typedef SkWStream INHERITED;
382 }; 382 };
383 383
384 class SK_API SkDynamicMemoryWStream : public SkWStream { 384 class SK_API SkDynamicMemoryWStream : public SkWStream {
385 public: 385 public:
386 SK_DECLARE_INST_COUNT(SkDynamicMemoryWStream) 386 SK_DECLARE_INST_COUNT(SkDynamicMemoryWStream)
387 387
388 SkDynamicMemoryWStream(); 388 SkDynamicMemoryWStream();
389 virtual ~SkDynamicMemoryWStream(); 389 virtual ~SkDynamicMemoryWStream();
390 390
391 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 391 bool write(const void* buffer, size_t size) SK_OVERRIDE;
392 virtual size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; } 392 size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; }
393 // random access write 393 // random access write
394 // 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()
395 bool write(const void* buffer, size_t offset, size_t size); 395 bool write(const void* buffer, size_t offset, size_t size);
396 bool read(void* buffer, size_t offset, size_t size); 396 bool read(void* buffer, size_t offset, size_t size);
397 size_t getOffset() const { return fBytesWritten; } 397 size_t getOffset() const { return fBytesWritten; }
398 398
399 // copy what has been written to the stream into dst 399 // copy what has been written to the stream into dst
400 void copyTo(void* dst) const; 400 void copyTo(void* dst) const;
401 401
402 /** 402 /**
(...skipping 24 matching lines...) Expand all
427 typedef SkWStream INHERITED; 427 typedef SkWStream INHERITED;
428 }; 428 };
429 429
430 430
431 class SK_API SkDebugWStream : public SkWStream { 431 class SK_API SkDebugWStream : public SkWStream {
432 public: 432 public:
433 SkDebugWStream() : fBytesWritten(0) {} 433 SkDebugWStream() : fBytesWritten(0) {}
434 SK_DECLARE_INST_COUNT(SkDebugWStream) 434 SK_DECLARE_INST_COUNT(SkDebugWStream)
435 435
436 // overrides 436 // overrides
437 virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 437 bool write(const void* buffer, size_t size) SK_OVERRIDE;
438 virtual void newline() SK_OVERRIDE; 438 void newline() SK_OVERRIDE;
439 virtual size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; } 439 size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; }
440 440
441 private: 441 private:
442 size_t fBytesWritten; 442 size_t fBytesWritten;
443 typedef SkWStream INHERITED; 443 typedef SkWStream INHERITED;
444 }; 444 };
445 445
446 // for now 446 // for now
447 typedef SkFILEStream SkURLStream; 447 typedef SkFILEStream SkURLStream;
448 448
449 #endif 449 #endif
OLDNEW
« no previous file with comments | « include/core/SkShader.h ('k') | include/core/SkTypes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698