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

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

Issue 1889793007: move static arrays into impl, to avoid multiple copies (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: re-expose globals (since gcc didn't like my hiding trick) Created 4 years, 8 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 | « include/core/SkImageInfo.h ('k') | 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 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 const uint8_t gPrivate_SkColorTypeBytesPerPixel[] = {
13 0, // Unknown
14 1, // Alpha_8
15 2, // RGB_565
16 2, // ARGB_4444
17 4, // RGBA_8888
18 4, // BGRA_8888
19 1, // kIndex_8
20 1, // kGray_8
21 8, // kRGBA_F16
22 };
23 static_assert(SK_ARRAY_COUNT(gPrivate_SkColorTypeBytesPerPixel) == (size_t)(kLas tEnum_SkColorType + 1),
24 "size_mismatch_with_SkColorType_enum");
25
26 const uint8_t gPrivate_SkColorTypeShiftPerPixel[] = {
27 0, // Unknown
28 0, // Alpha_8
29 1, // RGB_565
30 1, // ARGB_4444
31 2, // RGBA_8888
32 2, // BGRA_8888
33 0, // kIndex_8
34 0, // kGray_8
35 3, // kRGBA_F16
36 };
37 static_assert(SK_ARRAY_COUNT(gPrivate_SkColorTypeShiftPerPixel) == (size_t)(kLas tEnum_SkColorType + 1),
38 "size_mismatch_with_SkColorType_enum");
39
12 static bool profile_type_is_valid(SkColorProfileType profileType) { 40 static bool profile_type_is_valid(SkColorProfileType profileType) {
13 return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType); 41 return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType);
14 } 42 }
15 43
16 static bool alpha_type_is_valid(SkAlphaType alphaType) { 44 static bool alpha_type_is_valid(SkAlphaType alphaType) {
17 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType); 45 return (alphaType >= 0) && (alphaType <= kLastEnum_SkAlphaType);
18 } 46 }
19 47
20 static bool color_type_is_valid(SkColorType colorType) { 48 static bool color_type_is_valid(SkColorType colorType) {
21 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType); 49 return (colorType >= 0) && (colorType <= kLastEnum_SkColorType);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 142 }
115 // here x,y are either 0 or negative 143 // here x,y are either 0 or negative
116 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel()); 144 fPixels = ((char*)fPixels - y * fRowBytes - x * fInfo.bytesPerPixel());
117 // the intersect may have shrunk info's logical size 145 // the intersect may have shrunk info's logical size
118 fInfo = fInfo.makeWH(srcR.width(), srcR.height()); 146 fInfo = fInfo.makeWH(srcR.width(), srcR.height());
119 fX = srcR.x(); 147 fX = srcR.x();
120 fY = srcR.y(); 148 fY = srcR.y();
121 149
122 return true; 150 return true;
123 } 151 }
OLDNEW
« no previous file with comments | « include/core/SkImageInfo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698