Chromium Code Reviews| 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 | |
| 415 /** | |
| 416 * An container of function pointers which consumers of Skia can fill in and | |
| 417 * pass to Skia. Skia will use these function pointers in place of its backend | |
| 418 * API texture creation function. Either all of the function pointers should be | |
| 419 * filled in, or they should all be nullptr. | |
| 420 */ | |
| 421 struct GrTextureStorageAllocator { | |
| 422 GrTextureStorageAllocator() | |
| 423 : fAllocateTextureStorage(nullptr) | |
| 424 , fDeallocateTextureStorage(nullptr) { | |
| 425 } | |
| 426 | |
| 427 enum class Result { | |
| 428 kSucceededAndUploaded, | |
| 429 kSucceededWithoutUpload, | |
| 430 kFailed | |
| 431 }; | |
| 432 typedef Result (*AllocateTextureStorageProc)( | |
| 433 void* ctx, GrBackendObject texture, unsigned width, | |
| 434 unsigned height, GrPixelConfig config, const void* srcData); | |
| 435 typedef void (*DeallocateTextureStorageProc)(void* ctx, GrBackendObject text ure); | |
| 436 | |
| 437 /* | |
| 438 * Generates and binds a texture to |textureStorageTarget()|. Allocates | |
| 439 * storage for the texture. | |
| 440 * | |
| 441 * The MIN and MAX filters for the created texture must be GL_LINEAR. The | |
|
bsalomon
2016/02/01 14:54:42
In OpenGL, ...
erikchen
2016/02/01 22:58:32
Done.
| |
| 442 * WRAP_S and WRAP_T must be GL_CLAMP_TO_EDGE. | |
| 443 * | |
| 444 * If |srcData| is not nullptr, then the implementation of this function | |
|
bsalomon
2016/02/01 14:54:42
I think we need an origin param as well. Also, may
erikchen
2016/02/01 22:58:32
Done and done.
| |
| 445 * should attempt to upload the data into the texture. On successful upload, | |
| 446 * or if |srcData| is nullptr, returns kSucceededAndUploaded. | |
| 447 */ | |
| 448 AllocateTextureStorageProc fAllocateTextureStorage; | |
| 449 | |
| 450 /* | |
| 451 * Deallocate the storage for the given texture. | |
| 452 * | |
| 453 * Skia does not always destroy its outstanding textures. See | |
| 454 * GrContext::abandonContext() for more details. The consumer of Skia is | |
| 455 * responsible for making sure that all textures are destroyed, even if this | |
| 456 * callback is not invoked. | |
| 457 */ | |
| 458 DeallocateTextureStorageProc fDeallocateTextureStorage; | |
| 459 | |
| 460 /* | |
| 461 * The context to use when invoking fAllocateTextureStorage and | |
| 462 * fDeallocateTextureStorage. | |
| 463 */ | |
| 464 void* fCtx; | |
| 465 }; | |
| 466 | |
| 412 /** | 467 /** |
| 413 * Some textures will be stored such that the upper and left edges of the conten t meet at the | 468 * 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 | 469 * 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 | 470 * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render tar gets |
| 416 * to BottomLeft. | 471 * to BottomLeft. |
| 417 */ | 472 */ |
| 418 | 473 |
| 419 enum GrSurfaceOrigin { | 474 enum GrSurfaceOrigin { |
| 420 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed | 475 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed |
| 421 kTopLeft_GrSurfaceOrigin, | 476 kTopLeft_GrSurfaceOrigin, |
| (...skipping 25 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 TexImage2D. All | |
|
bsalomon
2016/02/01 14:54:42
...in place of the backend APIs usual texture crea
erikchen
2016/02/01 22:58:32
Done.
| |
| 515 * surfaces derived from the original surface will have the same value for | |
|
bsalomon
2016/02/01 14:54:42
What exactly is meant here by surfaces derived fro
erikchen
2016/02/01 22:58:32
I was referring to RenderTargets created by copy-o
| |
| 516 * fTextureStorageAllocator. | |
| 517 */ | |
| 518 GrTextureStorageAllocator fTextureStorageAllocator; | |
| 457 }; | 519 }; |
| 458 | 520 |
| 459 // Legacy alias | 521 // Legacy alias |
| 460 typedef GrSurfaceDesc GrTextureDesc; | 522 typedef GrSurfaceDesc GrTextureDesc; |
| 461 | 523 |
| 462 /** | 524 /** |
| 463 * Clips are composed from these objects. | 525 * Clips are composed from these objects. |
| 464 */ | 526 */ |
| 465 enum GrClipType { | 527 enum GrClipType { |
| 466 kRect_ClipType, | 528 kRect_ClipType, |
| 467 kPath_ClipType | 529 kPath_ClipType |
| 468 }; | 530 }; |
| 469 | 531 |
| 470 /////////////////////////////////////////////////////////////////////////////// | 532 /////////////////////////////////////////////////////////////////////////////// |
| 471 | 533 |
| 472 // opaque type for 3D API object handles | |
| 473 typedef intptr_t GrBackendObject; | |
| 474 | |
| 475 | 534 |
| 476 /** Ownership rules for external GPU resources imported into Skia. */ | 535 /** Ownership rules for external GPU resources imported into Skia. */ |
| 477 enum GrWrapOwnership { | 536 enum GrWrapOwnership { |
| 478 /** Skia will assume the client will keep the resource alive and Skia will n ot free it. */ | 537 /** Skia will assume the client will keep the resource alive and Skia will n ot free it. */ |
| 479 kBorrow_GrWrapOwnership, | 538 kBorrow_GrWrapOwnership, |
| 480 | 539 |
| 481 /** Skia will assume ownership of the resource and free it. */ | 540 /** Skia will assume ownership of the resource and free it. */ |
| 482 kAdopt_GrWrapOwnership, | 541 kAdopt_GrWrapOwnership, |
| 483 }; | 542 }; |
| 484 | 543 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 return 4 * width * height; | 677 return 4 * width * height; |
| 619 } | 678 } |
| 620 } | 679 } |
| 621 | 680 |
| 622 /** | 681 /** |
| 623 * This value translates to reseting all the context state for any backend. | 682 * This value translates to reseting all the context state for any backend. |
| 624 */ | 683 */ |
| 625 static const uint32_t kAll_GrBackendState = 0xffffffff; | 684 static const uint32_t kAll_GrBackendState = 0xffffffff; |
| 626 | 685 |
| 627 #endif | 686 #endif |
| OLD | NEW |