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

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

Issue 1845283002: Remode dead code from SkReadBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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
« src/core/SkReadBuffer.h ('K') | « src/core/SkReadBuffer.h ('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 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkErrorInternals.h" 9 #include "SkErrorInternals.h"
10 #include "SkImage.h" 10 #include "SkImage.h"
(...skipping 13 matching lines...) Expand all
24 24
25 SkReadBuffer::SkReadBuffer() { 25 SkReadBuffer::SkReadBuffer() {
26 fFlags = default_flags(); 26 fFlags = default_flags();
27 fVersion = 0; 27 fVersion = 0;
28 fMemoryPtr = nullptr; 28 fMemoryPtr = nullptr;
29 29
30 fBitmapStorage = nullptr; 30 fBitmapStorage = nullptr;
31 fTFArray = nullptr; 31 fTFArray = nullptr;
32 fTFCount = 0; 32 fTFCount = 0;
33 33
34 fFactoryTDArray = nullptr;
35 fFactoryArray = nullptr; 34 fFactoryArray = nullptr;
36 fFactoryCount = 0; 35 fFactoryCount = 0;
37 fBitmapDecoder = nullptr; 36 fBitmapDecoder = nullptr;
38 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT 37 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT
39 fDecodedBitmapIndex = -1; 38 fDecodedBitmapIndex = -1;
40 #endif // DEBUG_NON_DETERMINISTIC_ASSERT 39 #endif // DEBUG_NON_DETERMINISTIC_ASSERT
41 } 40 }
42 41
43 SkReadBuffer::SkReadBuffer(const void* data, size_t size) { 42 SkReadBuffer::SkReadBuffer(const void* data, size_t size) {
44 fFlags = default_flags(); 43 fFlags = default_flags();
45 fVersion = 0; 44 fVersion = 0;
46 fReader.setMemory(data, size); 45 fReader.setMemory(data, size);
47 fMemoryPtr = nullptr; 46 fMemoryPtr = nullptr;
48 47
49 fBitmapStorage = nullptr; 48 fBitmapStorage = nullptr;
50 fTFArray = nullptr; 49 fTFArray = nullptr;
51 fTFCount = 0; 50 fTFCount = 0;
52 51
53 fFactoryTDArray = nullptr;
54 fFactoryArray = nullptr; 52 fFactoryArray = nullptr;
55 fFactoryCount = 0; 53 fFactoryCount = 0;
56 fBitmapDecoder = nullptr; 54 fBitmapDecoder = nullptr;
57 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT 55 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT
58 fDecodedBitmapIndex = -1; 56 fDecodedBitmapIndex = -1;
59 #endif // DEBUG_NON_DETERMINISTIC_ASSERT 57 #endif // DEBUG_NON_DETERMINISTIC_ASSERT
60 } 58 }
61 59
62 SkReadBuffer::SkReadBuffer(SkStream* stream) { 60 SkReadBuffer::SkReadBuffer(SkStream* stream) {
63 fFlags = default_flags(); 61 fFlags = default_flags();
64 fVersion = 0; 62 fVersion = 0;
65 const size_t length = stream->getLength(); 63 const size_t length = stream->getLength();
66 fMemoryPtr = sk_malloc_throw(length); 64 fMemoryPtr = sk_malloc_throw(length);
67 stream->read(fMemoryPtr, length); 65 stream->read(fMemoryPtr, length);
68 fReader.setMemory(fMemoryPtr, length); 66 fReader.setMemory(fMemoryPtr, length);
69 67
70 fBitmapStorage = nullptr; 68 fBitmapStorage = nullptr;
71 fTFArray = nullptr; 69 fTFArray = nullptr;
72 fTFCount = 0; 70 fTFCount = 0;
73 71
74 fFactoryTDArray = nullptr;
75 fFactoryArray = nullptr; 72 fFactoryArray = nullptr;
76 fFactoryCount = 0; 73 fFactoryCount = 0;
77 fBitmapDecoder = nullptr; 74 fBitmapDecoder = nullptr;
78 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT 75 #ifdef DEBUG_NON_DETERMINISTIC_ASSERT
79 fDecodedBitmapIndex = -1; 76 fDecodedBitmapIndex = -1;
80 #endif // DEBUG_NON_DETERMINISTIC_ASSERT 77 #endif // DEBUG_NON_DETERMINISTIC_ASSERT
81 } 78 }
82 79
83 SkReadBuffer::~SkReadBuffer() { 80 SkReadBuffer::~SkReadBuffer() {
84 sk_free(fMemoryPtr); 81 sk_free(fMemoryPtr);
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 int32_t index = fReader.readU32(); 340 int32_t index = fReader.readU32();
344 if (0 == index) { 341 if (0 == index) {
345 return nullptr; // writer failed to give us the flattenable 342 return nullptr; // writer failed to give us the flattenable
346 } 343 }
347 index -= 1; // we stored the index-base-1 344 index -= 1; // we stored the index-base-1
348 if ((unsigned)index >= (unsigned)fFactoryCount) { 345 if ((unsigned)index >= (unsigned)fFactoryCount) {
349 this->validate(false); 346 this->validate(false);
350 return nullptr; 347 return nullptr;
351 } 348 }
352 factory = fFactoryArray[index]; 349 factory = fFactoryArray[index];
353 } else if (fFactoryTDArray) {
354 int32_t index = fReader.readU32();
355 if (0 == index) {
356 return nullptr; // writer failed to give us the flattenable
357 }
358 index -= 1; // we stored the index-base-1
359 if ((unsigned)index >= (unsigned)fFactoryCount) {
msarett 2016/03/31 15:05:35 AFAICT, fFactoryCount is always zero when fFactory
360 this->validate(false);
361 return nullptr;
362 }
363 factory = (*fFactoryTDArray)[index];
364 } else { 350 } else {
365 factory = (SkFlattenable::Factory)readFunctionPtr(); 351 factory = (SkFlattenable::Factory)readFunctionPtr();
366 if (nullptr == factory) { 352 if (nullptr == factory) {
367 return nullptr; // writer failed to give us the flattenable 353 return nullptr; // writer failed to give us the flattenable
368 } 354 }
369 } 355 }
370 356
371 // if we get here, factory may still be null, but if that is the case, the 357 // if we get here, factory may still be null, but if that is the case, the
372 // failure was ours, not the writer. 358 // failure was ours, not the writer.
373 SkFlattenable* obj = nullptr; 359 SkFlattenable* obj = nullptr;
(...skipping 16 matching lines...) Expand all
390 376
391 /** 377 /**
392 * Needs to follow the same pattern as readFlattenable(), but explicitly skip w hatever data 378 * Needs to follow the same pattern as readFlattenable(), but explicitly skip w hatever data
393 * has been written. 379 * has been written.
394 */ 380 */
395 void SkReadBuffer::skipFlattenable() { 381 void SkReadBuffer::skipFlattenable() {
396 if (fFactoryCount > 0) { 382 if (fFactoryCount > 0) {
397 if (0 == fReader.readU32()) { 383 if (0 == fReader.readU32()) {
398 return; 384 return;
399 } 385 }
400 } else if (fFactoryTDArray) {
401 if (0 == fReader.readU32()) {
402 return;
403 }
404 } else { 386 } else {
405 if (nullptr == this->readFunctionPtr()) { 387 if (nullptr == this->readFunctionPtr()) {
406 return; 388 return;
407 } 389 }
408 } 390 }
409 uint32_t sizeRecorded = fReader.readU32(); 391 uint32_t sizeRecorded = fReader.readU32();
410 fReader.skip(sizeRecorded); 392 fReader.skip(sizeRecorded);
411 } 393 }
OLDNEW
« src/core/SkReadBuffer.h ('K') | « src/core/SkReadBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698