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 "src/gpu/ganesh/gl/GrGLTypesPriv.h"
8
9 #include "include/core/SkScalar.h"
10 #include "include/gpu/ganesh/GrTypes.h"
11 #include "src/gpu/ganesh/gl/GrGLDefines.h"
12
SamplerOverriddenState()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 , fMaxAniso(1.f)
22 , fBorderColorInvalid(false) {}
23
invalidate()24 void GrGLTextureParameters::SamplerOverriddenState::invalidate() {
25 fMinFilter = ~0U;
26 fMagFilter = ~0U;
27 fWrapS = ~0U;
28 fWrapT = ~0U;
29 fMinLOD = SK_ScalarNaN;
30 fMaxLOD = SK_ScalarNaN;
31 fMaxAniso = -1.f;
32 fBorderColorInvalid = true;
33 }
34
NonsamplerState()35 GrGLTextureParameters::NonsamplerState::NonsamplerState()
36 // These are the OpenGL defaults.
37 : fBaseMipMapLevel(0), fMaxMipmapLevel(1000), fSwizzleIsRGBA(true) {}
38
invalidate()39 void GrGLTextureParameters::NonsamplerState::invalidate() {
40 fSwizzleIsRGBA = false;
41 fBaseMipMapLevel = ~0;
42 fMaxMipmapLevel = ~0;
43 }
44
invalidate()45 void GrGLTextureParameters::invalidate() {
46 fSamplerOverriddenState.invalidate();
47 fNonsamplerState.invalidate();
48 }
49
set(const SamplerOverriddenState * samplerState,const NonsamplerState & nonsamplerState,ResetTimestamp currTimestamp)50 void GrGLTextureParameters::set(const SamplerOverriddenState* samplerState,
51 const NonsamplerState& nonsamplerState,
52 ResetTimestamp currTimestamp) {
53 if (samplerState) {
54 fSamplerOverriddenState = *samplerState;
55 }
56 fNonsamplerState = nonsamplerState;
57 fResetTimestamp = currTimestamp;
58 }
59
GrGLTextureSpecToSurfaceInfo(const GrGLTextureSpec & glSpec,uint32_t sampleCount,uint32_t levelCount,GrProtected isProtected)60 GrGLSurfaceInfo GrGLTextureSpecToSurfaceInfo(const GrGLTextureSpec& glSpec,
61 uint32_t sampleCount,
62 uint32_t levelCount,
63 GrProtected isProtected) {
64 GrGLSurfaceInfo info;
65 // Shared info
66 info.fSampleCount = sampleCount;
67 info.fLevelCount = levelCount;
68 info.fProtected = isProtected;
69
70 // GL info
71 info.fTarget = glSpec.fTarget;
72 info.fFormat = glSpec.fFormat;
73
74 return info;
75 }
76