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

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

Issue 37803002: Adding size parameter to read array functions (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Added dox in SkFlattenableBuffers.h Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2009 The Android Open Source Project 3 * Copyright 2009 The Android Open Source Project
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 #include "SkColorTable.h" 10 #include "SkColorTable.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 /////////////////////////////////////////////////////////////////////////////// 86 ///////////////////////////////////////////////////////////////////////////////
87 87
88 SkColorTable::SkColorTable(SkFlattenableReadBuffer& buffer) { 88 SkColorTable::SkColorTable(SkFlattenableReadBuffer& buffer) {
89 f16BitCache = NULL; 89 f16BitCache = NULL;
90 SkDEBUGCODE(fColorLockCount = 0;) 90 SkDEBUGCODE(fColorLockCount = 0;)
91 SkDEBUGCODE(f16BitCacheLockCount = 0;) 91 SkDEBUGCODE(f16BitCacheLockCount = 0;)
92 92
93 fAlphaType = SkToU8(buffer.readUInt()); 93 fAlphaType = SkToU8(buffer.readUInt());
94 fCount = buffer.getArrayCount(); 94 fCount = buffer.getArrayCount();
95 fColors = (SkPMColor*)sk_malloc_throw(fCount * sizeof(SkPMColor)); 95 uint32_t size = fCount * sizeof(SkPMColor);
96 SkDEBUGCODE(const uint32_t countRead =) buffer.readColorArray(fColors); 96 fColors = (SkPMColor*)sk_malloc_throw(size);
97 SkDEBUGCODE(const uint32_t countRead =) buffer.readColorArray(fColors, size) ;
97 #ifdef SK_DEBUG 98 #ifdef SK_DEBUG
98 SkASSERT((unsigned)fCount <= 256); 99 SkASSERT((unsigned)fCount <= 256);
99 SkASSERT(countRead == fCount); 100 SkASSERT(countRead == fCount);
100 #endif 101 #endif
101 } 102 }
102 103
103 void SkColorTable::writeToBuffer(SkFlattenableWriteBuffer& buffer) const { 104 void SkColorTable::writeToBuffer(SkFlattenableWriteBuffer& buffer) const {
104 buffer.writeUInt(fAlphaType); 105 buffer.writeUInt(fAlphaType);
105 buffer.writeColorArray(fColors, fCount); 106 buffer.writeColorArray(fColors, fCount);
106 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698