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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 kZeroCopy_GrSurfaceFlag = 0x2, | 402 kZeroCopy_GrSurfaceFlag = 0x2, |
403 /** | 403 /** |
404 * Indicates that all allocations (color buffer, FBO completeness, etc) | 404 * Indicates that all allocations (color buffer, FBO completeness, etc) |
405 * should be verified. | 405 * should be verified. |
406 */ | 406 */ |
407 kCheckAllocation_GrSurfaceFlag = 0x4, | 407 kCheckAllocation_GrSurfaceFlag = 0x4, |
408 }; | 408 }; |
409 | 409 |
410 GR_MAKE_BITFIELD_OPS(GrSurfaceFlags) | 410 GR_MAKE_BITFIELD_OPS(GrSurfaceFlags) |
411 | 411 |
| 412 // opaque type for 3D API object handles |
| 413 typedef intptr_t GrBackendObject; |
| 414 |
412 /** | 415 /** |
413 * Some textures will be stored such that the upper and left edges of the conten
t meet at the | 416 * Some textures will be stored such that the upper and left edges of the conten
t meet at the |
414 * the origin (in texture coord space) and for other textures the lower and left
edges meet at | 417 * the origin (in texture coord space) and for other textures the lower and left
edges meet at |
415 * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render tar
gets | 418 * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render tar
gets |
416 * to BottomLeft. | 419 * to BottomLeft. |
417 */ | 420 */ |
418 | 421 |
419 enum GrSurfaceOrigin { | 422 enum GrSurfaceOrigin { |
420 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed | 423 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed |
421 kTopLeft_GrSurfaceOrigin, | 424 kTopLeft_GrSurfaceOrigin, |
422 kBottomLeft_GrSurfaceOrigin, | 425 kBottomLeft_GrSurfaceOrigin, |
423 }; | 426 }; |
424 | 427 |
425 /** | 428 /** |
| 429 * An container of function pointers which consumers of Skia can fill in and |
| 430 * pass to Skia. Skia will use these function pointers in place of its backend |
| 431 * API texture creation function. Either all of the function pointers should be |
| 432 * filled in, or they should all be nullptr. |
| 433 */ |
| 434 struct GrTextureStorageAllocator { |
| 435 GrTextureStorageAllocator() |
| 436 : fAllocateTextureStorage(nullptr) |
| 437 , fDeallocateTextureStorage(nullptr) { |
| 438 } |
| 439 |
| 440 enum class Result { |
| 441 kSucceededAndUploaded, |
| 442 kSucceededWithoutUpload, |
| 443 kFailed |
| 444 }; |
| 445 typedef Result (*AllocateTextureStorageProc)( |
| 446 void* ctx, GrBackendObject texture, unsigned width, |
| 447 unsigned height, GrPixelConfig config, const void* srcData, GrSurfac
eOrigin); |
| 448 typedef void (*DeallocateTextureStorageProc)(void* ctx, GrBackendObject text
ure); |
| 449 |
| 450 /* |
| 451 * Generates and binds a texture to |textureStorageTarget()|. Allocates |
| 452 * storage for the texture. |
| 453 * |
| 454 * In OpenGL, the MIN and MAX filters for the created texture must be |
| 455 * GL_LINEAR. The WRAP_S and WRAP_T must be GL_CLAMP_TO_EDGE. |
| 456 * |
| 457 * If |srcData| is not nullptr, then the implementation of this function |
| 458 * may attempt to upload the data into the texture. On successful upload, |
| 459 * or if |srcData| is nullptr, returns kSucceededAndUploaded. |
| 460 */ |
| 461 AllocateTextureStorageProc fAllocateTextureStorage; |
| 462 |
| 463 /* |
| 464 * Deallocate the storage for the given texture. |
| 465 * |
| 466 * Skia does not always destroy its outstanding textures. See |
| 467 * GrContext::abandonContext() for more details. The consumer of Skia is |
| 468 * responsible for making sure that all textures are destroyed, even if this |
| 469 * callback is not invoked. |
| 470 */ |
| 471 DeallocateTextureStorageProc fDeallocateTextureStorage; |
| 472 |
| 473 /* |
| 474 * The context to use when invoking fAllocateTextureStorage and |
| 475 * fDeallocateTextureStorage. |
| 476 */ |
| 477 void* fCtx; |
| 478 }; |
| 479 |
| 480 /** |
426 * Describes a surface to be created. | 481 * Describes a surface to be created. |
427 */ | 482 */ |
428 struct GrSurfaceDesc { | 483 struct GrSurfaceDesc { |
429 GrSurfaceDesc() | 484 GrSurfaceDesc() |
430 : fFlags(kNone_GrSurfaceFlags) | 485 : fFlags(kNone_GrSurfaceFlags) |
431 , fOrigin(kDefault_GrSurfaceOrigin) | 486 , fOrigin(kDefault_GrSurfaceOrigin) |
432 , fWidth(0) | 487 , fWidth(0) |
433 , fHeight(0) | 488 , fHeight(0) |
434 , fConfig(kUnknown_GrPixelConfig) | 489 , fConfig(kUnknown_GrPixelConfig) |
435 , fSampleCnt(0) { | 490 , fSampleCnt(0) { |
(...skipping 11 matching lines...) Expand all Loading... |
447 GrPixelConfig fConfig; | 502 GrPixelConfig fConfig; |
448 | 503 |
449 /** | 504 /** |
450 * The number of samples per pixel or 0 to disable full scene AA. This only | 505 * The number of samples per pixel or 0 to disable full scene AA. This only |
451 * applies if the kRenderTarget_GrSurfaceFlag is set. The actual number | 506 * applies if the kRenderTarget_GrSurfaceFlag is set. The actual number |
452 * of samples may not exactly match the request. The request will be rounded | 507 * of samples may not exactly match the request. The request will be rounded |
453 * up to the next supported sample count, or down if it is larger than the | 508 * up to the next supported sample count, or down if it is larger than the |
454 * max supported count. | 509 * max supported count. |
455 */ | 510 */ |
456 int fSampleCnt; | 511 int fSampleCnt; |
| 512 |
| 513 /** |
| 514 * A custom platform-specific allocator to use in place of the backend APIs |
| 515 * usual texture creation method (e.g. TexImage2D in OpenGL). |
| 516 */ |
| 517 GrTextureStorageAllocator fTextureStorageAllocator; |
457 }; | 518 }; |
458 | 519 |
459 // Legacy alias | 520 // Legacy alias |
460 typedef GrSurfaceDesc GrTextureDesc; | 521 typedef GrSurfaceDesc GrTextureDesc; |
461 | 522 |
462 /** | 523 /** |
463 * Clips are composed from these objects. | 524 * Clips are composed from these objects. |
464 */ | 525 */ |
465 enum GrClipType { | 526 enum GrClipType { |
466 kRect_ClipType, | 527 kRect_ClipType, |
467 kPath_ClipType | 528 kPath_ClipType |
468 }; | 529 }; |
469 | 530 |
470 /////////////////////////////////////////////////////////////////////////////// | 531 /////////////////////////////////////////////////////////////////////////////// |
471 | 532 |
472 // opaque type for 3D API object handles | |
473 typedef intptr_t GrBackendObject; | |
474 | |
475 | 533 |
476 /** Ownership rules for external GPU resources imported into Skia. */ | 534 /** Ownership rules for external GPU resources imported into Skia. */ |
477 enum GrWrapOwnership { | 535 enum GrWrapOwnership { |
478 /** Skia will assume the client will keep the resource alive and Skia will n
ot free it. */ | 536 /** Skia will assume the client will keep the resource alive and Skia will n
ot free it. */ |
479 kBorrow_GrWrapOwnership, | 537 kBorrow_GrWrapOwnership, |
480 | 538 |
481 /** Skia will assume ownership of the resource and free it. */ | 539 /** Skia will assume ownership of the resource and free it. */ |
482 kAdopt_GrWrapOwnership, | 540 kAdopt_GrWrapOwnership, |
483 }; | 541 }; |
484 | 542 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 return 4 * width * height; | 676 return 4 * width * height; |
619 } | 677 } |
620 } | 678 } |
621 | 679 |
622 /** | 680 /** |
623 * This value translates to reseting all the context state for any backend. | 681 * This value translates to reseting all the context state for any backend. |
624 */ | 682 */ |
625 static const uint32_t kAll_GrBackendState = 0xffffffff; | 683 static const uint32_t kAll_GrBackendState = 0xffffffff; |
626 | 684 |
627 #endif | 685 #endif |
OLD | NEW |