OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef GrTypes_DEFINED | 9 #ifndef GrTypes_DEFINED |
10 #define GrTypes_DEFINED | 10 #define GrTypes_DEFINED |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 * up to the next supported sample count, or down if it is larger than the | 466 * up to the next supported sample count, or down if it is larger than the |
467 * max supported count. | 467 * max supported count. |
468 */ | 468 */ |
469 int fSampleCnt; | 469 int fSampleCnt; |
470 }; | 470 }; |
471 | 471 |
472 // Legacy alias | 472 // Legacy alias |
473 typedef GrSurfaceDesc GrTextureDesc; | 473 typedef GrSurfaceDesc GrTextureDesc; |
474 | 474 |
475 /** | 475 /** |
476 * GrCacheID is used create and find cached GrResources (e.g. GrTextures). The I
D has two parts: | |
477 * the domain and the key. Domains simply allow multiple clients to use 0-based
indices as their | |
478 * cache key without colliding. The key uniquely identifies a GrResource within
the domain. | |
479 * Users of the cache must obtain a domain via GenerateDomain(). | |
480 */ | |
481 struct GrCacheID { | |
482 public: | |
483 typedef uint8_t Domain; | |
484 | |
485 struct Key { | |
486 union { | |
487 uint8_t fData8[16]; | |
488 uint32_t fData32[4]; | |
489 uint64_t fData64[2]; | |
490 }; | |
491 }; | |
492 | |
493 /** | |
494 * A default cache ID is invalid; a set method must be called before the obj
ect is used. | |
495 */ | |
496 GrCacheID() { fDomain = kInvalid_Domain; } | |
497 | |
498 /** | |
499 * Initialize the cache ID to a domain and key. | |
500 */ | |
501 GrCacheID(Domain domain, const Key& key) { | |
502 SkASSERT(kInvalid_Domain != domain); | |
503 this->reset(domain, key); | |
504 } | |
505 | |
506 void reset(Domain domain, const Key& key) { | |
507 fDomain = domain; | |
508 memcpy(&fKey, &key, sizeof(Key)); | |
509 } | |
510 | |
511 /** Has this been initialized to a valid domain */ | |
512 bool isValid() const { return kInvalid_Domain != fDomain; } | |
513 | |
514 const Key& getKey() const { SkASSERT(this->isValid()); return fKey; } | |
515 Domain getDomain() const { SkASSERT(this->isValid()); return fDomain; } | |
516 | |
517 /** Creates a new unique ID domain. */ | |
518 static Domain GenerateDomain(); | |
519 | |
520 private: | |
521 Key fKey; | |
522 Domain fDomain; | |
523 | |
524 static const Domain kInvalid_Domain = 0; | |
525 }; | |
526 | |
527 /** | |
528 * Clips are composed from these objects. | 476 * Clips are composed from these objects. |
529 */ | 477 */ |
530 enum GrClipType { | 478 enum GrClipType { |
531 kRect_ClipType, | 479 kRect_ClipType, |
532 kPath_ClipType | 480 kPath_ClipType |
533 }; | 481 }; |
534 | 482 |
535 /////////////////////////////////////////////////////////////////////////////// | 483 /////////////////////////////////////////////////////////////////////////////// |
536 | 484 |
537 // opaque type for 3D API object handles | 485 // opaque type for 3D API object handles |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 public: | 639 public: |
692 GrAutoMalloc() : INHERITED() {} | 640 GrAutoMalloc() : INHERITED() {} |
693 explicit GrAutoMalloc(size_t size) : INHERITED(size) {} | 641 explicit GrAutoMalloc(size_t size) : INHERITED(size) {} |
694 virtual ~GrAutoMalloc() {} | 642 virtual ~GrAutoMalloc() {} |
695 private: | 643 private: |
696 typedef GrAutoMallocBaseType INHERITED; | 644 typedef GrAutoMallocBaseType INHERITED; |
697 }; | 645 }; |
698 | 646 |
699 #undef GrAutoMallocBaseType | 647 #undef GrAutoMallocBaseType |
700 #endif | 648 #endif |
OLD | NEW |