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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) | 317 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
318 static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfi
g; | 318 static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfi
g; |
319 #else | 319 #else |
320 #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." |
321 #endif | 321 #endif |
322 | 322 |
323 // 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 |
324 // representation. | 324 // representation. |
325 static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) { | 325 static inline bool GrPixelConfigIsCompressed(GrPixelConfig config) { |
326 switch (config) { | 326 switch (config) { |
| 327 case kIndex_8_GrPixelConfig: |
327 case kETC1_GrPixelConfig: | 328 case kETC1_GrPixelConfig: |
328 case kLATC_GrPixelConfig: | 329 case kLATC_GrPixelConfig: |
329 case kR11_EAC_GrPixelConfig: | 330 case kR11_EAC_GrPixelConfig: |
330 case kASTC_12x12_GrPixelConfig: | 331 case kASTC_12x12_GrPixelConfig: |
331 return true; | 332 return true; |
332 default: | 333 default: |
333 return false; | 334 return false; |
334 } | 335 } |
335 } | 336 } |
336 | 337 |
(...skipping 15 matching lines...) Expand all Loading... |
352 case kBGRA_8888_GrPixelConfig: | 353 case kBGRA_8888_GrPixelConfig: |
353 return kRGBA_8888_GrPixelConfig; | 354 return kRGBA_8888_GrPixelConfig; |
354 case kRGBA_8888_GrPixelConfig: | 355 case kRGBA_8888_GrPixelConfig: |
355 return kBGRA_8888_GrPixelConfig; | 356 return kBGRA_8888_GrPixelConfig; |
356 default: | 357 default: |
357 return kUnknown_GrPixelConfig; | 358 return kUnknown_GrPixelConfig; |
358 } | 359 } |
359 } | 360 } |
360 | 361 |
361 static inline size_t GrBytesPerPixel(GrPixelConfig config) { | 362 static inline size_t GrBytesPerPixel(GrPixelConfig config) { |
| 363 SkASSERT(!GrPixelConfigIsCompressed(config)); |
362 switch (config) { | 364 switch (config) { |
363 case kAlpha_8_GrPixelConfig: | 365 case kAlpha_8_GrPixelConfig: |
364 case kIndex_8_GrPixelConfig: | |
365 return 1; | 366 return 1; |
366 case kRGB_565_GrPixelConfig: | 367 case kRGB_565_GrPixelConfig: |
367 case kRGBA_4444_GrPixelConfig: | 368 case kRGBA_4444_GrPixelConfig: |
368 return 2; | 369 return 2; |
369 case kRGBA_8888_GrPixelConfig: | 370 case kRGBA_8888_GrPixelConfig: |
370 case kBGRA_8888_GrPixelConfig: | 371 case kBGRA_8888_GrPixelConfig: |
371 return 4; | 372 return 4; |
372 case kRGBA_float_GrPixelConfig: | 373 case kRGBA_float_GrPixelConfig: |
373 return 16; | 374 return 16; |
374 default: | 375 default: |
375 return 0; | 376 return 0; |
376 } | 377 } |
377 } | 378 } |
378 | 379 |
379 static inline size_t GrUnpackAlignment(GrPixelConfig config) { | 380 static inline size_t GrUnpackAlignment(GrPixelConfig config) { |
| 381 SkASSERT(!GrPixelConfigIsCompressed(config)); |
380 switch (config) { | 382 switch (config) { |
381 case kAlpha_8_GrPixelConfig: | 383 case kAlpha_8_GrPixelConfig: |
382 case kIndex_8_GrPixelConfig: | |
383 return 1; | 384 return 1; |
384 case kRGB_565_GrPixelConfig: | 385 case kRGB_565_GrPixelConfig: |
385 case kRGBA_4444_GrPixelConfig: | 386 case kRGBA_4444_GrPixelConfig: |
386 return 2; | 387 return 2; |
387 case kRGBA_8888_GrPixelConfig: | 388 case kRGBA_8888_GrPixelConfig: |
388 case kBGRA_8888_GrPixelConfig: | 389 case kBGRA_8888_GrPixelConfig: |
389 case kRGBA_float_GrPixelConfig: | 390 case kRGBA_float_GrPixelConfig: |
390 return 4; | 391 return 4; |
391 default: | 392 default: |
392 return 0; | 393 return 0; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 * should be verified. | 442 * should be verified. |
442 */ | 443 */ |
443 kCheckAllocation_GrTextureFlagBit = 0x8, | 444 kCheckAllocation_GrTextureFlagBit = 0x8, |
444 | 445 |
445 kDummy_GrTextureFlagBit, | 446 kDummy_GrTextureFlagBit, |
446 kLastPublic_GrTextureFlagBit = kDummy_GrTextureFlagBit-1, | 447 kLastPublic_GrTextureFlagBit = kDummy_GrTextureFlagBit-1, |
447 }; | 448 }; |
448 | 449 |
449 GR_MAKE_BITFIELD_OPS(GrTextureFlags) | 450 GR_MAKE_BITFIELD_OPS(GrTextureFlags) |
450 | 451 |
451 enum { | |
452 /** | |
453 * For Index8 pixel config, the colortable must be 256 entries | |
454 */ | |
455 kGrColorTableSize = 256 * 4 //sizeof(GrColor) | |
456 }; | |
457 | |
458 /** | 452 /** |
459 * Some textures will be stored such that the upper and left edges of the conten
t meet at the | 453 * Some textures will be stored such that the upper and left edges of the conten
t meet at the |
460 * the origin (in texture coord space) and for other textures the lower and left
edges meet at | 454 * the origin (in texture coord space) and for other textures the lower and left
edges meet at |
461 * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render tar
gets | 455 * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render tar
gets |
462 * to BottomLeft. | 456 * to BottomLeft. |
463 */ | 457 */ |
464 | 458 |
465 enum GrSurfaceOrigin { | 459 enum GrSurfaceOrigin { |
466 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed | 460 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed |
467 kTopLeft_GrSurfaceOrigin, | 461 kTopLeft_GrSurfaceOrigin, |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 kPathRendering_GrGLBackendState = 1 << 11, | 671 kPathRendering_GrGLBackendState = 1 << 11, |
678 kALL_GrGLBackendState = 0xffff | 672 kALL_GrGLBackendState = 0xffff |
679 }; | 673 }; |
680 | 674 |
681 /** | 675 /** |
682 * Returns the data size for the given compressed pixel config | 676 * Returns the data size for the given compressed pixel config |
683 */ | 677 */ |
684 static inline size_t GrCompressedFormatDataSize(GrPixelConfig config, | 678 static inline size_t GrCompressedFormatDataSize(GrPixelConfig config, |
685 int width, int height) { | 679 int width, int height) { |
686 SkASSERT(GrPixelConfigIsCompressed(config)); | 680 SkASSERT(GrPixelConfigIsCompressed(config)); |
| 681 static const int kGrIndex8TableSize = 256 * 4; // 4 == sizeof(GrColor) |
687 | 682 |
688 switch (config) { | 683 switch (config) { |
| 684 case kIndex_8_GrPixelConfig: |
| 685 return width * height + kGrIndex8TableSize; |
689 case kR11_EAC_GrPixelConfig: | 686 case kR11_EAC_GrPixelConfig: |
690 case kLATC_GrPixelConfig: | 687 case kLATC_GrPixelConfig: |
691 case kETC1_GrPixelConfig: | 688 case kETC1_GrPixelConfig: |
692 SkASSERT((width & 3) == 0); | 689 SkASSERT((width & 3) == 0); |
693 SkASSERT((height & 3) == 0); | 690 SkASSERT((height & 3) == 0); |
694 return (width >> 2) * (height >> 2) * 8; | 691 return (width >> 2) * (height >> 2) * 8; |
695 | 692 |
696 case kASTC_12x12_GrPixelConfig: | 693 case kASTC_12x12_GrPixelConfig: |
697 SkASSERT((width % 12) == 0); | 694 SkASSERT((width % 12) == 0); |
698 SkASSERT((height % 12) == 0); | 695 SkASSERT((height % 12) == 0); |
699 return (width / 12) * (height / 12) * 16; | 696 return (width / 12) * (height / 12) * 16; |
700 | 697 |
701 default: | 698 default: |
702 SkFAIL("Unknown compressed pixel config"); | 699 SkFAIL("Unknown compressed pixel config"); |
703 return 4 * width * height; | 700 return 4 * width * height; |
704 } | 701 } |
705 } | 702 } |
706 | 703 |
707 /** | 704 /** |
708 * This value translates to reseting all the context state for any backend. | 705 * This value translates to reseting all the context state for any backend. |
709 */ | 706 */ |
710 static const uint32_t kAll_GrBackendState = 0xffffffff; | 707 static const uint32_t kAll_GrBackendState = 0xffffffff; |
711 | 708 |
712 /////////////////////////////////////////////////////////////////////////////// | 709 /////////////////////////////////////////////////////////////////////////////// |
713 | 710 |
714 #endif | 711 #endif |
OLD | NEW |