• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/gpu/ganesh/GrGLTypesPriv.h"
10 #include "src/gpu/Swizzle.h"
11 #include "src/gpu/ganesh/gl/GrGLDefines_impl.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 
assign(const GrGLBackendTextureInfo & that,bool thisIsValid)60 void GrGLBackendTextureInfo::assign(const GrGLBackendTextureInfo& that, bool thisIsValid) {
61     fInfo = that.fInfo;
62     SkSafeRef(that.fParams);
63     if (thisIsValid) {
64         SkSafeUnref(fParams);
65     }
66     fParams = that.fParams;
67 }
68 
cleanup()69 void GrGLBackendTextureInfo::cleanup() { SkSafeUnref(fParams); }
70 
GrGLTextureSpecToSurfaceInfo(const GrGLTextureSpec & glSpec,uint32_t sampleCount,uint32_t levelCount,GrProtected isProtected)71 GrGLSurfaceInfo GrGLTextureSpecToSurfaceInfo(const GrGLTextureSpec& glSpec,
72                                              uint32_t sampleCount,
73                                              uint32_t levelCount,
74                                              GrProtected isProtected) {
75     GrGLSurfaceInfo info;
76     // Shared info
77     info.fSampleCount = sampleCount;
78     info.fLevelCount = levelCount;
79     info.fProtected = isProtected;
80 
81     // GL info
82     info.fTarget = glSpec.fTarget;
83     info.fFormat = glSpec.fFormat;
84 
85     return info;
86 }
87