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

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

Issue 617443002: Temp fix for crash when generating 16-bit cache for colorTables. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment Created 6 years, 2 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 | « no previous file | 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 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "SkColorPriv.h" 66 #include "SkColorPriv.h"
67 67
68 static inline void build_16bitcache(uint16_t dst[], const SkPMColor src[], 68 static inline void build_16bitcache(uint16_t dst[], const SkPMColor src[],
69 int count) { 69 int count) {
70 while (--count >= 0) { 70 while (--count >= 0) {
71 *dst++ = SkPixel32ToPixel16_ToU16(*src++); 71 *dst++ = SkPixel32ToPixel16_ToU16(*src++);
72 } 72 }
73 } 73 }
74 74
75 const uint16_t* SkColorTable::lock16BitCache() { 75 const uint16_t* SkColorTable::lock16BitCache() {
76 if (this->isOpaque() && NULL == f16BitCache) { 76 // Assert that we're opaque, since our 16-bit cache will be sort of useless
77 // if there is alpha (which we're throwing away)
78 SkASSERT(this->isOpaque());
79 if (NULL == f16BitCache) {
77 f16BitCache = (uint16_t*)sk_malloc_throw(fCount * sizeof(uint16_t)); 80 f16BitCache = (uint16_t*)sk_malloc_throw(fCount * sizeof(uint16_t));
78 build_16bitcache(f16BitCache, fColors, fCount); 81 build_16bitcache(f16BitCache, fColors, fCount);
79 } 82 }
80 83
81 SkDEBUGCODE(f16BitCacheLockCount += 1); 84 SkDEBUGCODE(f16BitCacheLockCount += 1);
82 return f16BitCache; 85 return f16BitCache;
83 } 86 }
84 87
85 /////////////////////////////////////////////////////////////////////////////// 88 ///////////////////////////////////////////////////////////////////////////////
86 89
(...skipping 16 matching lines...) Expand all
103 #ifdef SK_DEBUG 106 #ifdef SK_DEBUG
104 SkASSERT((unsigned)fCount <= 256); 107 SkASSERT((unsigned)fCount <= 256);
105 SkASSERT(success); 108 SkASSERT(success);
106 #endif 109 #endif
107 } 110 }
108 111
109 void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const { 112 void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const {
110 buffer.writeUInt(fAlphaType); 113 buffer.writeUInt(fAlphaType);
111 buffer.writeColorArray(fColors, fCount); 114 buffer.writeColorArray(fColors, fCount);
112 } 115 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698