GrTexturePriv.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2014 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef GrTexturePriv_DEFINED
  8. #define GrTexturePriv_DEFINED
  9. #include "include/gpu/GrTexture.h"
  10. /** Class that adds methods to GrTexture that are only intended for use internal to Skia.
  11. This class is purely a privileged window into GrTexture. It should never have additional data
  12. members or virtual methods.
  13. Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and
  14. implemented privately in GrTexture with a inline public method here). */
  15. class GrTexturePriv {
  16. public:
  17. void markMipMapsDirty() {
  18. fTexture->markMipMapsDirty();
  19. }
  20. void markMipMapsClean() {
  21. fTexture->markMipMapsClean();
  22. }
  23. bool mipMapsAreDirty() const {
  24. return GrMipMapsStatus::kValid != fTexture->fMipMapsStatus;
  25. }
  26. GrMipMapped mipMapped() const {
  27. if (GrMipMapsStatus::kNotAllocated != fTexture->fMipMapsStatus) {
  28. return GrMipMapped::kYes;
  29. }
  30. return GrMipMapped::kNo;
  31. }
  32. int maxMipMapLevel() const {
  33. return fTexture->fMaxMipMapLevel;
  34. }
  35. GrTextureType textureType() const { return fTexture->fTextureType; }
  36. bool hasRestrictedSampling() const {
  37. return GrTextureTypeHasRestrictedSampling(this->textureType());
  38. }
  39. /** Filtering is clamped to this value. */
  40. GrSamplerState::Filter highestFilterMode() const {
  41. return this->hasRestrictedSampling() ? GrSamplerState::Filter::kBilerp
  42. : GrSamplerState::Filter::kMipMap;
  43. }
  44. static void ComputeScratchKey(const GrSurfaceDesc&, GrRenderable, int sampleCnt, GrScratchKey*);
  45. static void ComputeScratchKey(GrPixelConfig config, int width, int height, GrRenderable,
  46. int sampleCnt, GrMipMapped, GrScratchKey* key);
  47. private:
  48. GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
  49. GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
  50. GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
  51. // No taking addresses of this type.
  52. const GrTexturePriv* operator&() const;
  53. GrTexturePriv* operator&();
  54. GrTexture* fTexture;
  55. friend class GrTexture; // to construct/copy this type.
  56. };
  57. inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
  58. inline const GrTexturePriv GrTexture::texturePriv () const {
  59. return GrTexturePriv(const_cast<GrTexture*>(this));
  60. }
  61. #endif