Flutter Engine
The Flutter Engine
third_party
skia
src
gpu
ganesh
GrDeferredUpload.h
Go to the documentation of this file.
1
/*
2
* Copyright 2017 Google Inc.
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 GrDeferredUpload_DEFINED
9
#define GrDeferredUpload_DEFINED
10
11
#include <functional>
12
#include "
include/gpu/GrTypes.h
"
13
#include "
include/private/gpu/ganesh/GrTypesPriv.h
"
14
#include "
src/gpu/AtlasTypes.h
"
15
16
class
GrTextureProxy
;
17
18
/**
19
* A word about deferred uploads and tokens: Ops should usually schedule their uploads to occur at
20
* the beginning of a frame whenever possible. These are called ASAP uploads. Of course, this
21
* requires that there are no draws that have yet to be flushed that rely on the old texture
22
* contents. In that case the ASAP upload would happen prior to the draw and therefore the draw
23
* would read the new (wrong) texture data. When this read-before-write data hazard exists they
24
* should schedule an inline upload.
25
*
26
* Ops, in conjunction with helpers such as GrDrawOpAtlas, use upload tokens to know what the most
27
* recent draw was that referenced a resource (or portion of a resource). Each draw is assigned a
28
* token. A resource (or portion thereof) can be tagged with the most recent reading draw's token.
29
* The deferred upload's target provides a facility for testing whether the draw corresponding to
30
* the token has been flushed. If it has not been flushed then the op must perform an inline upload
31
* instead so that the upload occurs after the draw depending on the old contents and before the
32
* draw depending on the updated contents. When scheduling an inline upload the op provides the
33
* token of the draw that the upload must occur before.
34
*/
35
36
/**
37
* Passed to a deferred upload when it is executed, this method allows the deferred upload to
38
* actually write its pixel data into a texture.
39
*/
40
using
GrDeferredTextureUploadWritePixelsFn
=
std::function
<bool(
GrTextureProxy
*,
41
SkIRect
,
42
GrColorType
srcColorType,
43
const
void
*,
44
size_t
rowBytes)>;
45
46
/**
47
* A deferred texture upload is simply a std::function that takes a
48
* GrDeferredTextureUploadWritePixelsFn as a parameter. It is called when it should perform its
49
* upload as the draw/upload sequence is executed.
50
*/
51
using
GrDeferredTextureUploadFn
=
std::function
<void(
GrDeferredTextureUploadWritePixelsFn
&)>;
52
53
/**
54
* An interface for scheduling deferred uploads. It accepts asap and deferred inline uploads.
55
*/
56
class
GrDeferredUploadTarget
{
57
public
:
58
virtual
~GrDeferredUploadTarget
() {}
59
60
virtual
const
skgpu::TokenTracker
*
tokenTracker
() = 0;
61
62
/** Returns the token of the draw that this upload will occur before. */
63
virtual
skgpu::AtlasToken
addInlineUpload
(
GrDeferredTextureUploadFn
&&) = 0;
64
65
/** Returns the token of the draw that this upload will occur before. Since ASAP uploads
66
are done first during a flush, this will be the first token since the most recent
67
flush. */
68
virtual
skgpu::AtlasToken
addASAPUpload
(
GrDeferredTextureUploadFn
&&
upload
) = 0;
69
};
70
71
#endif
AtlasTypes.h
GrDeferredTextureUploadFn
std::function< void(GrDeferredTextureUploadWritePixelsFn &)> GrDeferredTextureUploadFn
Definition:
GrDeferredUpload.h:51
GrDeferredTextureUploadWritePixelsFn
std::function< bool(GrTextureProxy *, SkIRect, GrColorType srcColorType, const void *, size_t rowBytes)> GrDeferredTextureUploadWritePixelsFn
Definition:
GrDeferredUpload.h:44
GrTypesPriv.h
GrColorType
GrColorType
Definition:
GrTypesPriv.h:540
GrTypes.h
GrDeferredUploadTarget
Definition:
GrDeferredUpload.h:56
GrDeferredUploadTarget::tokenTracker
virtual const skgpu::TokenTracker * tokenTracker()=0
GrDeferredUploadTarget::addASAPUpload
virtual skgpu::AtlasToken addASAPUpload(GrDeferredTextureUploadFn &&upload)=0
GrDeferredUploadTarget::~GrDeferredUploadTarget
virtual ~GrDeferredUploadTarget()
Definition:
GrDeferredUpload.h:58
GrDeferredUploadTarget::addInlineUpload
virtual skgpu::AtlasToken addInlineUpload(GrDeferredTextureUploadFn &&)=0
GrTextureProxy
Definition:
GrTextureProxy.h:34
skgpu::AtlasToken
Definition:
AtlasTypes.h:151
skgpu::TokenTracker
Definition:
AtlasTypes.h:201
function
Dart_NativeFunction function
Definition:
fuchsia.cc:51
upload
Definition:
upload.py:1
SkIRect
Definition:
SkRect.h:32
Generated on Sun Jun 23 2024 21:56:20 for Flutter Engine by
1.9.4