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

Side by Side Diff: src/core/SkReadBuffer.cpp

Issue 214413008: Thread picture version through to SkReadBuffer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: debugger too Created 6 years, 9 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 | « src/core/SkPicturePlayback.cpp ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkErrorInternals.h" 10 #include "SkErrorInternals.h"
11 #include "SkReadBuffer.h" 11 #include "SkReadBuffer.h"
12 #include "SkStream.h" 12 #include "SkStream.h"
13 #include "SkTypeface.h" 13 #include "SkTypeface.h"
14 14
15 static uint32_t default_flags() { 15 static uint32_t default_flags() {
16 uint32_t flags = 0; 16 uint32_t flags = 0;
17 #ifdef SK_SCALAR_IS_FLOAT 17 #ifdef SK_SCALAR_IS_FLOAT
18 flags |= SkReadBuffer::kScalarIsFloat_Flag; 18 flags |= SkReadBuffer::kScalarIsFloat_Flag;
19 #endif 19 #endif
20 if (8 == sizeof(void*)) { 20 if (8 == sizeof(void*)) {
21 flags |= SkReadBuffer::kPtrIs64Bit_Flag; 21 flags |= SkReadBuffer::kPtrIs64Bit_Flag;
22 } 22 }
23 return flags; 23 return flags;
24 } 24 }
25 25
26 SkReadBuffer::SkReadBuffer() { 26 SkReadBuffer::SkReadBuffer() {
27 fFlags = default_flags(); 27 fFlags = default_flags();
28 fPictureVersion = 0;
28 fMemoryPtr = NULL; 29 fMemoryPtr = NULL;
29 30
30 fBitmapStorage = NULL; 31 fBitmapStorage = NULL;
31 fTFArray = NULL; 32 fTFArray = NULL;
32 fTFCount = 0; 33 fTFCount = 0;
33 34
34 fFactoryTDArray = NULL; 35 fFactoryTDArray = NULL;
35 fFactoryArray = NULL; 36 fFactoryArray = NULL;
36 fFactoryCount = 0; 37 fFactoryCount = 0;
37 fBitmapDecoder = NULL; 38 fBitmapDecoder = NULL;
38 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT 39 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT
39 fDecodedBitmapIndex = -1; 40 fDecodedBitmapIndex = -1;
40 #endif // DEBUG_NON_DETERMINISTIC_ASSERT 41 #endif // DEBUG_NON_DETERMINISTIC_ASSERT
41 } 42 }
42 43
43 SkReadBuffer::SkReadBuffer(const void* data, size_t size) { 44 SkReadBuffer::SkReadBuffer(const void* data, size_t size) {
44 fFlags = default_flags(); 45 fFlags = default_flags();
46 fPictureVersion = 0;
45 fReader.setMemory(data, size); 47 fReader.setMemory(data, size);
46 fMemoryPtr = NULL; 48 fMemoryPtr = NULL;
47 49
48 fBitmapStorage = NULL; 50 fBitmapStorage = NULL;
49 fTFArray = NULL; 51 fTFArray = NULL;
50 fTFCount = 0; 52 fTFCount = 0;
51 53
52 fFactoryTDArray = NULL; 54 fFactoryTDArray = NULL;
53 fFactoryArray = NULL; 55 fFactoryArray = NULL;
54 fFactoryCount = 0; 56 fFactoryCount = 0;
55 fBitmapDecoder = NULL; 57 fBitmapDecoder = NULL;
56 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT 58 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT
57 fDecodedBitmapIndex = -1; 59 fDecodedBitmapIndex = -1;
58 #endif // DEBUG_NON_DETERMINISTIC_ASSERT 60 #endif // DEBUG_NON_DETERMINISTIC_ASSERT
59 } 61 }
60 62
61 SkReadBuffer::SkReadBuffer(SkStream* stream) { 63 SkReadBuffer::SkReadBuffer(SkStream* stream) {
62 fFlags = default_flags(); 64 fFlags = default_flags();
65 fPictureVersion = 0;
63 const size_t length = stream->getLength(); 66 const size_t length = stream->getLength();
64 fMemoryPtr = sk_malloc_throw(length); 67 fMemoryPtr = sk_malloc_throw(length);
65 stream->read(fMemoryPtr, length); 68 stream->read(fMemoryPtr, length);
66 fReader.setMemory(fMemoryPtr, length); 69 fReader.setMemory(fMemoryPtr, length);
67 70
68 fBitmapStorage = NULL; 71 fBitmapStorage = NULL;
69 fTFArray = NULL; 72 fTFArray = NULL;
70 fTFCount = 0; 73 fTFCount = 0;
71 74
72 fFactoryTDArray = NULL; 75 fFactoryTDArray = NULL;
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 if (sizeRecorded != sizeRead) { 328 if (sizeRecorded != sizeRead) {
326 // we could try to fix up the offset... 329 // we could try to fix up the offset...
327 sk_throw(); 330 sk_throw();
328 } 331 }
329 } else { 332 } else {
330 // we must skip the remaining data 333 // we must skip the remaining data
331 fReader.skip(sizeRecorded); 334 fReader.skip(sizeRecorded);
332 } 335 }
333 return obj; 336 return obj;
334 } 337 }
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698