Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrGLTypesPriv.h
Go to the documentation of this file.
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
10
11#ifndef GrGLTypesPriv_DEFINED
12#define GrGLTypesPriv_DEFINED
13
14static constexpr int kGrGLColorFormatCount = static_cast<int>(GrGLFormat::kLastColorFormat) + 1;
15
16class GrGLTextureParameters : public SkNVRefCnt<GrGLTextureParameters> {
17public:
18 // We currently consider texture parameters invalid on all textures
19 // GrContext::resetContext(). We use this type to track whether instances of
20 // GrGLTextureParameters were updated before or after the most recent resetContext(). At 10
21 // resets / frame and 60fps a 64bit timestamp will overflow in about a billion years.
22 // TODO: Require clients to use GrBackendTexture::glTextureParametersModified() to invalidate
23 // texture parameters and get rid of timestamp checking.
24 using ResetTimestamp = uint64_t;
25
26 // This initializes the params to have an expired timestamp. They'll be considered invalid the
27 // first time the texture is used unless set() is called.
29
30 // This is texture parameter state that is overridden when a non-zero sampler object is bound.
33 void invalidate();
34
42 // We always want the border color to be transparent black, so no need to store 4 floats.
43 // Just track if it's been invalidated and no longer the default
45 };
46
47 // Texture parameter state that is not overridden by a bound sampler object.
56
57 void invalidate();
58
59 ResetTimestamp resetTimestamp() const { return fResetTimestamp; }
60 const SamplerOverriddenState& samplerOverriddenState() const { return fSamplerOverriddenState; }
61 const NonsamplerState& nonsamplerState() const { return fNonsamplerState; }
62
63 // SamplerOverriddenState is optional because we don't track it when we're using sampler
64 // objects.
65 void set(const SamplerOverriddenState* samplerState,
66 const NonsamplerState& nonsamplerState,
67 ResetTimestamp currTimestamp);
68
69private:
70 static constexpr ResetTimestamp kExpiredTimestamp = 0;
71
72 SamplerOverriddenState fSamplerOverriddenState;
73 NonsamplerState fNonsamplerState;
74 ResetTimestamp fResetTimestamp = kExpiredTimestamp;
75};
76
78public:
81 const GrGLTextureInfo& info() const { return fInfo; }
82 GrGLTextureParameters* parameters() const { return fParams.get(); }
83 sk_sp<GrGLTextureParameters> refParameters() const { return fParams; }
84
85 bool isProtected() const { return fInfo.isProtected(); }
86
87private:
88 GrGLTextureInfo fInfo;
89 sk_sp<GrGLTextureParameters> fParams; // not const because we might call invalidate() on it.
90};
91
99
101 uint32_t sampleCount,
102 uint32_t levelCount,
103 skgpu::Protected isProtected);
104
105#endif
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
GrGLSurfaceInfo GrGLTextureSpecToSurfaceInfo(const GrGLTextureSpec &glSpec, uint32_t sampleCount, uint32_t levelCount, skgpu::Protected isProtected)
static constexpr int kGrGLColorFormatCount
float GrGLfloat
Definition GrGLTypes.h:116
int GrGLint
Definition GrGLTypes.h:108
unsigned int GrGLenum
Definition GrGLTypes.h:102
const GrGLTextureInfo & info() const
sk_sp< GrGLTextureParameters > refParameters() const
GrGLBackendTextureInfo(const GrGLTextureInfo &info, sk_sp< GrGLTextureParameters > params)
GrGLTextureParameters * parameters() const
ResetTimestamp resetTimestamp() const
GrGLTextureParameters()=default
const SamplerOverriddenState & samplerOverriddenState() const
const NonsamplerState & nonsamplerState() const
T * get() const
Definition SkRefCnt.h:303
const EmbeddedViewParams * params
Protected
Definition GpuTypes.h:61
Definition ref_ptr.h:256
bool isProtected() const
Definition GrGLTypes.h:193
GrGLTextureSpec(const GrGLSurfaceInfo &info)