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

Side by Side Diff: src/codec/SkGifCodec.cpp

Issue 2452673002: Always use a color table with 256 colors (Closed)
Patch Set: rebase Created 4 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
« 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 /* 8 /*
9 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 9 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
10 * 10 *
(...skipping 19 matching lines...) Expand all
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33 #include "SkCodecAnimation.h" 33 #include "SkCodecAnimation.h"
34 #include "SkCodecPriv.h" 34 #include "SkCodecPriv.h"
35 #include "SkColorPriv.h" 35 #include "SkColorPriv.h"
36 #include "SkColorTable.h" 36 #include "SkColorTable.h"
37 #include "SkGifCodec.h" 37 #include "SkGifCodec.h"
38 #include "SkStream.h" 38 #include "SkStream.h"
39 #include "SkSwizzler.h" 39 #include "SkSwizzler.h"
40 #include "SkUtils.h"
40 41
41 #include <algorithm> 42 #include <algorithm>
42 43
43 #define GIF87_STAMP "GIF87a" 44 #define GIF87_STAMP "GIF87a"
44 #define GIF89_STAMP "GIF89a" 45 #define GIF89_STAMP "GIF89a"
45 #define GIF_STAMP_LEN 6 46 #define GIF_STAMP_LEN 6
46 47
47 /* 48 /*
48 * Checks the start of the stream to see if the image is a gif 49 * Checks the start of the stream to see if the image is a gif
49 */ 50 */
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 result[i].fRequiredFrame = frameContext->getRequiredFrame(); 137 result[i].fRequiredFrame = frameContext->getRequiredFrame();
137 } 138 }
138 return result; 139 return result;
139 } 140 }
140 141
141 void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, size_t frameIn dex, 142 void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, size_t frameIn dex,
142 SkPMColor* inputColorPtr, int* inputColorCount) { 143 SkPMColor* inputColorPtr, int* inputColorCount) {
143 fCurrColorTable = fReader->getColorTable(dstInfo.colorType(), frameIndex); 144 fCurrColorTable = fReader->getColorTable(dstInfo.colorType(), frameIndex);
144 fCurrColorTableIsReal = fCurrColorTable; 145 fCurrColorTableIsReal = fCurrColorTable;
145 if (!fCurrColorTable) { 146 if (!fCurrColorTable) {
146 // This is possible for an empty frame. Create a dummy with one value (t ransparent). 147 // This is possible for an empty frame. Create a dummy with all transpar ent.
147 SkPMColor color = SK_ColorTRANSPARENT; 148 SkPMColor colors[MAX_COLORS];
148 fCurrColorTable.reset(new SkColorTable(&color, 1)); 149 sk_memset32(colors, SK_ColorTRANSPARENT, MAX_COLORS);
150 fCurrColorTable.reset(new SkColorTable(colors, 256));
149 } 151 }
150 152
151 if (inputColorCount) { 153 if (inputColorCount) {
152 *inputColorCount = fCurrColorTable->count(); 154 *inputColorCount = fCurrColorTable->count();
153 } 155 }
154 156
155 copy_color_table(dstInfo, fCurrColorTable.get(), inputColorPtr, inputColorCo unt); 157 copy_color_table(dstInfo, fCurrColorTable.get(), inputColorPtr, inputColorCo unt);
156 } 158 }
157 159
158 160
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 void* copiedLine = SkTAddOffset<void>(dstLine, fSwizzler->swizzleOffsetB ytes()); 558 void* copiedLine = SkTAddOffset<void>(dstLine, fSwizzler->swizzleOffsetB ytes());
557 void* dst = copiedLine; 559 void* dst = copiedLine;
558 for (unsigned i = 1; i < repeatCount; i++) { 560 for (unsigned i = 1; i < repeatCount; i++) {
559 dst = SkTAddOffset<void>(dst, fDstRowBytes); 561 dst = SkTAddOffset<void>(dst, fDstRowBytes);
560 memcpy(dst, copiedLine, bytesToCopy); 562 memcpy(dst, copiedLine, bytesToCopy);
561 } 563 }
562 } 564 }
563 565
564 return true; 566 return true;
565 } 567 }
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