OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
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 | 10 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 kETC1_GrPixelConfig, | 280 kETC1_GrPixelConfig, |
281 /** | 281 /** |
282 * LATC/RGTC/3Dc/BC4 Compressed Data | 282 * LATC/RGTC/3Dc/BC4 Compressed Data |
283 */ | 283 */ |
284 kLATC_GrPixelConfig, | 284 kLATC_GrPixelConfig, |
285 /** | 285 /** |
286 * R11 EAC Compressed Data | 286 * R11 EAC Compressed Data |
287 * (Corresponds to section C.3.5 of the OpenGL 4.4 core profile spec) | 287 * (Corresponds to section C.3.5 of the OpenGL 4.4 core profile spec) |
288 */ | 288 */ |
289 kR11_EAC_GrPixelConfig, | 289 kR11_EAC_GrPixelConfig, |
| 290 |
| 291 /** |
| 292 * 12x12 ASTC Compressed Data |
| 293 * ASTC stands for Adaptive Scalable Texture Compression. It is a technique |
| 294 * that allows for a lot of customization in the compressed representataion |
| 295 * of a block. The only thing fixed in the representation is the block size, |
| 296 * which means that a texture that contains ASTC data must be treated as |
| 297 * having RGBA values. However, there are single-channel encodings which set |
| 298 * the alpha to opaque and all three RGB channels equal effectively making t
he |
| 299 * compression format a single channel such as R11 EAC and LATC. |
| 300 */ |
| 301 kASTC_12x12_GrPixelConfig, |
| 302 |
290 /** | 303 /** |
291 * Byte order is r, g, b, a. This color format is 32 bits per channel | 304 * Byte order is r, g, b, a. This color format is 32 bits per channel |
292 */ | 305 */ |
293 kRGBA_float_GrPixelConfig, | 306 kRGBA_float_GrPixelConfig, |
294 kLast_GrPixelConfig = kRGBA_float_GrPixelConfig | 307 kLast_GrPixelConfig = kRGBA_float_GrPixelConfig |
295 }; | 308 }; |
296 static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1; | 309 static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1; |
297 | 310 |
298 // Aliases for pixel configs that match skia's byte order. | 311 // Aliases for pixel configs that match skia's byte order. |
299 #ifndef SK_CPU_LENDIAN | 312 #ifndef SK_CPU_LENDIAN |
300 #error "Skia gpu currently assumes little endian" | 313 #error "Skia gpu currently assumes little endian" |
301 #endif | 314 #endif |
302 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) | 315 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) |
303 static const GrPixelConfig kSkia8888_GrPixelConfig = kBGRA_8888_GrPixelConfi
g; | 316 static const GrPixelConfig kSkia8888_GrPixelConfig = kBGRA_8888_GrPixelConfi
g; |
304 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) | 317 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
305 static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfi
g; | 318 static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfi
g; |
306 #else | 319 #else |
307 #error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format." | 320 #error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format." |
308 #endif | 321 #endif |
309 | 322 |
310 // Returns true if the pixel config is a GPU-specific compressed format | 323 // Returns true if the pixel config is a GPU-specific compressed format |
311 // representation. | 324 // representation. |
312 static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) { | 325 static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) { |
313 switch (config) { | 326 switch (config) { |
314 case kETC1_GrPixelConfig: | 327 case kETC1_GrPixelConfig: |
315 case kLATC_GrPixelConfig: | 328 case kLATC_GrPixelConfig: |
316 case kR11_EAC_GrPixelConfig: | 329 case kR11_EAC_GrPixelConfig: |
| 330 case kASTC_12x12_GrPixelConfig: |
317 return true; | 331 return true; |
318 default: | 332 default: |
319 return false; | 333 return false; |
320 } | 334 } |
321 } | 335 } |
322 | 336 |
323 // Returns true if the pixel config is 32 bits per pixel | 337 // Returns true if the pixel config is 32 bits per pixel |
324 static inline bool GrPixelConfigIs8888(GrPixelConfig config) { | 338 static inline bool GrPixelConfigIs8888(GrPixelConfig config) { |
325 switch (config) { | 339 switch (config) { |
326 case kRGBA_8888_GrPixelConfig: | 340 case kRGBA_8888_GrPixelConfig: |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 SkASSERT(GrPixelConfigIsCompressed(config)); | 685 SkASSERT(GrPixelConfigIsCompressed(config)); |
672 | 686 |
673 switch (config) { | 687 switch (config) { |
674 case kR11_EAC_GrPixelConfig: | 688 case kR11_EAC_GrPixelConfig: |
675 case kLATC_GrPixelConfig: | 689 case kLATC_GrPixelConfig: |
676 case kETC1_GrPixelConfig: | 690 case kETC1_GrPixelConfig: |
677 SkASSERT((width & 3) == 0); | 691 SkASSERT((width & 3) == 0); |
678 SkASSERT((height & 3) == 0); | 692 SkASSERT((height & 3) == 0); |
679 return (width >> 2) * (height >> 2) * 8; | 693 return (width >> 2) * (height >> 2) * 8; |
680 | 694 |
| 695 case kASTC_12x12_GrPixelConfig: |
| 696 SkASSERT((width % 12) == 0); |
| 697 SkASSERT((height % 12) == 0); |
| 698 return (width / 12) * (height / 12) * 16; |
| 699 |
681 default: | 700 default: |
682 SkFAIL("Unknown compressed pixel config"); | 701 SkFAIL("Unknown compressed pixel config"); |
683 return 4 * width * height; | 702 return 4 * width * height; |
684 } | 703 } |
685 } | 704 } |
686 | 705 |
687 /** | 706 /** |
688 * This value translates to reseting all the context state for any backend. | 707 * This value translates to reseting all the context state for any backend. |
689 */ | 708 */ |
690 static const uint32_t kAll_GrBackendState = 0xffffffff; | 709 static const uint32_t kAll_GrBackendState = 0xffffffff; |
691 | 710 |
692 /////////////////////////////////////////////////////////////////////////////// | 711 /////////////////////////////////////////////////////////////////////////////// |
693 | 712 |
694 #endif | 713 #endif |
OLD | NEW |