Flutter Engine
The Flutter Engine
third_party
skia
include
private
gpu
ganesh
GrTextureGenerator.h
Go to the documentation of this file.
1
/*
2
* Copyright 2023 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
#ifndef GrTextureGenerator_DEFINED
9
#define GrTextureGenerator_DEFINED
10
11
#include "
include/core/SkImageGenerator.h
"
12
#include "
include/gpu/GrTypes.h
"
13
#include "
include/private/base/SkAPI.h
"
14
15
#include <cstdint>
16
17
class
GrRecordingContext
;
18
class
GrSurfaceProxyView
;
19
enum class
GrImageTexGenPolicy
:
int
;
20
namespace
skgpu
{
enum class
Mipmapped
: bool; }
21
struct
SkImageInfo
;
22
23
class
SK_API
GrTextureGenerator
:
public
SkImageGenerator
{
24
public
:
25
bool
isTextureGenerator
() const final {
return
true
; }
26
27
/**
28
* If the generator can natively/efficiently return its pixels as a GPU image (backed by a
29
* texture) this will return that image. If not, this will return NULL.
30
*
31
* Regarding the GrRecordingContext parameter:
32
*
33
* It must be non-NULL. The generator should only succeed if:
34
* - its internal context is the same
35
* - it can somehow convert its texture into one that is valid for the provided context.
36
*
37
* If the mipmapped parameter is kYes, the generator should try to create a TextureProxy that
38
* at least has the mip levels allocated and the base layer filled in. If this is not possible,
39
* the generator is allowed to return a non mipped proxy, but this will have some additional
40
* overhead in later allocating mips and copying of the base layer.
41
*
42
* GrImageTexGenPolicy determines whether or not a new texture must be created (and its budget
43
* status) or whether this may (but is not required to) return a pre-existing texture that is
44
* retained by the generator (kDraw).
45
*/
46
GrSurfaceProxyView
generateTexture(
GrRecordingContext
*,
47
const
SkImageInfo
&
info
,
48
skgpu::Mipmapped
mipmapped,
49
GrImageTexGenPolicy
);
50
51
// External clients should override GrExternalTextureGenerator instead of trying to implement
52
// this (which uses private Skia types)
53
virtual
GrSurfaceProxyView
onGenerateTexture
(
GrRecordingContext
*,
const
SkImageInfo
&,
54
skgpu::Mipmapped
,
GrImageTexGenPolicy
) = 0;
55
56
// Most internal SkImageGenerators produce textures and views that use kTopLeft_GrSurfaceOrigin.
57
// If the generator may produce textures with different origins (e.g.
58
// GrAHardwareBufferImageGenerator) it should override this function to return the correct
59
// origin. Implementations should be thread-safe.
60
virtual
GrSurfaceOrigin
origin
()
const
{
return
kTopLeft_GrSurfaceOrigin
; }
61
62
protected
:
63
GrTextureGenerator
(
const
SkImageInfo
&
info
, uint32_t uniqueId =
kNeedNewImageUniqueID
);
64
};
65
66
#endif
// GrTextureGenerator_DEFINED
info
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition:
DM.cpp:213
GrTypes.h
GrSurfaceOrigin
GrSurfaceOrigin
Definition:
GrTypes.h:147
kTopLeft_GrSurfaceOrigin
@ kTopLeft_GrSurfaceOrigin
Definition:
GrTypes.h:148
SkAPI.h
SK_API
#define SK_API
Definition:
SkAPI.h:35
GrImageTexGenPolicy
GrImageTexGenPolicy
Definition:
SkGr.h:141
SkImageGenerator.h
kNeedNewImageUniqueID
@ kNeedNewImageUniqueID
Definition:
SkImage_Base.h:33
GrRecordingContext
Definition:
GrRecordingContext.h:42
GrSurfaceProxyView
Definition:
GrSurfaceProxyView.h:34
GrTextureGenerator
Definition:
GrTextureGenerator.h:23
GrTextureGenerator::origin
virtual GrSurfaceOrigin origin() const
Definition:
GrTextureGenerator.h:60
GrTextureGenerator::isTextureGenerator
bool isTextureGenerator() const final
Definition:
GrTextureGenerator.h:25
GrTextureGenerator::onGenerateTexture
virtual GrSurfaceProxyView onGenerateTexture(GrRecordingContext *, const SkImageInfo &, skgpu::Mipmapped, GrImageTexGenPolicy)=0
SkImageGenerator
Definition:
SkImageGenerator.h:28
skgpu
Definition:
GpuTools.h:21
skgpu::Mipmapped
Mipmapped
Definition:
GpuTypes.h:53
tools.skpbench.skpbench.int
int
Definition:
skpbench.py:49
SkImageInfo
Definition:
SkImageInfo.h:208
Generated on Sun Jun 23 2024 21:56:03 for Flutter Engine by
1.9.4