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 abstract base class which consumers of Skia can subclass and pass to Skia. | |
417 * Skia will use this object in place of its backend API texture creation | |
418 * function. | |
419 */ | |
420 class GrTextureStorageAllocator { | |
421 public: | |
422 /* | |
423 * Whether a texture can be created with the given pixel config. | |
424 */ | |
425 virtual bool supportsPixelConfig(GrPixelConfig config) = 0; | |
426 /* | |
427 * Generates and binds a texture to |textureStorageTarget()|. Allocates | |
428 * storage for the texture. | |
429 * | |
430 * The MIN and MAX filters for the created texture must be GL_LINEAR. The | |
431 * WRAP_S and WRAP_T must be GL_CLAMP_TO_EDGE. | |
432 * | |
433 * The internal format must be GL_RGBA. | |
bsalomon
2016/01/29 16:57:38
I'm not crazy about this restriction. I get that t
erikchen
2016/01/29 20:32:25
I added two more parameters: GrPixelConfig and a c
| |
434 */ | |
435 virtual bool allocateTextureStorage(GrBackendObject texture, unsigned width, | |
436 unsigned height) = 0; | |
437 /* | |
438 * Deallocate the storage for the given texture. | |
439 * | |
440 * Skia does not always destroy its outstanding textures. See | |
441 * GrContext::abandonContext() for more details. The consumer of Skia is | |
442 * responsible for making sure that all textures are destroyed, even if this | |
443 * callback is not invoked. | |
444 */ | |
445 virtual void deallocateTextureStorage(GrBackendObject texture) = 0; | |
446 | |
447 protected: | |
448 virtual ~GrTextureStorageAllocator() {} | |
449 }; | |
450 | |
412 /** | 451 /** |
413 * Some textures will be stored such that the upper and left edges of the conten t meet at the | 452 * 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 | 453 * 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 | 454 * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render tar gets |
416 * to BottomLeft. | 455 * to BottomLeft. |
417 */ | 456 */ |
418 | 457 |
419 enum GrSurfaceOrigin { | 458 enum GrSurfaceOrigin { |
420 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed | 459 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed |
421 kTopLeft_GrSurfaceOrigin, | 460 kTopLeft_GrSurfaceOrigin, |
422 kBottomLeft_GrSurfaceOrigin, | 461 kBottomLeft_GrSurfaceOrigin, |
423 }; | 462 }; |
424 | 463 |
425 /** | 464 /** |
426 * Describes a surface to be created. | 465 * Describes a surface to be created. |
427 */ | 466 */ |
428 struct GrSurfaceDesc { | 467 struct GrSurfaceDesc { |
429 GrSurfaceDesc() | 468 GrSurfaceDesc() |
430 : fFlags(kNone_GrSurfaceFlags) | 469 : fFlags(kNone_GrSurfaceFlags) |
431 , fOrigin(kDefault_GrSurfaceOrigin) | 470 , fOrigin(kDefault_GrSurfaceOrigin) |
432 , fWidth(0) | 471 , fWidth(0) |
433 , fHeight(0) | 472 , fHeight(0) |
434 , fConfig(kUnknown_GrPixelConfig) | 473 , fConfig(kUnknown_GrPixelConfig) |
435 , fSampleCnt(0) { | 474 , fSampleCnt(0) |
475 , fTextureStorageAllocator(nullptr) { | |
436 } | 476 } |
437 | 477 |
438 GrSurfaceFlags fFlags; //!< bitfield of TextureFlags | 478 GrSurfaceFlags fFlags; //!< bitfield of TextureFlags |
439 GrSurfaceOrigin fOrigin; //!< origin of the texture | 479 GrSurfaceOrigin fOrigin; //!< origin of the texture |
440 int fWidth; //!< Width of the texture | 480 int fWidth; //!< Width of the texture |
441 int fHeight; //!< Height of the texture | 481 int fHeight; //!< Height of the texture |
442 | 482 |
443 /** | 483 /** |
444 * Format of source data of the texture. Not guaranteed to be the same as | 484 * Format of source data of the texture. Not guaranteed to be the same as |
445 * internal format used by 3D API. | 485 * internal format used by 3D API. |
446 */ | 486 */ |
447 GrPixelConfig fConfig; | 487 GrPixelConfig fConfig; |
448 | 488 |
449 /** | 489 /** |
450 * The number of samples per pixel or 0 to disable full scene AA. This only | 490 * 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 | 491 * applies if the kRenderTarget_GrSurfaceFlag is set. The actual number |
452 * of samples may not exactly match the request. The request will be rounded | 492 * 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 | 493 * up to the next supported sample count, or down if it is larger than the |
454 * max supported count. | 494 * max supported count. |
455 */ | 495 */ |
456 int fSampleCnt; | 496 int fSampleCnt; |
497 | |
498 /** | |
499 * A custom platform-specific allocator to use in place of TexImage2D. All | |
500 * surfaces derived from the original surface will have the same value for | |
501 * fTextureStorageAllocator. | |
502 */ | |
503 GrTextureStorageAllocator* fTextureStorageAllocator; | |
457 }; | 504 }; |
458 | 505 |
459 // Legacy alias | 506 // Legacy alias |
460 typedef GrSurfaceDesc GrTextureDesc; | 507 typedef GrSurfaceDesc GrTextureDesc; |
461 | 508 |
462 /** | 509 /** |
463 * Clips are composed from these objects. | 510 * Clips are composed from these objects. |
464 */ | 511 */ |
465 enum GrClipType { | 512 enum GrClipType { |
466 kRect_ClipType, | 513 kRect_ClipType, |
467 kPath_ClipType | 514 kPath_ClipType |
468 }; | 515 }; |
469 | 516 |
470 /////////////////////////////////////////////////////////////////////////////// | 517 /////////////////////////////////////////////////////////////////////////////// |
471 | 518 |
472 // opaque type for 3D API object handles | |
473 typedef intptr_t GrBackendObject; | |
474 | |
475 | 519 |
476 /** Ownership rules for external GPU resources imported into Skia. */ | 520 /** Ownership rules for external GPU resources imported into Skia. */ |
477 enum GrWrapOwnership { | 521 enum GrWrapOwnership { |
478 /** Skia will assume the client will keep the resource alive and Skia will n ot free it. */ | 522 /** Skia will assume the client will keep the resource alive and Skia will n ot free it. */ |
479 kBorrow_GrWrapOwnership, | 523 kBorrow_GrWrapOwnership, |
480 | 524 |
481 /** Skia will assume ownership of the resource and free it. */ | 525 /** Skia will assume ownership of the resource and free it. */ |
482 kAdopt_GrWrapOwnership, | 526 kAdopt_GrWrapOwnership, |
483 }; | 527 }; |
484 | 528 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
618 return 4 * width * height; | 662 return 4 * width * height; |
619 } | 663 } |
620 } | 664 } |
621 | 665 |
622 /** | 666 /** |
623 * This value translates to reseting all the context state for any backend. | 667 * This value translates to reseting all the context state for any backend. |
624 */ | 668 */ |
625 static const uint32_t kAll_GrBackendState = 0xffffffff; | 669 static const uint32_t kAll_GrBackendState = 0xffffffff; |
626 | 670 |
627 #endif | 671 #endif |
OLD | NEW |