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

Side by Side Diff: cc/resources/resource_format.cc

Issue 1379783002: Allow one-copy task tile worker pool to use compressed textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace memory_efficient_format* with preferred_tile_format Created 5 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/resource_format.h" 5 #include "cc/resources/resource_format.h"
6 6
7 #include "third_party/khronos/GLES2/gl2.h" 7 #include "third_party/khronos/GLES2/gl2.h"
8 #include "third_party/khronos/GLES2/gl2ext.h" 8 #include "third_party/khronos/GLES2/gl2ext.h"
9 9
10 namespace cc { 10 namespace cc {
(...skipping 10 matching lines...) Expand all
21 case LUMINANCE_8: 21 case LUMINANCE_8:
22 case RGB_565: 22 case RGB_565:
23 case RED_8: 23 case RED_8:
24 NOTREACHED(); 24 NOTREACHED();
25 break; 25 break;
26 } 26 }
27 NOTREACHED(); 27 NOTREACHED();
28 return kN32_SkColorType; 28 return kN32_SkColorType;
29 } 29 }
30 30
31 ResourceFormat SkColorTypeToResourceFormat(SkColorType color_type) {
32 switch (color_type) {
33 case kARGB_4444_SkColorType:
34 return RGBA_4444;
35 case kAlpha_8_SkColorType:
36 return ALPHA_8;
37 case kRGB_565_SkColorType:
38 return RGB_565;
39 case kRGBA_8888_SkColorType:
40 return RGBA_8888;
41 case kBGRA_8888_SkColorType:
42 return BGRA_8888;
43 case kGray_8_SkColorType:
44 case kIndex_8_SkColorType:
45 case kUnknown_SkColorType:
46 NOTREACHED();
47 break;
48 }
49 NOTREACHED();
50 return RGBA_8888;
51 }
52
31 int BitsPerPixel(ResourceFormat format) { 53 int BitsPerPixel(ResourceFormat format) {
32 switch (format) { 54 switch (format) {
33 case BGRA_8888: 55 case BGRA_8888:
34 case RGBA_8888: 56 case RGBA_8888:
35 return 32; 57 return 32;
36 case RGBA_4444: 58 case RGBA_4444:
37 case RGB_565: 59 case RGB_565:
38 return 16; 60 return 16;
39 case ALPHA_8: 61 case ALPHA_8:
40 case LUMINANCE_8: 62 case LUMINANCE_8:
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 gfx::BufferFormat BufferFormat(ResourceFormat format) { 112 gfx::BufferFormat BufferFormat(ResourceFormat format) {
91 switch (format) { 113 switch (format) {
92 case BGRA_8888: 114 case BGRA_8888:
93 return gfx::BufferFormat::BGRA_8888; 115 return gfx::BufferFormat::BGRA_8888;
94 case RED_8: 116 case RED_8:
95 return gfx::BufferFormat::R_8; 117 return gfx::BufferFormat::R_8;
96 case RGBA_4444: 118 case RGBA_4444:
97 return gfx::BufferFormat::RGBA_4444; 119 return gfx::BufferFormat::RGBA_4444;
98 case RGBA_8888: 120 case RGBA_8888:
99 return gfx::BufferFormat::RGBA_8888; 121 return gfx::BufferFormat::RGBA_8888;
122 case ETC1:
123 return gfx::BufferFormat::ETC1;
100 case ALPHA_8: 124 case ALPHA_8:
101 case LUMINANCE_8: 125 case LUMINANCE_8:
102 case RGB_565: 126 case RGB_565:
103 case ETC1:
104 break; 127 break;
105 } 128 }
106 NOTREACHED(); 129 NOTREACHED();
107 return gfx::BufferFormat::RGBA_8888; 130 return gfx::BufferFormat::RGBA_8888;
108 } 131 }
109 132
133 ResourceFormat BufferFormatToResourceFormat(gfx::BufferFormat format) {
134 switch (format) {
135 case gfx::BufferFormat::RGBA_4444:
136 return RGBA_4444;
137 case gfx::BufferFormat::RGBA_8888:
138 return RGBA_8888;
139 case gfx::BufferFormat::BGRA_8888:
140 return BGRA_8888;
141 case gfx::BufferFormat::ETC1:
142 return ETC1;
143 case gfx::BufferFormat::ATC:
144 case gfx::BufferFormat::ATCIA:
145 case gfx::BufferFormat::DXT1:
146 case gfx::BufferFormat::DXT5:
147 case gfx::BufferFormat::R_8:
148 case gfx::BufferFormat::RGBX_8888:
149 case gfx::BufferFormat::BGRX_8888:
150 case gfx::BufferFormat::YUV_420:
151 case gfx::BufferFormat::YUV_420_BIPLANAR:
152 case gfx::BufferFormat::UYVY_422:
153 break;
154 }
155 NOTREACHED();
156 return RGBA_8888;
157 }
158
159 bool IsResourceFormatCompressed(ResourceFormat format) {
160 return format == ETC1;
161 }
162
163 bool DoesResourceFormatSupportAlpha(ResourceFormat format) {
164 switch (format) {
165 case RGBA_4444:
166 case RGBA_8888:
167 case BGRA_8888:
168 case ALPHA_8:
169 return true;
170 case LUMINANCE_8:
171 case RGB_565:
172 case ETC1:
173 case RED_8:
174 return false;
175 }
176 NOTREACHED();
177 return false;
178 }
179
110 } // namespace cc 180 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698