GrGLTypesPriv.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright 2019 Google LLC
  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. #include "include/core/SkScalar.h"
  8. #include "include/private/GrGLTypesPriv.h"
  9. #include "src/gpu/GrSwizzle.h"
  10. #include "src/gpu/gl/GrGLDefines.h"
  11. GrGLTextureParameters::SamplerOverriddenState::SamplerOverriddenState()
  12. // These are the OpenGL defaults.
  13. : fMinFilter(GR_GL_NEAREST_MIPMAP_LINEAR)
  14. , fMagFilter(GR_GL_LINEAR)
  15. , fWrapS(GR_GL_REPEAT)
  16. , fWrapT(GR_GL_REPEAT)
  17. , fMinLOD(-1000.f)
  18. , fMaxLOD(1000.f)
  19. , fBorderColorInvalid(false) {}
  20. void GrGLTextureParameters::SamplerOverriddenState::invalidate() {
  21. fMinFilter = ~0U;
  22. fMagFilter = ~0U;
  23. fWrapS = ~0U;
  24. fWrapT = ~0U;
  25. fMinLOD = SK_ScalarNaN;
  26. fMaxLOD = SK_ScalarNaN;
  27. fBorderColorInvalid = true;
  28. }
  29. GrGLTextureParameters::NonsamplerState::NonsamplerState()
  30. // These are the OpenGL defaults.
  31. : fSwizzleKey(GrSwizzle::RGBA().asKey()), fBaseMipMapLevel(0), fMaxMipMapLevel(1000) {}
  32. void GrGLTextureParameters::NonsamplerState::invalidate() {
  33. fSwizzleKey = ~0U;
  34. fBaseMipMapLevel = ~0;
  35. fMaxMipMapLevel = ~0;
  36. }
  37. void GrGLTextureParameters::invalidate() {
  38. fSamplerOverriddenState.invalidate();
  39. fNonsamplerState.invalidate();
  40. }
  41. void GrGLTextureParameters::set(const SamplerOverriddenState* samplerState,
  42. const NonsamplerState& nonsamplerState,
  43. ResetTimestamp currTimestamp) {
  44. if (samplerState) {
  45. fSamplerOverriddenState = *samplerState;
  46. }
  47. fNonsamplerState = nonsamplerState;
  48. fResetTimestamp = currTimestamp;
  49. }
  50. void GrGLBackendTextureInfo::assign(const GrGLBackendTextureInfo& that, bool thisIsValid) {
  51. fInfo = that.fInfo;
  52. SkSafeRef(that.fParams);
  53. if (thisIsValid) {
  54. SkSafeUnref(fParams);
  55. }
  56. fParams = that.fParams;
  57. }
  58. void GrGLBackendTextureInfo::cleanup() { SkSafeUnref(fParams); }