Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 SkASSERT(this->isOpaque()); |
|
reed1
2014/09/29 14:16:00
// Assert that we're opaque, since our 16bit will
| |
| 77 if (NULL == f16BitCache) { | |
| 77 f16BitCache = (uint16_t*)sk_malloc_throw(fCount * sizeof(uint16_t)); | 78 f16BitCache = (uint16_t*)sk_malloc_throw(fCount * sizeof(uint16_t)); |
| 78 build_16bitcache(f16BitCache, fColors, fCount); | 79 build_16bitcache(f16BitCache, fColors, fCount); |
| 79 } | 80 } |
| 80 | 81 |
| 81 SkDEBUGCODE(f16BitCacheLockCount += 1); | 82 SkDEBUGCODE(f16BitCacheLockCount += 1); |
| 82 return f16BitCache; | 83 return f16BitCache; |
| 83 } | 84 } |
| 84 | 85 |
| 85 /////////////////////////////////////////////////////////////////////////////// | 86 /////////////////////////////////////////////////////////////////////////////// |
| 86 | 87 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 103 #ifdef SK_DEBUG | 104 #ifdef SK_DEBUG |
| 104 SkASSERT((unsigned)fCount <= 256); | 105 SkASSERT((unsigned)fCount <= 256); |
| 105 SkASSERT(success); | 106 SkASSERT(success); |
| 106 #endif | 107 #endif |
| 107 } | 108 } |
| 108 | 109 |
| 109 void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const { | 110 void SkColorTable::writeToBuffer(SkWriteBuffer& buffer) const { |
| 110 buffer.writeUInt(fAlphaType); | 111 buffer.writeUInt(fAlphaType); |
| 111 buffer.writeColorArray(fColors, fCount); | 112 buffer.writeColorArray(fColors, fCount); |
| 112 } | 113 } |
| OLD | NEW |