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

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: Minor cleanup. 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
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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 * to use custom storage allocation in place of TexImage2D.
bsalomon 2016/01/26 22:20:54 Maybe say "in place of backend API texture creatio
erikchen 2016/01/27 21:55:14 Done.
418 */
419 class TextureStorageAllocator {
bsalomon 2016/01/26 22:20:54 Should be GrTextureStorageAllocator
erikchen 2016/01/27 21:55:15 Done.
420 public:
421 /*
bsalomon 2016/01/26 22:20:54 nit, we use four space indents.
erikchen 2016/01/27 21:55:14 Done.
422 * The required bind target for any texture with custom storage.
423 */
424 virtual unsigned textureStorageTarget() = 0;
425 /*
426 * Generates and binds a texture to |textureStorageTarget()|. Allocates
427 * storage for the texture.
428 *
429 * The MIN and MAX filters for the created texture must be GL_LINEAR. The
430 * WRAP_S and WRAP_T must be GL_CLAMP_TO_EDGE.
431 */
432 virtual bool allocateTextureStorage(GrBackendObject texture, unsigned width,
bsalomon 2016/01/26 22:20:54 Don't we also need to somehow tell the allocator t
erikchen 2016/01/27 21:55:14 CHROMIUM_image on Mac supports very few pixel form
433 unsigned height) = 0;
434 /*
435 * Deallocate the storage for the given texture.
436 */
437 virtual void deallocateTextureStorage(GrBackendObject texture) = 0;
bsalomon 2016/01/26 22:20:54 We have a method on GrContext called abandonContex
erikchen 2016/01/27 21:55:15 The consumer of Skia will be responsible for destr
438
439 protected:
440 ~TextureStorageAllocator() {}
bsalomon 2016/01/26 22:20:54 Who deletes the allocator, Skia? Should this be vi
erikchen 2016/01/27 21:55:14 Skia does not delete the allocator, but this shoul
441 };
442
412 /** 443 /**
413 * Some textures will be stored such that the upper and left edges of the conten t meet at the 444 * 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 445 * 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 446 * the origin. kDefault_GrSurfaceOrigin sets textures to TopLeft, and render tar gets
416 * to BottomLeft. 447 * to BottomLeft.
417 */ 448 */
418 449
419 enum GrSurfaceOrigin { 450 enum GrSurfaceOrigin {
420 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed 451 kDefault_GrSurfaceOrigin, // DEPRECATED; to be removed
421 kTopLeft_GrSurfaceOrigin, 452 kTopLeft_GrSurfaceOrigin,
422 kBottomLeft_GrSurfaceOrigin, 453 kBottomLeft_GrSurfaceOrigin,
423 }; 454 };
424 455
425 /** 456 /**
426 * Describes a surface to be created. 457 * Describes a surface to be created.
427 */ 458 */
428 struct GrSurfaceDesc { 459 struct GrSurfaceDesc {
429 GrSurfaceDesc() 460 GrSurfaceDesc()
430 : fFlags(kNone_GrSurfaceFlags) 461 : fFlags(kNone_GrSurfaceFlags)
431 , fOrigin(kDefault_GrSurfaceOrigin) 462 , fOrigin(kDefault_GrSurfaceOrigin)
432 , fWidth(0) 463 , fWidth(0)
433 , fHeight(0) 464 , fHeight(0)
434 , fConfig(kUnknown_GrPixelConfig) 465 , fConfig(kUnknown_GrPixelConfig)
435 , fSampleCnt(0) { 466 , fSampleCnt(0)
467 , fTextureStorageAllocator(nullptr) {
436 } 468 }
437 469
438 GrSurfaceFlags fFlags; //!< bitfield of TextureFlags 470 GrSurfaceFlags fFlags; //!< bitfield of TextureFlags
439 GrSurfaceOrigin fOrigin; //!< origin of the texture 471 GrSurfaceOrigin fOrigin; //!< origin of the texture
440 int fWidth; //!< Width of the texture 472 int fWidth; //!< Width of the texture
441 int fHeight; //!< Height of the texture 473 int fHeight; //!< Height of the texture
442 474
443 /** 475 /**
444 * Format of source data of the texture. Not guaranteed to be the same as 476 * Format of source data of the texture. Not guaranteed to be the same as
445 * internal format used by 3D API. 477 * internal format used by 3D API.
446 */ 478 */
447 GrPixelConfig fConfig; 479 GrPixelConfig fConfig;
448 480
449 /** 481 /**
450 * The number of samples per pixel or 0 to disable full scene AA. This only 482 * 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 483 * applies if the kRenderTarget_GrSurfaceFlag is set. The actual number
452 * of samples may not exactly match the request. The request will be rounded 484 * 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 485 * up to the next supported sample count, or down if it is larger than the
454 * max supported count. 486 * max supported count.
455 */ 487 */
456 int fSampleCnt; 488 int fSampleCnt;
489
490 /**
491 * A custom platform-specific allocator to use in place of TexImage2D. All
492 * surfaces derived from the original surface will have the same value for
493 * fTextureStorageAllocator.
494 */
495 TextureStorageAllocator* fTextureStorageAllocator;
457 }; 496 };
458 497
459 // Legacy alias 498 // Legacy alias
460 typedef GrSurfaceDesc GrTextureDesc; 499 typedef GrSurfaceDesc GrTextureDesc;
461 500
462 /** 501 /**
463 * Clips are composed from these objects. 502 * Clips are composed from these objects.
464 */ 503 */
465 enum GrClipType { 504 enum GrClipType {
466 kRect_ClipType, 505 kRect_ClipType,
467 kPath_ClipType 506 kPath_ClipType
468 }; 507 };
469 508
470 /////////////////////////////////////////////////////////////////////////////// 509 ///////////////////////////////////////////////////////////////////////////////
471 510
472 // opaque type for 3D API object handles
473 typedef intptr_t GrBackendObject;
474
475 511
476 /** Ownership rules for external GPU resources imported into Skia. */ 512 /** Ownership rules for external GPU resources imported into Skia. */
477 enum GrWrapOwnership { 513 enum GrWrapOwnership {
478 /** Skia will assume the client will keep the resource alive and Skia will n ot free it. */ 514 /** Skia will assume the client will keep the resource alive and Skia will n ot free it. */
479 kBorrow_GrWrapOwnership, 515 kBorrow_GrWrapOwnership,
480 516
481 /** Skia will assume ownership of the resource and free it. */ 517 /** Skia will assume ownership of the resource and free it. */
482 kAdopt_GrWrapOwnership, 518 kAdopt_GrWrapOwnership,
483 }; 519 };
484 520
(...skipping 133 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

Powered by Google App Engine
This is Rietveld 408576698