Skip to content

Commit c57aff1

Browse files
authored
Use the GrDirectContext factories instead of deprecated GrContext ones (flutter#19962)
This is part of a larger effort to expose the difference between GrDirectContext, which runs on the GPU thread and can directly perform operations like uploading textures, and GrRecordingContext, which can only queue up work to be delivered to the GrDirectContext later.
1 parent 2d8a00e commit c57aff1

File tree

116 files changed

+307
-283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+307
-283
lines changed

flow/compositor_context.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void CompositorContext::EndFrame(ScopedFrame& frame,
3131
}
3232

3333
std::unique_ptr<CompositorContext::ScopedFrame> CompositorContext::AcquireFrame(
34-
GrContext* gr_context,
34+
GrDirectContext* gr_context,
3535
SkCanvas* canvas,
3636
ExternalViewEmbedder* view_embedder,
3737
const SkMatrix& root_surface_transformation,
@@ -45,7 +45,7 @@ std::unique_ptr<CompositorContext::ScopedFrame> CompositorContext::AcquireFrame(
4545

4646
CompositorContext::ScopedFrame::ScopedFrame(
4747
CompositorContext& context,
48-
GrContext* gr_context,
48+
GrDirectContext* gr_context,
4949
SkCanvas* canvas,
5050
ExternalViewEmbedder* view_embedder,
5151
const SkMatrix& root_surface_transformation,

flow/compositor_context.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "flutter/fml/macros.h"
1616
#include "flutter/fml/raster_thread_merger.h"
1717
#include "third_party/skia/include/core/SkCanvas.h"
18-
#include "third_party/skia/include/gpu/GrContext.h"
18+
#include "third_party/skia/include/gpu/GrDirectContext.h"
1919

2020
namespace flutter {
2121

@@ -40,7 +40,7 @@ class CompositorContext {
4040
class ScopedFrame {
4141
public:
4242
ScopedFrame(CompositorContext& context,
43-
GrContext* gr_context,
43+
GrDirectContext* gr_context,
4444
SkCanvas* canvas,
4545
ExternalViewEmbedder* view_embedder,
4646
const SkMatrix& root_surface_transformation,
@@ -62,14 +62,14 @@ class CompositorContext {
6262

6363
bool surface_supports_readback() { return surface_supports_readback_; }
6464

65-
GrContext* gr_context() const { return gr_context_; }
65+
GrDirectContext* gr_context() const { return gr_context_; }
6666

6767
virtual RasterStatus Raster(LayerTree& layer_tree,
6868
bool ignore_raster_cache);
6969

7070
private:
7171
CompositorContext& context_;
72-
GrContext* gr_context_;
72+
GrDirectContext* gr_context_;
7373
SkCanvas* canvas_;
7474
ExternalViewEmbedder* view_embedder_;
7575
const SkMatrix& root_surface_transformation_;
@@ -85,7 +85,7 @@ class CompositorContext {
8585
virtual ~CompositorContext();
8686

8787
virtual std::unique_ptr<ScopedFrame> AcquireFrame(
88-
GrContext* gr_context,
88+
GrDirectContext* gr_context,
8989
SkCanvas* canvas,
9090
ExternalViewEmbedder* view_embedder,
9191
const SkMatrix& root_surface_transformation,

flow/embedded_views.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace flutter {
88

9-
void ExternalViewEmbedder::SubmitFrame(GrContext* context,
9+
void ExternalViewEmbedder::SubmitFrame(GrDirectContext* context,
1010
std::unique_ptr<SurfaceFrame> frame) {
1111
frame->Submit();
1212
};

flow/embedded_views.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class ExternalViewEmbedder {
268268

269269
virtual void BeginFrame(
270270
SkISize frame_size,
271-
GrContext* context,
271+
GrDirectContext* context,
272272
double device_pixel_ratio,
273273
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) = 0;
274274

@@ -295,7 +295,7 @@ class ExternalViewEmbedder {
295295
// This method can mutate the root Skia canvas before submitting the frame.
296296
//
297297
// It can also allocate frames for overlay surfaces to compose hybrid views.
298-
virtual void SubmitFrame(GrContext* context,
298+
virtual void SubmitFrame(GrDirectContext* context,
299299
std::unique_ptr<SurfaceFrame> frame);
300300

301301
// This method provides the embedder a way to do additional tasks after

flow/layers/layer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ enum Clip { none, hardEdge, antiAlias, antiAliasWithSaveLayer };
4444

4545
struct PrerollContext {
4646
RasterCache* raster_cache;
47-
GrContext* gr_context;
47+
GrDirectContext* gr_context;
4848
ExternalViewEmbedder* view_embedder;
4949
MutatorsStack& mutators_stack;
5050
SkColorSpace* dst_color_space;
@@ -121,7 +121,7 @@ class Layer {
121121
// layers.
122122
SkCanvas* internal_nodes_canvas;
123123
SkCanvas* leaf_nodes_canvas;
124-
GrContext* gr_context;
124+
GrDirectContext* gr_context;
125125
ExternalViewEmbedder* view_embedder;
126126
const Stopwatch& raster_time;
127127
const Stopwatch& ui_time;

flow/raster_cache.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "third_party/skia/include/core/SkImage.h"
1616
#include "third_party/skia/include/core/SkPicture.h"
1717
#include "third_party/skia/include/core/SkSurface.h"
18-
#include "third_party/skia/include/gpu/GrContext.h"
18+
#include "third_party/skia/include/gpu/GrDirectContext.h"
1919

2020
namespace flutter {
2121

@@ -89,7 +89,7 @@ static bool IsPictureWorthRasterizing(SkPicture* picture,
8989

9090
/// @note Procedure doesn't copy all closures.
9191
static std::unique_ptr<RasterCacheResult> Rasterize(
92-
GrContext* context,
92+
GrDirectContext* context,
9393
const SkMatrix& ctm,
9494
SkColorSpace* dst_color_space,
9595
bool checkerboard,
@@ -126,7 +126,7 @@ static std::unique_ptr<RasterCacheResult> Rasterize(
126126

127127
std::unique_ptr<RasterCacheResult> RasterCache::RasterizePicture(
128128
SkPicture* picture,
129-
GrContext* context,
129+
GrDirectContext* context,
130130
const SkMatrix& ctm,
131131
SkColorSpace* dst_color_space,
132132
bool checkerboard) const {
@@ -177,7 +177,7 @@ std::unique_ptr<RasterCacheResult> RasterCache::RasterizeLayer(
177177
});
178178
}
179179

180-
bool RasterCache::Prepare(GrContext* context,
180+
bool RasterCache::Prepare(GrDirectContext* context,
181181
SkPicture* picture,
182182
const SkMatrix& transformation_matrix,
183183
SkColorSpace* dst_color_space,

flow/raster_cache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class RasterCache {
7272
*/
7373
virtual std::unique_ptr<RasterCacheResult> RasterizePicture(
7474
SkPicture* picture,
75-
GrContext* context,
75+
GrDirectContext* context,
7676
const SkMatrix& ctm,
7777
SkColorSpace* dst_color_space,
7878
bool checkerboard) const;
@@ -134,7 +134,7 @@ class RasterCache {
134134
// 3. The picture is accessed too few times
135135
// 4. There are too many pictures to be cached in the current frame.
136136
// (See also kDefaultPictureCacheLimitPerFrame.)
137-
bool Prepare(GrContext* context,
137+
bool Prepare(GrDirectContext* context,
138138
SkPicture* picture,
139139
const SkMatrix& transformation_matrix,
140140
SkColorSpace* dst_color_space,

flow/scene_update_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class SceneUpdateContext : public flutter::ExternalViewEmbedder {
214214
// |ExternalViewEmbedder|
215215
void BeginFrame(
216216
SkISize frame_size,
217-
GrContext* context,
217+
GrDirectContext* context,
218218
double device_pixel_ratio,
219219
fml::RefPtr<fml::RasterThreadMerger> raster_thread_merger) override {}
220220

flow/skia_gpu_object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "flutter/fml/memory/weak_ptr.h"
1313
#include "flutter/fml/task_runner.h"
1414
#include "third_party/skia/include/core/SkRefCnt.h"
15-
#include "third_party/skia/include/gpu/GrContext.h"
15+
#include "third_party/skia/include/gpu/GrDirectContext.h"
1616

1717
namespace flutter {
1818

@@ -37,7 +37,7 @@ class SkiaUnrefQueue : public fml::RefCountedThreadSafe<SkiaUnrefQueue> {
3737
bool drain_pending_;
3838
fml::WeakPtr<GrContext> context_;
3939

40-
// The `GrContext* context` is only used for signaling Skia to
40+
// The `GrDirectContext* context` is only used for signaling Skia to
4141
// performDeferredCleanup. It can be nullptr when such signaling is not needed
4242
// (e.g., in unit tests).
4343
SkiaUnrefQueue(fml::RefPtr<fml::TaskRunner> task_runner,

flow/surface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Surface {
2727

2828
virtual SkMatrix GetRootTransformation() const = 0;
2929

30-
virtual GrContext* GetContext() = 0;
30+
virtual GrDirectContext* GetContext() = 0;
3131

3232
virtual flutter::ExternalViewEmbedder* GetExternalViewEmbedder();
3333

0 commit comments

Comments
 (0)