Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrTexture.h
Go to the documentation of this file.
1
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#ifndef GrTexture_DEFINED
10#define GrTexture_DEFINED
11
14#include "include/gpu/GrTypes.h"
18
19#include <cstddef>
20#include <string_view>
21
22class GrCaps;
23class GrGpu;
24struct SkISize;
25
26namespace skgpu {
27class ScratchKey;
28enum class Mipmapped : bool;
29} // namespace skgpu
30
31class GrTexture : virtual public GrSurface {
32public:
33 GrTexture* asTexture() override { return this; }
34 const GrTexture* asTexture() const override { return this; }
35
37
38 /**
39 * This function indicates that the texture parameters (wrap mode, filtering, ...) have been
40 * changed externally to Skia.
41 */
42 virtual void textureParamsModified() = 0;
43
44 /**
45 * This function steals the backend texture from a uniquely owned GrTexture with no pending
46 * IO, passing it out to the caller. The GrTexture is deleted in the process.
47 *
48 * Note that if the GrTexture is not uniquely owned (no other refs), or has pending IO, this
49 * function will fail.
50 */
54
55 GrTextureType textureType() const { return fTextureType; }
59
60 void markMipmapsDirty();
61 void markMipmapsClean();
63 return skgpu::Mipmapped(fMipmapStatus != GrMipmapStatus::kNotAllocated);
64 }
65 bool mipmapsAreDirty() const { return fMipmapStatus != GrMipmapStatus::kValid; }
66 GrMipmapStatus mipmapStatus() const { return fMipmapStatus; }
67 int maxMipmapLevel() const { return fMaxMipmapLevel; }
68
69 static void ComputeScratchKey(const GrCaps& caps,
73 int sampleCnt,
77
78protected:
80 const SkISize&,
84 std::string_view label);
85
87
88 void computeScratchKey(skgpu::ScratchKey*) const override;
89
90private:
91 size_t onGpuMemorySize() const override;
92
93 GrTextureType fTextureType;
94 GrMipmapStatus fMipmapStatus;
95 int fMaxMipmapLevel;
96 friend class GrTextureResource;
97
98 using INHERITED = GrSurface;
99};
100
101#endif
GrMipmapStatus
GrTextureType
static bool GrTextureTypeHasRestrictedSampling(GrTextureType type)
Definition GrGpu.h:62
SkISize dimensions() const
Definition GrSurface.h:27
size_t onGpuMemorySize() const override
Definition GrTexture.cpp:36
virtual GrBackendTexture getBackendTexture() const =0
int maxMipmapLevel() const
Definition GrTexture.h:67
void markMipmapsDirty()
Definition GrTexture.cpp:25
virtual void textureParamsModified()=0
void markMipmapsClean()
Definition GrTexture.cpp:31
skgpu::Mipmapped mipmapped() const
Definition GrTexture.h:62
GrMipmapStatus mipmapStatus() const
Definition GrTexture.h:66
virtual bool onStealBackendTexture(GrBackendTexture *, SkImages::BackendTextureReleaseProc *)=0
static bool StealBackendTexture(sk_sp< GrTexture >, GrBackendTexture *, SkImages::BackendTextureReleaseProc *)
Definition GrTexture.cpp:61
const GrTexture * asTexture() const override
Definition GrTexture.h:34
bool hasRestrictedSampling() const
Definition GrTexture.h:56
GrTextureType textureType() const
Definition GrTexture.h:55
static void ComputeScratchKey(const GrCaps &caps, const GrBackendFormat &format, SkISize dimensions, GrRenderable, int sampleCnt, skgpu::Mipmapped, GrProtected, skgpu::ScratchKey *key)
GrTexture * asTexture() override
Definition GrTexture.h:33
bool mipmapsAreDirty() const
Definition GrTexture.h:65
void computeScratchKey(skgpu::ScratchKey *) const override
Definition GrTexture.cpp:91
uint32_t uint32_t * format
std::function< void(GrBackendTexture)> BackendTextureReleaseProc
Renderable
Definition GpuTypes.h:69
Mipmapped
Definition GpuTypes.h:53
Protected
Definition GpuTypes.h:61