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

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

Issue 676883003: flag imageinfo as srgb (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix copy/paste error in loop limits Created 6 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 | « include/core/SkImageInfo.h ('k') | src/ports/SkImageDecoder_CG.cpp » ('j') | 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 2010 Google Inc. 2 * Copyright 2010 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 "SkImageInfo.h" 8 #include "SkImageInfo.h"
9 #include "SkReadBuffer.h" 9 #include "SkReadBuffer.h"
10 #include "SkWriteBuffer.h" 10 #include "SkWriteBuffer.h"
11 11
12 static bool profile_type_is_valid(SkColorProfileType profileType) {
13 return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType);
14 }
15
12 static bool alpha_type_is_valid(SkAlphaType alphaType) { 16 static bool alpha_type_is_valid(SkAlphaType alphaType) {
13 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); 17 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType);
14 } 18 }
15 19
16 static bool color_type_is_valid(SkColorType colorType) { 20 static bool color_type_is_valid(SkColorType colorType) {
17 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); 21 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType);
18 } 22 }
19 23
20 void SkImageInfo::unflatten(SkReadBuffer& buffer) { 24 void SkImageInfo::unflatten(SkReadBuffer& buffer) {
21 fWidth = buffer.read32(); 25 fWidth = buffer.read32();
22 fHeight = buffer.read32(); 26 fHeight = buffer.read32();
23 27
24 uint32_t packed = buffer.read32(); 28 uint32_t packed = buffer.read32();
25 SkASSERT(0 == (packed >> 16)); 29 SkASSERT(0 == (packed >> 24));
30 fProfileType = (SkColorProfileType)((packed >> 16) & 0xFF);
26 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF); 31 fAlphaType = (SkAlphaType)((packed >> 8) & 0xFF);
27 fColorType = (SkColorType)((packed >> 0) & 0xFF); 32 fColorType = (SkColorType)((packed >> 0) & 0xFF);
28 buffer.validate(alpha_type_is_valid(fAlphaType) && 33 buffer.validate(profile_type_is_valid(fProfileType) &&
34 alpha_type_is_valid(fAlphaType) &&
29 color_type_is_valid(fColorType)); 35 color_type_is_valid(fColorType));
30 } 36 }
31 37
32 void SkImageInfo::flatten(SkWriteBuffer& buffer) const { 38 void SkImageInfo::flatten(SkWriteBuffer& buffer) const {
33 buffer.write32(fWidth); 39 buffer.write32(fWidth);
34 buffer.write32(fHeight); 40 buffer.write32(fHeight);
35 41
42 SkASSERT(0 == (fProfileType & ~0xFF));
36 SkASSERT(0 == (fAlphaType & ~0xFF)); 43 SkASSERT(0 == (fAlphaType & ~0xFF));
37 SkASSERT(0 == (fColorType & ~0xFF)); 44 SkASSERT(0 == (fColorType & ~0xFF));
38 uint32_t packed = (fAlphaType << 8) | fColorType; 45 uint32_t packed = (fProfileType << 16) | (fAlphaType << 8) | fColorType;
39 buffer.write32(packed); 46 buffer.write32(packed);
40 } 47 }
41 48
42 bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, 49 bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,
43 SkAlphaType* canonical) { 50 SkAlphaType* canonical) {
44 switch (colorType) { 51 switch (colorType) {
45 case kUnknown_SkColorType: 52 case kUnknown_SkColorType:
46 alphaType = kIgnore_SkAlphaType; 53 alphaType = kIgnore_SkAlphaType;
47 break; 54 break;
48 case kAlpha_8_SkColorType: 55 case kAlpha_8_SkColorType:
(...skipping 13 matching lines...) Expand all
62 alphaType = kOpaque_SkAlphaType; 69 alphaType = kOpaque_SkAlphaType;
63 break; 70 break;
64 default: 71 default:
65 return false; 72 return false;
66 } 73 }
67 if (canonical) { 74 if (canonical) {
68 *canonical = alphaType; 75 *canonical = alphaType;
69 } 76 }
70 return true; 77 return true;
71 } 78 }
OLDNEW
« no previous file with comments | « include/core/SkImageInfo.h ('k') | src/ports/SkImageDecoder_CG.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698