OLD | NEW |
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 #ifndef GrTypes_DEFINED | 8 #ifndef GrTypes_DEFINED |
9 #define GrTypes_DEFINED | 9 #define GrTypes_DEFINED |
10 | 10 |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 kTopLeft_GrSurfaceOrigin, | 437 kTopLeft_GrSurfaceOrigin, |
438 kBottomLeft_GrSurfaceOrigin, | 438 kBottomLeft_GrSurfaceOrigin, |
439 }; | 439 }; |
440 | 440 |
441 struct GrMipLevel { | 441 struct GrMipLevel { |
442 const void* fPixels; | 442 const void* fPixels; |
443 size_t fRowBytes; | 443 size_t fRowBytes; |
444 }; | 444 }; |
445 | 445 |
446 /** | 446 /** |
447 * An container of function pointers which consumers of Skia can fill in and | |
448 * pass to Skia. Skia will use these function pointers in place of its backend | |
449 * API texture creation function. Either all of the function pointers should be | |
450 * filled in, or they should all be nullptr. | |
451 */ | |
452 struct GrTextureStorageAllocator { | |
453 GrTextureStorageAllocator() | |
454 : fAllocateTextureStorage(nullptr) | |
455 , fDeallocateTextureStorage(nullptr) { | |
456 } | |
457 | |
458 enum class Result { | |
459 kSucceededAndUploaded, | |
460 kSucceededWithoutUpload, | |
461 kFailed | |
462 }; | |
463 typedef Result (*AllocateTextureStorageProc)( | |
464 void* ctx, GrBackendObject texture, unsigned width, | |
465 unsigned height, GrPixelConfig config, const void* srcData, GrSurfac
eOrigin); | |
466 typedef void (*DeallocateTextureStorageProc)(void* ctx, GrBackendObject text
ure); | |
467 | |
468 /* | |
469 * Generates and binds a texture to |textureStorageTarget()|. Allocates | |
470 * storage for the texture. | |
471 * | |
472 * In OpenGL, the MIN and MAX filters for the created texture must be | |
473 * GL_LINEAR. The WRAP_S and WRAP_T must be GL_CLAMP_TO_EDGE. | |
474 * | |
475 * If |srcData| is not nullptr, then the implementation of this function | |
476 * may attempt to upload the data into the texture. On successful upload, | |
477 * or if |srcData| is nullptr, returns kSucceededAndUploaded. | |
478 */ | |
479 AllocateTextureStorageProc fAllocateTextureStorage; | |
480 | |
481 /* | |
482 * Deallocate the storage for the given texture. | |
483 * | |
484 * Skia does not always destroy its outstanding textures. See | |
485 * GrContext::abandonContext() for more details. The consumer of Skia is | |
486 * responsible for making sure that all textures are destroyed, even if this | |
487 * callback is not invoked. | |
488 */ | |
489 DeallocateTextureStorageProc fDeallocateTextureStorage; | |
490 | |
491 /* | |
492 * The context to use when invoking fAllocateTextureStorage and | |
493 * fDeallocateTextureStorage. | |
494 */ | |
495 void* fCtx; | |
496 }; | |
497 | |
498 /** | |
499 * Describes a surface to be created. | 447 * Describes a surface to be created. |
500 */ | 448 */ |
501 struct GrSurfaceDesc { | 449 struct GrSurfaceDesc { |
502 GrSurfaceDesc() | 450 GrSurfaceDesc() |
503 : fFlags(kNone_GrSurfaceFlags) | 451 : fFlags(kNone_GrSurfaceFlags) |
504 , fOrigin(kDefault_GrSurfaceOrigin) | 452 , fOrigin(kDefault_GrSurfaceOrigin) |
505 , fWidth(0) | 453 , fWidth(0) |
506 , fHeight(0) | 454 , fHeight(0) |
507 , fConfig(kUnknown_GrPixelConfig) | 455 , fConfig(kUnknown_GrPixelConfig) |
508 , fSampleCnt(0) | 456 , fSampleCnt(0) |
(...skipping 12 matching lines...) Expand all Loading... |
521 GrPixelConfig fConfig; | 469 GrPixelConfig fConfig; |
522 | 470 |
523 /** | 471 /** |
524 * The number of samples per pixel or 0 to disable full scene AA. This only | 472 * The number of samples per pixel or 0 to disable full scene AA. This only |
525 * applies if the kRenderTarget_GrSurfaceFlag is set. The actual number | 473 * applies if the kRenderTarget_GrSurfaceFlag is set. The actual number |
526 * of samples may not exactly match the request. The request will be rounded | 474 * of samples may not exactly match the request. The request will be rounded |
527 * up to the next supported sample count, or down if it is larger than the | 475 * up to the next supported sample count, or down if it is larger than the |
528 * max supported count. | 476 * max supported count. |
529 */ | 477 */ |
530 int fSampleCnt; | 478 int fSampleCnt; |
531 | |
532 /** | |
533 * A custom platform-specific allocator to use in place of the backend APIs | |
534 * usual texture creation method (e.g. TexImage2D in OpenGL). | |
535 */ | |
536 GrTextureStorageAllocator fTextureStorageAllocator; | |
537 | |
538 bool fIsMipMapped; //!< Indicates if the texture has mipma
ps | 479 bool fIsMipMapped; //!< Indicates if the texture has mipma
ps |
539 }; | 480 }; |
540 | 481 |
541 // Legacy alias | 482 // Legacy alias |
542 typedef GrSurfaceDesc GrTextureDesc; | 483 typedef GrSurfaceDesc GrTextureDesc; |
543 | 484 |
544 /** | 485 /** |
545 * Clips are composed from these objects. | 486 * Clips are composed from these objects. |
546 */ | 487 */ |
547 enum GrClipType { | 488 enum GrClipType { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 return 4 * width * height; | 638 return 4 * width * height; |
698 } | 639 } |
699 } | 640 } |
700 | 641 |
701 /** | 642 /** |
702 * This value translates to reseting all the context state for any backend. | 643 * This value translates to reseting all the context state for any backend. |
703 */ | 644 */ |
704 static const uint32_t kAll_GrBackendState = 0xffffffff; | 645 static const uint32_t kAll_GrBackendState = 0xffffffff; |
705 | 646 |
706 #endif | 647 #endif |
OLD | NEW |