Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: include/gpu/GrTypes.h

Issue 1623653002: skia: Add support for CHROMIUM_image backed textures. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Add test. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 /** 412 /**
413 * An abstract base class which consumers of Skia can subclass and pass to Skia
414 * to use custom storage allocation in place of TexImage2D.
415 */
416 class TextureStorageAllocator {
417 public:
418 /*
419 * The required bind target for any texture with custom storage.
420 */
421 virtual unsigned textureStorageTarget() = 0;
422 /*
423 * Allocates storage for the texture. |textureId| must already be bound to
424 * |TextureTarget()|.
425 */
426 virtual bool allocateTextureStorage(unsigned textureId, unsigned width, unsign ed height) = 0;
bsalomon 2016/01/25 20:51:09 What do you think about virtual bool allocateText
erikchen 2016/01/26 18:36:16 I went with your suggested API for allocateTexture
427 /*
428 * Deallocate the storage for the given texture.
429 */
430 virtual void deallocateTextureStorage(unsigned textureId) = 0;
431
432 protected:
433 ~TextureStorageAllocator() {}
434 };
435
436 /**
413 * Some textures will be stored such that the upper and left edges of the conten t meet at the 437 * 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 438 * 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 439 * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render tar gets
416 * to BottomLeft. 440 * to BottomLeft.
417 */ 441 */
418 442
419 enum GrSurfaceOrigin { 443 enum GrSurfaceOrigin {
420 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed 444 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed
421 kTopLeft_GrSurfaceOrigin, 445 kTopLeft_GrSurfaceOrigin,
422 kBottomLeft_GrSurfaceOrigin, 446 kBottomLeft_GrSurfaceOrigin,
423 }; 447 };
424 448
425 /** 449 /**
426 * Describes a surface to be created. 450 * Describes a surface to be created.
427 */ 451 */
428 struct GrSurfaceDesc { 452 struct GrSurfaceDesc {
429 GrSurfaceDesc() 453 GrSurfaceDesc()
430 : fFlags(kNone_GrSurfaceFlags) 454 : fFlags(kNone_GrSurfaceFlags)
431 , fOrigin(kDefault_GrSurfaceOrigin) 455 , fOrigin(kDefault_GrSurfaceOrigin)
432 , fWidth(0) 456 , fWidth(0)
433 , fHeight(0) 457 , fHeight(0)
434 , fConfig(kUnknown_GrPixelConfig) 458 , fConfig(kUnknown_GrPixelConfig)
435 , fSampleCnt(0) { 459 , fSampleCnt(0)
460 , fTextureStorageAllocator(nullptr) {
436 } 461 }
437 462
438 GrSurfaceFlags fFlags; //!< bitfield of TextureFlags 463 GrSurfaceFlags fFlags; //!< bitfield of TextureFlags
439 GrSurfaceOrigin fOrigin; //!< origin of the texture 464 GrSurfaceOrigin fOrigin; //!< origin of the texture
440 int fWidth; //!< Width of the texture 465 int fWidth; //!< Width of the texture
441 int fHeight; //!< Height of the texture 466 int fHeight; //!< Height of the texture
442 467
443 /** 468 /**
444 * Format of source data of the texture. Not guaranteed to be the same as 469 * Format of source data of the texture. Not guaranteed to be the same as
445 * internal format used by 3D API. 470 * internal format used by 3D API.
446 */ 471 */
447 GrPixelConfig fConfig; 472 GrPixelConfig fConfig;
448 473
449 /** 474 /**
450 * The number of samples per pixel or 0 to disable full scene AA. This only 475 * 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 476 * applies if the kRenderTarget_GrSurfaceFlag is set. The actual number
452 * of samples may not exactly match the request. The request will be rounded 477 * 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 478 * up to the next supported sample count, or down if it is larger than the
454 * max supported count. 479 * max supported count.
455 */ 480 */
456 int fSampleCnt; 481 int fSampleCnt;
482
483 /**
484 * A custom platform-specific allocator to use in place of TexImage2D. All
485 * surfaces derived from the original surface will have the same value for
486 * fTextureStorageAllocator.
487 */
488 TextureStorageAllocator* fTextureStorageAllocator;
457 }; 489 };
458 490
459 // Legacy alias 491 // Legacy alias
460 typedef GrSurfaceDesc GrTextureDesc; 492 typedef GrSurfaceDesc GrTextureDesc;
461 493
462 /** 494 /**
463 * Clips are composed from these objects. 495 * Clips are composed from these objects.
464 */ 496 */
465 enum GrClipType { 497 enum GrClipType {
466 kRect_ClipType, 498 kRect_ClipType,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 /** 558 /**
527 * If the render target flag is set and sample count is greater than 0 559 * If the render target flag is set and sample count is greater than 0
528 * then Gr will create an MSAA buffer that resolves to the texture. 560 * then Gr will create an MSAA buffer that resolves to the texture.
529 */ 561 */
530 int fSampleCnt; 562 int fSampleCnt;
531 /** 563 /**
532 * Handle to the 3D API object. 564 * Handle to the 3D API object.
533 * OpenGL: Texture ID. 565 * OpenGL: Texture ID.
534 */ 566 */
535 GrBackendObject fTextureHandle; 567 GrBackendObject fTextureHandle;
568 /**
569 * The custom allocator to use in place of TexImage2D.
570 */
571 TextureStorageAllocator* fTextureStorageAllocator;
bsalomon 2016/01/25 20:51:09 We shouldn't need this here. This is used to impor
erikchen 2016/01/26 18:36:16 Done.
536 }; 572 };
537 573
538 /////////////////////////////////////////////////////////////////////////////// 574 ///////////////////////////////////////////////////////////////////////////////
539 575
540 /** 576 /**
541 * Gr can wrap an existing render target created by the client in the 3D API 577 * Gr can wrap an existing render target created by the client in the 3D API
542 * with a GrRenderTarget object. The client is responsible for ensuring that the 578 * with a GrRenderTarget object. The client is responsible for ensuring that the
543 * underlying 3D API object lives at least as long as the GrRenderTarget object 579 * underlying 3D API object lives at least as long as the GrRenderTarget object
544 * wrapping it. We require the client to explicitly provide information about 580 * wrapping it. We require the client to explicitly provide information about
545 * the target, such as width, height, and pixel config rather than querying the 581 * the target, such as width, height, and pixel config rather than querying the
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 return 4 * width * height; 654 return 4 * width * height;
619 } 655 }
620 } 656 }
621 657
622 /** 658 /**
623 * This value translates to reseting all the context state for any backend. 659 * This value translates to reseting all the context state for any backend.
624 */ 660 */
625 static const uint32_t kAll_GrBackendState = 0xffffffff; 661 static const uint32_t kAll_GrBackendState = 0xffffffff;
626 662
627 #endif 663 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698