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