diff --git a/flow/compositor_context.cc b/flow/compositor_context.cc index e94ffd53f53d7..ddf9f1c698893 100644 --- a/flow/compositor_context.cc +++ b/flow/compositor_context.cc @@ -31,7 +31,7 @@ void CompositorContext::EndFrame(ScopedFrame& frame, } std::unique_ptr CompositorContext::AcquireFrame( - GrContext* gr_context, + GrDirectContext* gr_context, SkCanvas* canvas, ExternalViewEmbedder* view_embedder, const SkMatrix& root_surface_transformation, @@ -45,7 +45,7 @@ std::unique_ptr CompositorContext::AcquireFrame( CompositorContext::ScopedFrame::ScopedFrame( CompositorContext& context, - GrContext* gr_context, + GrDirectContext* gr_context, SkCanvas* canvas, ExternalViewEmbedder* view_embedder, const SkMatrix& root_surface_transformation, diff --git a/flow/compositor_context.h b/flow/compositor_context.h index e3c786d156126..47992abda6028 100644 --- a/flow/compositor_context.h +++ b/flow/compositor_context.h @@ -15,7 +15,7 @@ #include "flutter/fml/macros.h" #include "flutter/fml/raster_thread_merger.h" #include "third_party/skia/include/core/SkCanvas.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -40,7 +40,7 @@ class CompositorContext { class ScopedFrame { public: ScopedFrame(CompositorContext& context, - GrContext* gr_context, + GrDirectContext* gr_context, SkCanvas* canvas, ExternalViewEmbedder* view_embedder, const SkMatrix& root_surface_transformation, @@ -62,14 +62,14 @@ class CompositorContext { bool surface_supports_readback() { return surface_supports_readback_; } - GrContext* gr_context() const { return gr_context_; } + GrDirectContext* gr_context() const { return gr_context_; } virtual RasterStatus Raster(LayerTree& layer_tree, bool ignore_raster_cache); private: CompositorContext& context_; - GrContext* gr_context_; + GrDirectContext* gr_context_; SkCanvas* canvas_; ExternalViewEmbedder* view_embedder_; const SkMatrix& root_surface_transformation_; @@ -85,7 +85,7 @@ class CompositorContext { virtual ~CompositorContext(); virtual std::unique_ptr AcquireFrame( - GrContext* gr_context, + GrDirectContext* gr_context, SkCanvas* canvas, ExternalViewEmbedder* view_embedder, const SkMatrix& root_surface_transformation, diff --git a/flow/embedded_views.cc b/flow/embedded_views.cc index e363b0674a61f..07a484999ff51 100644 --- a/flow/embedded_views.cc +++ b/flow/embedded_views.cc @@ -6,7 +6,7 @@ namespace flutter { -void ExternalViewEmbedder::SubmitFrame(GrContext* context, +void ExternalViewEmbedder::SubmitFrame(GrDirectContext* context, std::unique_ptr frame) { frame->Submit(); }; diff --git a/flow/embedded_views.h b/flow/embedded_views.h index 554f872e99dc5..455eb91511801 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -268,7 +268,7 @@ class ExternalViewEmbedder { virtual void BeginFrame( SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) = 0; @@ -295,7 +295,7 @@ class ExternalViewEmbedder { // This method can mutate the root Skia canvas before submitting the frame. // // It can also allocate frames for overlay surfaces to compose hybrid views. - virtual void SubmitFrame(GrContext* context, + virtual void SubmitFrame(GrDirectContext* context, std::unique_ptr frame); // This method provides the embedder a way to do additional tasks after diff --git a/flow/layers/layer.h b/flow/layers/layer.h index 4986ac1f3af77..b22a322a73422 100644 --- a/flow/layers/layer.h +++ b/flow/layers/layer.h @@ -44,7 +44,7 @@ enum Clip { none, hardEdge, antiAlias, antiAliasWithSaveLayer }; struct PrerollContext { RasterCache* raster_cache; - GrContext* gr_context; + GrDirectContext* gr_context; ExternalViewEmbedder* view_embedder; MutatorsStack& mutators_stack; SkColorSpace* dst_color_space; @@ -121,7 +121,7 @@ class Layer { // layers. SkCanvas* internal_nodes_canvas; SkCanvas* leaf_nodes_canvas; - GrContext* gr_context; + GrDirectContext* gr_context; ExternalViewEmbedder* view_embedder; const Stopwatch& raster_time; const Stopwatch& ui_time; diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index 22368dccfb98d..c9fcad4a34b49 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -15,7 +15,7 @@ #include "third_party/skia/include/core/SkImage.h" #include "third_party/skia/include/core/SkPicture.h" #include "third_party/skia/include/core/SkSurface.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -89,7 +89,7 @@ static bool IsPictureWorthRasterizing(SkPicture* picture, /// @note Procedure doesn't copy all closures. static std::unique_ptr Rasterize( - GrContext* context, + GrDirectContext* context, const SkMatrix& ctm, SkColorSpace* dst_color_space, bool checkerboard, @@ -126,7 +126,7 @@ static std::unique_ptr Rasterize( std::unique_ptr RasterCache::RasterizePicture( SkPicture* picture, - GrContext* context, + GrDirectContext* context, const SkMatrix& ctm, SkColorSpace* dst_color_space, bool checkerboard) const { @@ -177,7 +177,7 @@ std::unique_ptr RasterCache::RasterizeLayer( }); } -bool RasterCache::Prepare(GrContext* context, +bool RasterCache::Prepare(GrDirectContext* context, SkPicture* picture, const SkMatrix& transformation_matrix, SkColorSpace* dst_color_space, diff --git a/flow/raster_cache.h b/flow/raster_cache.h index f7b1467fc12c9..d71b4e2ff9aed 100644 --- a/flow/raster_cache.h +++ b/flow/raster_cache.h @@ -72,7 +72,7 @@ class RasterCache { */ virtual std::unique_ptr RasterizePicture( SkPicture* picture, - GrContext* context, + GrDirectContext* context, const SkMatrix& ctm, SkColorSpace* dst_color_space, bool checkerboard) const; @@ -134,7 +134,7 @@ class RasterCache { // 3. The picture is accessed too few times // 4. There are too many pictures to be cached in the current frame. // (See also kDefaultPictureCacheLimitPerFrame.) - bool Prepare(GrContext* context, + bool Prepare(GrDirectContext* context, SkPicture* picture, const SkMatrix& transformation_matrix, SkColorSpace* dst_color_space, diff --git a/flow/scene_update_context.h b/flow/scene_update_context.h index 0e504610c9166..3b46fb2247f3c 100644 --- a/flow/scene_update_context.h +++ b/flow/scene_update_context.h @@ -214,7 +214,7 @@ class SceneUpdateContext : public flutter::ExternalViewEmbedder { // |ExternalViewEmbedder| void BeginFrame( SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) override {} diff --git a/flow/skia_gpu_object.h b/flow/skia_gpu_object.h index f2d10c2c674cf..ef7cb596f1a36 100644 --- a/flow/skia_gpu_object.h +++ b/flow/skia_gpu_object.h @@ -12,7 +12,7 @@ #include "flutter/fml/memory/weak_ptr.h" #include "flutter/fml/task_runner.h" #include "third_party/skia/include/core/SkRefCnt.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -37,7 +37,7 @@ class SkiaUnrefQueue : public fml::RefCountedThreadSafe { bool drain_pending_; fml::WeakPtr context_; - // The `GrContext* context` is only used for signaling Skia to + // The `GrDirectContext* context` is only used for signaling Skia to // performDeferredCleanup. It can be nullptr when such signaling is not needed // (e.g., in unit tests). SkiaUnrefQueue(fml::RefPtr task_runner, diff --git a/flow/surface.h b/flow/surface.h index 0396bb5294c5e..3009af6507d33 100644 --- a/flow/surface.h +++ b/flow/surface.h @@ -27,7 +27,7 @@ class Surface { virtual SkMatrix GetRootTransformation() const = 0; - virtual GrContext* GetContext() = 0; + virtual GrDirectContext* GetContext() = 0; virtual flutter::ExternalViewEmbedder* GetExternalViewEmbedder(); diff --git a/flow/testing/mock_raster_cache.cc b/flow/testing/mock_raster_cache.cc index 30c96e5bc8f49..8fde780ad6e4d 100644 --- a/flow/testing/mock_raster_cache.cc +++ b/flow/testing/mock_raster_cache.cc @@ -15,7 +15,7 @@ MockRasterCacheResult::MockRasterCacheResult(SkIRect device_rect) std::unique_ptr MockRasterCache::RasterizePicture( SkPicture* picture, - GrContext* context, + GrDirectContext* context, const SkMatrix& ctm, SkColorSpace* dst_color_space, bool checkerboard) const { diff --git a/flow/testing/mock_raster_cache.h b/flow/testing/mock_raster_cache.h index 72f00bb51fd54..795963994f230 100644 --- a/flow/testing/mock_raster_cache.h +++ b/flow/testing/mock_raster_cache.h @@ -46,7 +46,7 @@ class MockRasterCache : public RasterCache { public: std::unique_ptr RasterizePicture( SkPicture* picture, - GrContext* context, + GrDirectContext* context, const SkMatrix& ctm, SkColorSpace* dst_color_space, bool checkerboard) const override; diff --git a/flow/testing/mock_texture.cc b/flow/testing/mock_texture.cc index ee032355d2fff..fddb6e8586f5c 100644 --- a/flow/testing/mock_texture.cc +++ b/flow/testing/mock_texture.cc @@ -12,7 +12,7 @@ MockTexture::MockTexture(int64_t textureId) : Texture(textureId) {} void MockTexture::Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) { paint_calls_.emplace_back( PaintCall{canvas, bounds, freeze, context, filter_quality}); diff --git a/flow/testing/mock_texture.h b/flow/testing/mock_texture.h index d03907525feb0..8d3aa57e0d25a 100644 --- a/flow/testing/mock_texture.h +++ b/flow/testing/mock_texture.h @@ -20,7 +20,7 @@ class MockTexture : public Texture { SkCanvas& canvas; SkRect bounds; bool freeze; - GrContext* context; + GrDirectContext* context; SkFilterQuality filter_quality; }; @@ -30,7 +30,7 @@ class MockTexture : public Texture { void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) override; void OnGrContextCreated() override { gr_context_created_ = true; } diff --git a/flow/texture.h b/flow/texture.h index ef963bf70f732..dd136942d36ec 100644 --- a/flow/texture.h +++ b/flow/texture.h @@ -11,6 +11,8 @@ #include "flutter/fml/synchronization/waitable_event.h" #include "third_party/skia/include/core/SkCanvas.h" +class GrDirectContext; + namespace flutter { class Texture { @@ -22,7 +24,7 @@ class Texture { virtual void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality quality) = 0; // Called from raster thread. diff --git a/lib/ui/io_manager.h b/lib/ui/io_manager.h index dfcee970c745b..f799a841bfa4f 100644 --- a/lib/ui/io_manager.h +++ b/lib/ui/io_manager.h @@ -8,19 +8,19 @@ #include "flutter/flow/skia_gpu_object.h" #include "flutter/fml/memory/weak_ptr.h" #include "flutter/fml/synchronization/sync_switch.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { -// Interface for methods that manage access to the resource GrContext and Skia -// unref queue. Meant to be implemented by the owner of the resource GrContext, -// i.e. the shell's IOManager. +// Interface for methods that manage access to the resource GrDirectContext and +// Skia unref queue. Meant to be implemented by the owner of the resource +// GrDirectContext, i.e. the shell's IOManager. class IOManager { public: virtual ~IOManager() = default; virtual fml::WeakPtr GetWeakIOManager() const = 0; - virtual fml::WeakPtr GetResourceContext() const = 0; + virtual fml::WeakPtr GetResourceContext() const = 0; virtual fml::RefPtr GetSkiaUnrefQueue() const = 0; diff --git a/lib/ui/painting/image_decoder_unittests.cc b/lib/ui/painting/image_decoder_unittests.cc index aec75adf322ef..87c62857f24cd 100644 --- a/lib/ui/painting/image_decoder_unittests.cc +++ b/lib/ui/painting/image_decoder_unittests.cc @@ -28,9 +28,10 @@ class TestIOManager final : public IOManager { : gl_surface_(SkISize::Make(1, 1)), gl_context_(has_gpu_context ? gl_surface_.CreateGrContext() : nullptr), weak_gl_context_factory_( - has_gpu_context ? std::make_unique>( - gl_context_.get()) - : nullptr), + has_gpu_context + ? std::make_unique>( + gl_context_.get()) + : nullptr), unref_queue_(fml::MakeRefCounted( task_runner, fml::TimeDelta::FromNanoseconds(0))), @@ -59,9 +60,9 @@ class TestIOManager final : public IOManager { } // |IOManager| - fml::WeakPtr GetResourceContext() const override { + fml::WeakPtr GetResourceContext() const override { return weak_gl_context_factory_ ? weak_gl_context_factory_->GetWeakPtr() - : fml::WeakPtr{}; + : fml::WeakPtr{}; } // |IOManager| @@ -79,8 +80,9 @@ class TestIOManager final : public IOManager { private: TestGLSurface gl_surface_; - sk_sp gl_context_; - std::unique_ptr> weak_gl_context_factory_; + sk_sp gl_context_; + std::unique_ptr> + weak_gl_context_factory_; fml::RefPtr unref_queue_; fml::WeakPtr weak_prototype_; fml::RefPtr runner_; diff --git a/lib/ui/painting/image_encoding.cc b/lib/ui/painting/image_encoding.cc index e54a12711c24b..963e92b28c07e 100644 --- a/lib/ui/painting/image_encoding.cc +++ b/lib/ui/painting/image_encoding.cc @@ -54,7 +54,7 @@ void InvokeDataCallback(std::unique_ptr callback, sk_sp ConvertToRasterUsingResourceContext( sk_sp image, - GrContext* resource_context) { + GrDirectContext* resource_context) { sk_sp surface; SkImageInfo surface_info = SkImageInfo::MakeN32Premul(image->dimensions()); if (resource_context) { @@ -86,7 +86,7 @@ void ConvertImageToRaster(sk_sp image, std::function)> encode_task, fml::RefPtr raster_task_runner, fml::RefPtr io_task_runner, - GrContext* resource_context, + GrDirectContext* resource_context, fml::WeakPtr snapshot_delegate) { // Check validity of the image. if (image == nullptr) { @@ -213,7 +213,7 @@ void EncodeImageAndInvokeDataCallback( fml::RefPtr ui_task_runner, fml::RefPtr raster_task_runner, fml::RefPtr io_task_runner, - GrContext* resource_context, + GrDirectContext* resource_context, fml::WeakPtr snapshot_delegate) { auto callback_task = fml::MakeCopyable( [callback = std::move(callback)](sk_sp encoded) mutable { diff --git a/lib/ui/ui_dart_state.h b/lib/ui/ui_dart_state.h index 2fdedc8094963..fd21146d24dd4 100644 --- a/lib/ui/ui_dart_state.h +++ b/lib/ui/ui_dart_state.h @@ -20,7 +20,7 @@ #include "flutter/lib/ui/painting/image_decoder.h" #include "flutter/lib/ui/snapshot_delegate.h" #include "third_party/dart/runtime/include/dart_api.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/tonic/dart_microtask_queue.h" #include "third_party/tonic/dart_persistent_value.h" #include "third_party/tonic/dart_state.h" diff --git a/lib/ui/window/window.h b/lib/ui/window/window.h index 95055c70beddb..1e68b09d8095a 100644 --- a/lib/ui/window/window.h +++ b/lib/ui/window/window.h @@ -14,7 +14,7 @@ #include "flutter/lib/ui/window/platform_message.h" #include "flutter/lib/ui/window/pointer_data_packet.h" #include "flutter/lib/ui/window/viewport_metrics.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/tonic/dart_persistent_value.h" namespace tonic { diff --git a/shell/common/platform_view.cc b/shell/common/platform_view.cc index 72b31d67efd23..221697c3d8c4e 100644 --- a/shell/common/platform_view.cc +++ b/shell/common/platform_view.cc @@ -82,7 +82,7 @@ void PlatformView::NotifyDestroyed() { delegate_.OnPlatformViewDestroyed(); } -sk_sp PlatformView::CreateResourceContext() const { +sk_sp PlatformView::CreateResourceContext() const { FML_DLOG(WARNING) << "This platform does not setup the resource " "context on the IO thread for async texture uploads."; return nullptr; diff --git a/shell/common/platform_view.h b/shell/common/platform_view.h index 5596a01e59230..5b376878ee208 100644 --- a/shell/common/platform_view.h +++ b/shell/common/platform_view.h @@ -21,7 +21,7 @@ #include "flutter/shell/common/pointer_data_dispatcher.h" #include "flutter/shell/common/vsync_waiter.h" #include "third_party/skia/include/core/SkSize.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -427,7 +427,7 @@ class PlatformView { /// main render thread GPU context. May be `nullptr` in case such /// a context cannot be created. /// - virtual sk_sp CreateResourceContext() const; + virtual sk_sp CreateResourceContext() const; //---------------------------------------------------------------------------- /// @brief Used by the shell to notify the embedder that the resource diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index e25a94af41f1a..d43867876fd87 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -488,7 +488,7 @@ static sk_sp ScreenshotLayerTreeAsPicture( return recorder.finishRecordingAsPicture()->serialize(&procs); } -static sk_sp CreateSnapshotSurface(GrContext* surface_context, +static sk_sp CreateSnapshotSurface(GrDirectContext* surface_context, const SkISize& size) { const auto image_info = SkImageInfo::MakeN32Premul( size.width(), size.height(), SkColorSpace::MakeSRGB()); @@ -509,7 +509,7 @@ static sk_sp CreateSnapshotSurface(GrContext* surface_context, sk_sp Rasterizer::ScreenshotLayerTreeAsImage( flutter::LayerTree* tree, flutter::CompositorContext& compositor_context, - GrContext* surface_context, + GrDirectContext* surface_context, bool compressed) { // Attempt to create a snapshot surface depending on whether we have access to // a valid GPU rendering context. @@ -589,7 +589,8 @@ Rasterizer::Screenshot Rasterizer::ScreenshotLastLayerTree( sk_sp data = nullptr; - GrContext* surface_context = surface_ ? surface_->GetContext() : nullptr; + GrDirectContext* surface_context = + surface_ ? surface_->GetContext() : nullptr; switch (type) { case ScreenshotType::SkiaPicture: @@ -648,7 +649,7 @@ void Rasterizer::SetResourceCacheMaxBytes(size_t max_bytes, bool from_user) { return; } - GrContext* context = surface_->GetContext(); + GrDirectContext* context = surface_->GetContext(); if (context) { int max_resources; context->getResourceCacheLimits(&max_resources, nullptr); @@ -660,7 +661,7 @@ std::optional Rasterizer::GetResourceCacheMaxBytes() const { if (!surface_) { return std::nullopt; } - GrContext* context = surface_->GetContext(); + GrDirectContext* context = surface_->GetContext(); if (context) { size_t max_bytes; context->getResourceCacheLimits(nullptr, &max_bytes); diff --git a/shell/common/rasterizer.h b/shell/common/rasterizer.h index c436c3bda91e5..68701d0c0a75b 100644 --- a/shell/common/rasterizer.h +++ b/shell/common/rasterizer.h @@ -458,7 +458,7 @@ class Rasterizer final : public SnapshotDelegate { sk_sp ScreenshotLayerTreeAsImage( flutter::LayerTree* tree, flutter::CompositorContext& compositor_context, - GrContext* surface_context, + GrDirectContext* surface_context, bool compressed); sk_sp DoMakeRasterSnapshot( diff --git a/shell/common/shell_io_manager.cc b/shell/common/shell_io_manager.cc index 97badd40bb25b..3025c5c3c6d89 100644 --- a/shell/common/shell_io_manager.cc +++ b/shell/common/shell_io_manager.cc @@ -11,7 +11,7 @@ namespace flutter { -sk_sp ShellIOManager::CreateCompatibleResourceLoadingContext( +sk_sp ShellIOManager::CreateCompatibleResourceLoadingContext( GrBackend backend, sk_sp gl_interface) { if (backend != GrBackend::kOpenGL_GrBackend) { @@ -40,7 +40,7 @@ sk_sp ShellIOManager::CreateCompatibleResourceLoadingContext( options.fPreferExternalImagesOverES3 = true; #if !OS_FUCHSIA - if (auto context = GrContext::MakeGL(gl_interface, options)) { + if (auto context = GrDirectContext::MakeGL(gl_interface, options)) { // Do not cache textures created by the image decoder. These textures // should be deleted when they are no longer referenced by an SkImage. context->setResourceCacheLimits(0, 0); @@ -52,14 +52,15 @@ sk_sp ShellIOManager::CreateCompatibleResourceLoadingContext( } ShellIOManager::ShellIOManager( - sk_sp resource_context, + sk_sp resource_context, std::shared_ptr is_gpu_disabled_sync_switch, fml::RefPtr unref_queue_task_runner) : resource_context_(std::move(resource_context)), resource_context_weak_factory_( - resource_context_ ? std::make_unique>( - resource_context_.get()) - : nullptr), + resource_context_ + ? std::make_unique>( + resource_context_.get()) + : nullptr), unref_queue_(fml::MakeRefCounted( std::move(unref_queue_task_runner), fml::TimeDelta::FromMilliseconds(8), @@ -83,7 +84,7 @@ ShellIOManager::~ShellIOManager() { } void ShellIOManager::NotifyResourceContextAvailable( - sk_sp resource_context) { + sk_sp resource_context) { // The resource context needs to survive as long as we have Dart objects // referencing. We shouldn't ever need to replace it if we have one - unless // we've somehow shut down the Dart VM and started a new one fresh. @@ -92,12 +93,14 @@ void ShellIOManager::NotifyResourceContextAvailable( } } -void ShellIOManager::UpdateResourceContext(sk_sp resource_context) { +void ShellIOManager::UpdateResourceContext( + sk_sp resource_context) { resource_context_ = std::move(resource_context); resource_context_weak_factory_ = - resource_context_ ? std::make_unique>( - resource_context_.get()) - : nullptr; + resource_context_ + ? std::make_unique>( + resource_context_.get()) + : nullptr; } fml::WeakPtr ShellIOManager::GetWeakPtr() { @@ -105,10 +108,10 @@ fml::WeakPtr ShellIOManager::GetWeakPtr() { } // |IOManager| -fml::WeakPtr ShellIOManager::GetResourceContext() const { +fml::WeakPtr ShellIOManager::GetResourceContext() const { return resource_context_weak_factory_ ? resource_context_weak_factory_->GetWeakPtr() - : fml::WeakPtr(); + : fml::WeakPtr(); } // |IOManager| diff --git a/shell/common/shell_io_manager.h b/shell/common/shell_io_manager.h index c50529fda7553..e164183a4c378 100644 --- a/shell/common/shell_io_manager.h +++ b/shell/common/shell_io_manager.h @@ -11,20 +11,20 @@ #include "flutter/fml/macros.h" #include "flutter/fml/memory/weak_ptr.h" #include "flutter/lib/ui/io_manager.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { class ShellIOManager final : public IOManager { public: - // Convenience methods for platforms to create a GrContext used to supply to - // the IOManager. The platforms may create the context themselves if they so - // desire. - static sk_sp CreateCompatibleResourceLoadingContext( + // Convenience methods for platforms to create a GrDirectContext used to + // supply to the IOManager. The platforms may create the context themselves if + // they so desire. + static sk_sp CreateCompatibleResourceLoadingContext( GrBackend backend, sk_sp gl_interface); - ShellIOManager(sk_sp resource_context, + ShellIOManager(sk_sp resource_context, std::shared_ptr is_gpu_disabled_sync_switch, fml::RefPtr unref_queue_task_runner); @@ -33,13 +33,13 @@ class ShellIOManager final : public IOManager { // This method should be called when a resource_context first becomes // available. It is safe to call multiple times, and will only update // the held resource context if it has not already been set. - void NotifyResourceContextAvailable(sk_sp resource_context); + void NotifyResourceContextAvailable(sk_sp resource_context); // This method should be called if you want to force the IOManager to // update its resource context reference. It should not be called // if there are any Dart objects that have a reference to the old // resource context, but may be called if the Dart VM is restarted. - void UpdateResourceContext(sk_sp resource_context); + void UpdateResourceContext(sk_sp resource_context); fml::WeakPtr GetWeakPtr(); @@ -47,7 +47,7 @@ class ShellIOManager final : public IOManager { fml::WeakPtr GetWeakIOManager() const override; // |IOManager| - fml::WeakPtr GetResourceContext() const override; + fml::WeakPtr GetResourceContext() const override; // |IOManager| fml::RefPtr GetSkiaUnrefQueue() const override; @@ -57,8 +57,8 @@ class ShellIOManager final : public IOManager { private: // Resource context management. - sk_sp resource_context_; - std::unique_ptr> + sk_sp resource_context_; + std::unique_ptr> resource_context_weak_factory_; // Unref queue management. diff --git a/shell/common/shell_test_external_view_embedder.cc b/shell/common/shell_test_external_view_embedder.cc index 4738c9b69f426..f3a5a0a37d27d 100644 --- a/shell/common/shell_test_external_view_embedder.cc +++ b/shell/common/shell_test_external_view_embedder.cc @@ -8,7 +8,7 @@ void ShellTestExternalViewEmbedder::CancelFrame() {} // |ExternalViewEmbedder| void ShellTestExternalViewEmbedder::BeginFrame( SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) {} @@ -36,7 +36,7 @@ SkCanvas* ShellTestExternalViewEmbedder::CompositeEmbeddedView(int view_id) { // |ExternalViewEmbedder| void ShellTestExternalViewEmbedder::SubmitFrame( - GrContext* context, + GrDirectContext* context, std::unique_ptr frame) { frame->Submit(); } diff --git a/shell/common/shell_test_external_view_embedder.h b/shell/common/shell_test_external_view_embedder.h index 9680d1e6630da..c67772df74f9a 100644 --- a/shell/common/shell_test_external_view_embedder.h +++ b/shell/common/shell_test_external_view_embedder.h @@ -31,7 +31,7 @@ class ShellTestExternalViewEmbedder final : public ExternalViewEmbedder { // |ExternalViewEmbedder| void BeginFrame( SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) override; @@ -51,7 +51,7 @@ class ShellTestExternalViewEmbedder final : public ExternalViewEmbedder { SkCanvas* CompositeEmbeddedView(int view_id) override; // |ExternalViewEmbedder| - void SubmitFrame(GrContext* context, + void SubmitFrame(GrDirectContext* context, std::unique_ptr frame) override; // |ExternalViewEmbedder| diff --git a/shell/common/shell_test_platform_view_vulkan.cc b/shell/common/shell_test_platform_view_vulkan.cc index 5dedabebae0b8..57372e5d25077 100644 --- a/shell/common/shell_test_platform_view_vulkan.cc +++ b/shell/common/shell_test_platform_view_vulkan.cc @@ -113,10 +113,11 @@ bool ShellTestPlatformViewVulkan::OffScreenSurface::CreateSkiaGrContext() { PersistentCache::MarkStrategySet(); options.fPersistentCache = PersistentCache::GetCacheForProcess(); - sk_sp context = GrContext::MakeVulkan(backend_context, options); + sk_sp context = + GrDirectContext::MakeVulkan(backend_context, options); if (context == nullptr) { - FML_DLOG(ERROR) << "Failed to create GrContext"; + FML_DLOG(ERROR) << "Failed to create GrDirectContext"; return false; } @@ -179,7 +180,7 @@ ShellTestPlatformViewVulkan::OffScreenSurface::AcquireFrame( std::move(callback)); } -GrContext* ShellTestPlatformViewVulkan::OffScreenSurface::GetContext() { +GrDirectContext* ShellTestPlatformViewVulkan::OffScreenSurface::GetContext() { return context_.get(); } diff --git a/shell/common/shell_test_platform_view_vulkan.h b/shell/common/shell_test_platform_view_vulkan.h index 31757f39a30b0..c2a13e70f6830 100644 --- a/shell/common/shell_test_platform_view_vulkan.h +++ b/shell/common/shell_test_platform_view_vulkan.h @@ -45,7 +45,7 @@ class ShellTestPlatformViewVulkan : public ShellTestPlatformView { SkMatrix GetRootTransformation() const override; // |Surface| - GrContext* GetContext() override; + GrDirectContext* GetContext() override; flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; @@ -56,7 +56,7 @@ class ShellTestPlatformViewVulkan : public ShellTestPlatformView { shell_test_external_view_embedder_; std::unique_ptr application_; std::unique_ptr logical_device_; - sk_sp context_; + sk_sp context_; bool CreateSkiaGrContext(); bool CreateSkiaBackendContext(GrVkBackendContext* context); diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index de068f55304fd..5f82ee64b5b50 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -945,7 +945,7 @@ class MockTexture : public Texture { void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) override {} void OnGrContextCreated() override {} diff --git a/shell/gpu/gpu_surface_gl.cc b/shell/gpu/gpu_surface_gl.cc index e57a745606d92..c492a456bb812 100644 --- a/shell/gpu/gpu_surface_gl.cc +++ b/shell/gpu/gpu_surface_gl.cc @@ -66,7 +66,7 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate, // A similar work-around is also used in shell/common/io_manager.cc. options.fDisableGpuYUVConversion = true; - auto context = GrContext::MakeGL(delegate_->GetGLInterface(), options); + auto context = GrDirectContext::MakeGL(delegate_->GetGLInterface(), options); if (context == nullptr) { FML_LOG(ERROR) << "Failed to setup Skia Gr context."; @@ -93,7 +93,7 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate, delegate_->GLContextClearCurrent(); } -GPUSurfaceGL::GPUSurfaceGL(sk_sp gr_context, +GPUSurfaceGL::GPUSurfaceGL(sk_sp gr_context, GPUSurfaceGLDelegate* delegate, bool render_to_surface) : delegate_(delegate), @@ -120,7 +120,7 @@ GPUSurfaceGL::~GPUSurfaceGL() { auto context_switch = delegate_->GLContextMakeCurrent(); if (!context_switch->GetResult()) { FML_LOG(ERROR) << "Could not make the context current to destroy the " - "GrContext resources."; + "GrDirectContext resources."; return; } @@ -138,7 +138,7 @@ bool GPUSurfaceGL::IsValid() { return valid_; } -static SkColorType FirstSupportedColorType(GrContext* context, +static SkColorType FirstSupportedColorType(GrDirectContext* context, GrGLenum* format) { #define RETURN_IF_RENDERABLE(x, y) \ if (context->colorTypeSupportedAsSurface((x))) { \ @@ -151,7 +151,7 @@ static SkColorType FirstSupportedColorType(GrContext* context, return kUnknown_SkColorType; } -static sk_sp WrapOnscreenSurface(GrContext* context, +static sk_sp WrapOnscreenSurface(GrDirectContext* context, const SkISize& size, intptr_t fbo) { GrGLenum format; @@ -322,7 +322,7 @@ sk_sp GPUSurfaceGL::AcquireRenderSurface( } // |Surface| -GrContext* GPUSurfaceGL::GetContext() { +GrDirectContext* GPUSurfaceGL::GetContext() { return context_.get(); } diff --git a/shell/gpu/gpu_surface_gl.h b/shell/gpu/gpu_surface_gl.h index 42152d98855ea..11ecfb9ee3e32 100644 --- a/shell/gpu/gpu_surface_gl.h +++ b/shell/gpu/gpu_surface_gl.h @@ -14,7 +14,7 @@ #include "flutter/fml/macros.h" #include "flutter/fml/memory/weak_ptr.h" #include "flutter/shell/gpu/gpu_surface_gl_delegate.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -22,8 +22,8 @@ class GPUSurfaceGL : public Surface { public: GPUSurfaceGL(GPUSurfaceGLDelegate* delegate, bool render_to_surface); - // Creates a new GL surface reusing an existing GrContext. - GPUSurfaceGL(sk_sp gr_context, + // Creates a new GL surface reusing an existing GrDirectContext. + GPUSurfaceGL(sk_sp gr_context, GPUSurfaceGLDelegate* delegate, bool render_to_surface); @@ -40,7 +40,7 @@ class GPUSurfaceGL : public Surface { SkMatrix GetRootTransformation() const override; // |Surface| - GrContext* GetContext() override; + GrDirectContext* GetContext() override; // |Surface| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; @@ -50,7 +50,7 @@ class GPUSurfaceGL : public Surface { private: GPUSurfaceGLDelegate* delegate_; - sk_sp context_; + sk_sp context_; sk_sp onscreen_surface_; bool context_owner_; // TODO(38466): Refactor GPU surface APIs take into account the fact that an diff --git a/shell/gpu/gpu_surface_metal.h b/shell/gpu/gpu_surface_metal.h index a55c3f1e9daf5..42d9851d534c6 100644 --- a/shell/gpu/gpu_surface_metal.h +++ b/shell/gpu/gpu_surface_metal.h @@ -11,7 +11,7 @@ #include "flutter/fml/macros.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" #include "flutter/shell/gpu/gpu_surface_delegate.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" @class CAMetalLayer; @@ -21,7 +21,7 @@ class GPUSurfaceMetal : public Surface { public: GPUSurfaceMetal(GPUSurfaceDelegate* delegate, fml::scoped_nsobject layer, - sk_sp context, + sk_sp context, fml::scoped_nsprotocol> command_queue); // |Surface| @@ -30,7 +30,7 @@ class GPUSurfaceMetal : public Surface { private: GPUSurfaceDelegate* delegate_; fml::scoped_nsobject layer_; - sk_sp context_; + sk_sp context_; fml::scoped_nsprotocol> command_queue_; GrMTLHandle next_drawable_ = nullptr; @@ -44,7 +44,7 @@ class GPUSurfaceMetal : public Surface { SkMatrix GetRootTransformation() const override; // |Surface| - GrContext* GetContext() override; + GrDirectContext* GetContext() override; // |Surface| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; diff --git a/shell/gpu/gpu_surface_metal.mm b/shell/gpu/gpu_surface_metal.mm index 63bbb39238c13..c6383f99ee846 100644 --- a/shell/gpu/gpu_surface_metal.mm +++ b/shell/gpu/gpu_surface_metal.mm @@ -18,7 +18,7 @@ GPUSurfaceMetal::GPUSurfaceMetal(GPUSurfaceDelegate* delegate, fml::scoped_nsobject layer, - sk_sp context, + sk_sp context, fml::scoped_nsprotocol> command_queue) : delegate_(delegate), layer_(std::move(layer)), @@ -118,7 +118,7 @@ } // |Surface| -GrContext* GPUSurfaceMetal::GetContext() { +GrDirectContext* GPUSurfaceMetal::GetContext() { return context_.get(); } diff --git a/shell/gpu/gpu_surface_software.cc b/shell/gpu/gpu_surface_software.cc index 8b2f664d18648..ea9f6ae556bf5 100644 --- a/shell/gpu/gpu_surface_software.cc +++ b/shell/gpu/gpu_surface_software.cc @@ -82,7 +82,7 @@ SkMatrix GPUSurfaceSoftware::GetRootTransformation() const { } // |Surface| -GrContext* GPUSurfaceSoftware::GetContext() { +GrDirectContext* GPUSurfaceSoftware::GetContext() { // There is no GrContext associated with a software surface. return nullptr; } diff --git a/shell/gpu/gpu_surface_software.h b/shell/gpu/gpu_surface_software.h index 8c122f42fb32c..8784493584850 100644 --- a/shell/gpu/gpu_surface_software.h +++ b/shell/gpu/gpu_surface_software.h @@ -29,7 +29,7 @@ class GPUSurfaceSoftware : public Surface { SkMatrix GetRootTransformation() const override; // |Surface| - GrContext* GetContext() override; + GrDirectContext* GetContext() override; // |Surface| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; diff --git a/shell/gpu/gpu_surface_vulkan.cc b/shell/gpu/gpu_surface_vulkan.cc index 3e984ff223cf2..fcfbf7c5b23b1 100644 --- a/shell/gpu/gpu_surface_vulkan.cc +++ b/shell/gpu/gpu_surface_vulkan.cc @@ -63,7 +63,7 @@ SkMatrix GPUSurfaceVulkan::GetRootTransformation() const { return matrix; } -GrContext* GPUSurfaceVulkan::GetContext() { +GrDirectContext* GPUSurfaceVulkan::GetContext() { return window_.GetSkiaGrContext(); } diff --git a/shell/gpu/gpu_surface_vulkan.h b/shell/gpu/gpu_surface_vulkan.h index eaf583686dabb..c52346ed301d0 100644 --- a/shell/gpu/gpu_surface_vulkan.h +++ b/shell/gpu/gpu_surface_vulkan.h @@ -34,7 +34,7 @@ class GPUSurfaceVulkan : public Surface { SkMatrix GetRootTransformation() const override; // |Surface| - GrContext* GetContext() override; + GrDirectContext* GetContext() override; // |Surface| flutter::ExternalViewEmbedder* GetExternalViewEmbedder() override; diff --git a/shell/platform/android/android_external_texture_gl.cc b/shell/platform/android/android_external_texture_gl.cc index 00befbad243a6..8e071ffba2420 100644 --- a/shell/platform/android/android_external_texture_gl.cc +++ b/shell/platform/android/android_external_texture_gl.cc @@ -36,7 +36,7 @@ void AndroidExternalTextureGL::MarkNewFrameAvailable() { void AndroidExternalTextureGL::Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) { if (state_ == AttachmentState::detached) { return; diff --git a/shell/platform/android/android_external_texture_gl.h b/shell/platform/android/android_external_texture_gl.h index 72b9cf64ded61..09fda4a8744c3 100644 --- a/shell/platform/android/android_external_texture_gl.h +++ b/shell/platform/android/android_external_texture_gl.h @@ -24,7 +24,7 @@ class AndroidExternalTextureGL : public flutter::Texture { void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) override; void OnGrContextCreated() override; diff --git a/shell/platform/android/android_surface_gl.cc b/shell/platform/android/android_surface_gl.cc index c8cc3d2d1183e..a3356653df9a8 100644 --- a/shell/platform/android/android_surface_gl.cc +++ b/shell/platform/android/android_surface_gl.cc @@ -43,7 +43,7 @@ bool AndroidSurfaceGL::IsValid() const { } std::unique_ptr AndroidSurfaceGL::CreateGPUSurface( - GrContext* gr_context) { + GrDirectContext* gr_context) { if (gr_context) { return std::make_unique(sk_ref_sp(gr_context), this, true); } diff --git a/shell/platform/android/android_surface_gl.h b/shell/platform/android/android_surface_gl.h index 7c682171d12c4..281a273351908 100644 --- a/shell/platform/android/android_surface_gl.h +++ b/shell/platform/android/android_surface_gl.h @@ -31,7 +31,8 @@ class AndroidSurfaceGL final : public GPUSurfaceGLDelegate, bool IsValid() const override; // |AndroidSurface| - std::unique_ptr CreateGPUSurface(GrContext* gr_context) override; + std::unique_ptr CreateGPUSurface( + GrDirectContext* gr_context) override; // |AndroidSurface| void TeardownOnScreenContext() override; diff --git a/shell/platform/android/android_surface_software.cc b/shell/platform/android/android_surface_software.cc index 3bc52e317279a..1f99b967b9a00 100644 --- a/shell/platform/android/android_surface_software.cc +++ b/shell/platform/android/android_surface_software.cc @@ -65,7 +65,7 @@ bool AndroidSurfaceSoftware::ResourceContextClearCurrent() { } std::unique_ptr AndroidSurfaceSoftware::CreateGPUSurface( - GrContext* gr_context) { + GrDirectContext* gr_context) { if (!IsValid()) { return nullptr; } diff --git a/shell/platform/android/android_surface_software.h b/shell/platform/android/android_surface_software.h index 1f5fb885dbf88..ec9fdb63f131d 100644 --- a/shell/platform/android/android_surface_software.h +++ b/shell/platform/android/android_surface_software.h @@ -34,7 +34,8 @@ class AndroidSurfaceSoftware final : public AndroidSurface, bool ResourceContextClearCurrent() override; // |AndroidSurface| - std::unique_ptr CreateGPUSurface(GrContext* gr_context) override; + std::unique_ptr CreateGPUSurface( + GrDirectContext* gr_context) override; // |AndroidSurface| void TeardownOnScreenContext() override; diff --git a/shell/platform/android/android_surface_vulkan.cc b/shell/platform/android/android_surface_vulkan.cc index 4c428e931637c..4ff32b70a12c5 100644 --- a/shell/platform/android/android_surface_vulkan.cc +++ b/shell/platform/android/android_surface_vulkan.cc @@ -33,7 +33,7 @@ void AndroidSurfaceVulkan::TeardownOnScreenContext() { } std::unique_ptr AndroidSurfaceVulkan::CreateGPUSurface( - GrContext* gr_context) { + GrDirectContext* gr_context) { if (!IsValid()) { return nullptr; } diff --git a/shell/platform/android/android_surface_vulkan.h b/shell/platform/android/android_surface_vulkan.h index 3491d55acbcb8..377d0d7fa340d 100644 --- a/shell/platform/android/android_surface_vulkan.h +++ b/shell/platform/android/android_surface_vulkan.h @@ -29,7 +29,8 @@ class AndroidSurfaceVulkan : public AndroidSurface, bool IsValid() const override; // |AndroidSurface| - std::unique_ptr CreateGPUSurface(GrContext* gr_context) override; + std::unique_ptr CreateGPUSurface( + GrDirectContext* gr_context) override; // |AndroidSurface| void TeardownOnScreenContext() override; diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.cc b/shell/platform/android/external_view_embedder/external_view_embedder.cc index 2a5fab2b7c016..9a32dc171eabf 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder.cc @@ -73,7 +73,7 @@ SkRect AndroidExternalViewEmbedder::GetViewRect(int view_id) const { // |ExternalViewEmbedder| void AndroidExternalViewEmbedder::SubmitFrame( - GrContext* context, + GrDirectContext* context, std::unique_ptr frame) { TRACE_EVENT0("flutter", "AndroidExternalViewEmbedder::SubmitFrame"); @@ -185,7 +185,7 @@ void AndroidExternalViewEmbedder::SubmitFrame( // |ExternalViewEmbedder| std::unique_ptr -AndroidExternalViewEmbedder::CreateSurfaceIfNeeded(GrContext* context, +AndroidExternalViewEmbedder::CreateSurfaceIfNeeded(GrDirectContext* context, int64_t view_id, sk_sp picture, const SkRect& rect) { @@ -257,7 +257,7 @@ void AndroidExternalViewEmbedder::Reset() { // |ExternalViewEmbedder| void AndroidExternalViewEmbedder::BeginFrame( SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) { Reset(); diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.h b/shell/platform/android/external_view_embedder/external_view_embedder.h index bc81342d94349..9e827b83b0ee0 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.h +++ b/shell/platform/android/external_view_embedder/external_view_embedder.h @@ -45,7 +45,7 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder { std::vector GetCurrentCanvases() override; // |ExternalViewEmbedder| - void SubmitFrame(GrContext* context, + void SubmitFrame(GrDirectContext* context, std::unique_ptr frame) override; // |ExternalViewEmbedder| @@ -58,7 +58,7 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder { // |ExternalViewEmbedder| void BeginFrame( SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) override; @@ -132,7 +132,7 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder { // Creates a Surface when needed or recycles an existing one. // Finally, draws the picture on the frame's canvas. - std::unique_ptr CreateSurfaceIfNeeded(GrContext* context, + std::unique_ptr CreateSurfaceIfNeeded(GrDirectContext* context, int64_t view_id, sk_sp picture, const SkRect& rect); diff --git a/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc b/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc index 11eeac3b2edc6..93356347ae322 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc @@ -12,7 +12,7 @@ #include "flutter/shell/platform/android/surface/android_surface_mock.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { namespace testing { @@ -31,7 +31,7 @@ class SurfaceMock : public Surface { MOCK_METHOD(SkMatrix, GetRootTransformation, (), (const, override)); - MOCK_METHOD(GrContext*, GetContext, (), (override)); + MOCK_METHOD(GrDirectContext*, GetContext, (), (override)); MOCK_METHOD(flutter::ExternalViewEmbedder*, GetExternalViewEmbedder, @@ -260,7 +260,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) { std::make_shared(AndroidRenderingAPI::kSoftware); auto window = fml::MakeRefCounted(nullptr); - auto gr_context = GrContext::MakeMock(nullptr); + auto gr_context = GrDirectContext::MakeMock(nullptr); auto frame_size = SkISize::Make(1000, 1000); auto surface_factory = [gr_context, window, frame_size]( @@ -479,7 +479,7 @@ TEST(AndroidExternalViewEmbedder, DestroyOverlayLayersOnSizeChange) { std::make_shared(AndroidRenderingAPI::kSoftware); auto window = fml::MakeRefCounted(nullptr); - auto gr_context = GrContext::MakeMock(nullptr); + auto gr_context = GrDirectContext::MakeMock(nullptr); auto frame_size = SkISize::Make(1000, 1000); auto surface_factory = [gr_context, window, frame_size]( diff --git a/shell/platform/android/external_view_embedder/surface_pool.cc b/shell/platform/android/external_view_embedder/surface_pool.cc index cefd5e668a40f..bee34109b95b1 100644 --- a/shell/platform/android/external_view_embedder/surface_pool.cc +++ b/shell/platform/android/external_view_embedder/surface_pool.cc @@ -20,7 +20,7 @@ SurfacePool::SurfacePool() = default; SurfacePool::~SurfacePool() = default; std::shared_ptr SurfacePool::GetLayer( - GrContext* gr_context, + GrDirectContext* gr_context, std::shared_ptr android_context, std::shared_ptr jni_facade, const AndroidSurface::Factory& surface_factory) { diff --git a/shell/platform/android/external_view_embedder/surface_pool.h b/shell/platform/android/external_view_embedder/surface_pool.h index f4412a8e16f99..190119c75cf25 100644 --- a/shell/platform/android/external_view_embedder/surface_pool.h +++ b/shell/platform/android/external_view_embedder/surface_pool.h @@ -52,7 +52,7 @@ class SurfacePool { // Finally, it marks the layer as used. That is, it increments // `available_layer_index_`. std::shared_ptr GetLayer( - GrContext* gr_context, + GrDirectContext* gr_context, std::shared_ptr android_context, std::shared_ptr jni_facade, const AndroidSurface::Factory& surface_factory); diff --git a/shell/platform/android/external_view_embedder/surface_pool_unittests.cc b/shell/platform/android/external_view_embedder/surface_pool_unittests.cc index edfe86d1526b3..60ecb3648240f 100644 --- a/shell/platform/android/external_view_embedder/surface_pool_unittests.cc +++ b/shell/platform/android/external_view_embedder/surface_pool_unittests.cc @@ -9,7 +9,7 @@ #include "flutter/shell/platform/android/surface/android_surface_mock.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { namespace testing { @@ -20,7 +20,7 @@ using ::testing::Return; TEST(SurfacePool, GetLayer__AllocateOneLayer) { auto pool = std::make_unique(); - auto gr_context = GrContext::MakeMock(nullptr); + auto gr_context = GrDirectContext::MakeMock(nullptr); auto android_context = std::make_shared(AndroidRenderingAPI::kSoftware); @@ -51,7 +51,7 @@ TEST(SurfacePool, GetLayer__AllocateOneLayer) { TEST(SurfacePool, GetUnusedLayers) { auto pool = std::make_unique(); - auto gr_context = GrContext::MakeMock(nullptr); + auto gr_context = GrDirectContext::MakeMock(nullptr); auto android_context = std::make_shared(AndroidRenderingAPI::kSoftware); @@ -84,7 +84,7 @@ TEST(SurfacePool, GetUnusedLayers) { TEST(SurfacePool, GetLayer__Recycle) { auto pool = std::make_unique(); - auto gr_context_1 = GrContext::MakeMock(nullptr); + auto gr_context_1 = GrDirectContext::MakeMock(nullptr); auto jni_mock = std::make_shared(); auto window = fml::MakeRefCounted(nullptr); EXPECT_CALL(*jni_mock, FlutterViewCreateOverlaySurface()) @@ -95,7 +95,7 @@ TEST(SurfacePool, GetLayer__Recycle) { auto android_context = std::make_shared(AndroidRenderingAPI::kSoftware); - auto gr_context_2 = GrContext::MakeMock(nullptr); + auto gr_context_2 = GrDirectContext::MakeMock(nullptr); auto surface_factory = [gr_context_1, gr_context_2, window]( std::shared_ptr android_context, @@ -130,7 +130,7 @@ TEST(SurfacePool, GetLayer__Recycle) { TEST(SurfacePool, GetLayer__AllocateTwoLayers) { auto pool = std::make_unique(); - auto gr_context = GrContext::MakeMock(nullptr); + auto gr_context = GrDirectContext::MakeMock(nullptr); auto android_context = std::make_shared(AndroidRenderingAPI::kSoftware); @@ -172,7 +172,7 @@ TEST(SurfacePool, DestroyLayers) { EXPECT_CALL(*jni_mock, FlutterViewDestroyOverlaySurfaces()).Times(0); pool->DestroyLayers(jni_mock); - auto gr_context = GrContext::MakeMock(nullptr); + auto gr_context = GrDirectContext::MakeMock(nullptr); auto android_context = std::make_shared(AndroidRenderingAPI::kSoftware); diff --git a/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc index 596994662f3a2..2c887b638a060 100644 --- a/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.cc @@ -287,11 +287,11 @@ std::unique_ptr PlatformViewAndroid::CreateRenderingSurface() { } // |PlatformView| -sk_sp PlatformViewAndroid::CreateResourceContext() const { +sk_sp PlatformViewAndroid::CreateResourceContext() const { if (!android_surface_) { return nullptr; } - sk_sp resource_context; + sk_sp resource_context; if (android_surface_->ResourceContextMakeCurrent()) { // TODO(chinmaygarde): Currently, this code depends on the fact that only // the OpenGL surface will be able to make a resource context current. If diff --git a/shell/platform/android/platform_view_android.h b/shell/platform/android/platform_view_android.h index 34475ddbc5243..618b0413a572f 100644 --- a/shell/platform/android/platform_view_android.h +++ b/shell/platform/android/platform_view_android.h @@ -108,7 +108,7 @@ class PlatformViewAndroid final : public PlatformView { std::unique_ptr CreateRenderingSurface() override; // |PlatformView| - sk_sp CreateResourceContext() const override; + sk_sp CreateResourceContext() const override; // |PlatformView| void ReleaseResourceContext() const override; diff --git a/shell/platform/android/surface/android_surface.h b/shell/platform/android/surface/android_surface.h index 26604f4ff7717..98c4f629414ae 100644 --- a/shell/platform/android/surface/android_surface.h +++ b/shell/platform/android/surface/android_surface.h @@ -27,7 +27,7 @@ class AndroidSurface { virtual void TeardownOnScreenContext() = 0; virtual std::unique_ptr CreateGPUSurface( - GrContext* gr_context = nullptr) = 0; + GrDirectContext* gr_context = nullptr) = 0; virtual bool OnScreenSurfaceResize(const SkISize& size) = 0; diff --git a/shell/platform/android/surface/android_surface_mock.h b/shell/platform/android/surface/android_surface_mock.h index 23c3083567c50..688681e01c8c0 100644 --- a/shell/platform/android/surface/android_surface_mock.h +++ b/shell/platform/android/surface/android_surface_mock.h @@ -24,7 +24,7 @@ class AndroidSurfaceMock final : public GPUSurfaceGLDelegate, MOCK_METHOD(std::unique_ptr, CreateGPUSurface, - (GrContext * gr_context), + (GrDirectContext * gr_context), (override)); MOCK_METHOD(bool, OnScreenSurfaceResize, (const SkISize& size), (override)); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index abf854f15731b..9c43d355b3210 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -22,7 +22,7 @@ namespace flutter { std::shared_ptr FlutterPlatformViewLayerPool::GetLayer( - GrContext* gr_context, + GrDirectContext* gr_context, std::shared_ptr ios_context) { if (available_layer_index_ >= layers_.size()) { std::shared_ptr layer; @@ -462,7 +462,7 @@ ); } -bool FlutterPlatformViewsController::SubmitFrame(GrContext* gr_context, +bool FlutterPlatformViewsController::SubmitFrame(GrDirectContext* gr_context, std::shared_ptr ios_context, std::unique_ptr frame) { FML_DCHECK(flutter_view_); @@ -608,7 +608,7 @@ } std::shared_ptr FlutterPlatformViewsController::GetLayer( - GrContext* gr_context, + GrDirectContext* gr_context, std::shared_ptr ios_context, sk_sp picture, SkRect rect, diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 7a4724f5b0c6b..2b6bcf961310c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -78,7 +78,7 @@ struct FlutterPlatformViewLayer { // The GrContext that is currently used by the overlay surfaces. // We track this to know when the GrContext for the Flutter app has changed // so we can update the overlay with the new context. - GrContext* gr_context; + GrDirectContext* gr_context; }; // This class isn't thread safe. @@ -89,7 +89,7 @@ class FlutterPlatformViewLayerPool { // Gets a layer from the pool if available, or allocates a new one. // Finally, it marks the layer as used. That is, it increments `available_layer_index_`. - std::shared_ptr GetLayer(GrContext* gr_context, + std::shared_ptr GetLayer(GrDirectContext* gr_context, std::shared_ptr ios_context); // Gets the layers in the pool that aren't currently used. @@ -162,7 +162,7 @@ class FlutterPlatformViewsController { // Discards all platform views instances and auxiliary resources. void Reset(); - bool SubmitFrame(GrContext* gr_context, + bool SubmitFrame(GrDirectContext* gr_context, std::shared_ptr ios_context, std::unique_ptr frame); @@ -290,7 +290,7 @@ class FlutterPlatformViewsController { bool merge_threads_ = false; // Allocates a new FlutterPlatformViewLayer if needed, draws the pixels within the rect from // the picture on the layer's canvas. - std::shared_ptr GetLayer(GrContext* gr_context, + std::shared_ptr GetLayer(GrDirectContext* gr_context, std::shared_ptr ios_context, sk_sp picture, SkRect rect, diff --git a/shell/platform/darwin/ios/ios_context.h b/shell/platform/darwin/ios/ios_context.h index 265d3563c2981..f3def03f31fc1 100644 --- a/shell/platform/darwin/ios/ios_context.h +++ b/shell/platform/darwin/ios/ios_context.h @@ -13,7 +13,7 @@ #include "flutter/fml/platform/darwin/scoped_nsobject.h" #include "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" #include "flutter/shell/platform/darwin/ios/rendering_api_selection.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -58,12 +58,12 @@ class IOSContext { /// asynchronously and collect resources that are no longer needed /// on the render task runner. /// - /// @attention Client rendering APIs for which a GrContext cannot be realized + /// @attention Client rendering APIs for which a GrDirectContext cannot be realized /// (software rendering), this method will always return null. /// /// @return A non-null Skia context on success. `nullptr` on failure. /// - virtual sk_sp CreateResourceContext() = 0; + virtual sk_sp CreateResourceContext() = 0; //---------------------------------------------------------------------------- /// @brief When using client rendering APIs whose contexts need to be @@ -75,7 +75,7 @@ class IOSContext { /// bindings (anything that is not OpenGL) will always return /// `true`. /// - /// @attention Client rendering APIs for which a GrContext cannot be created + /// @attention Client rendering APIs for which a GrDirectContext cannot be created /// (software rendering) will always return `false`. /// /// @attention This binds the on-screen context to the current thread. To diff --git a/shell/platform/darwin/ios/ios_context_gl.h b/shell/platform/darwin/ios/ios_context_gl.h index 126fda48c3f70..1adea8235ca85 100644 --- a/shell/platform/darwin/ios/ios_context_gl.h +++ b/shell/platform/darwin/ios/ios_context_gl.h @@ -30,7 +30,7 @@ class IOSContextGL final : public IOSContext { fml::scoped_nsobject resource_context_; // |IOSContext| - sk_sp CreateResourceContext() override; + sk_sp CreateResourceContext() override; // |IOSContext| std::unique_ptr MakeCurrent() override; diff --git a/shell/platform/darwin/ios/ios_context_gl.mm b/shell/platform/darwin/ios/ios_context_gl.mm index 282f8eda2fce8..d34c78a18855b 100644 --- a/shell/platform/darwin/ios/ios_context_gl.mm +++ b/shell/platform/darwin/ios/ios_context_gl.mm @@ -32,7 +32,7 @@ } // |IOSContext| -sk_sp IOSContextGL::CreateResourceContext() { +sk_sp IOSContextGL::CreateResourceContext() { if (![EAGLContext setCurrentContext:resource_context_.get()]) { FML_DLOG(INFO) << "Could not make resource context current on IO thread. Async texture uploads " "will be disabled. On Simulators, this is expected."; diff --git a/shell/platform/darwin/ios/ios_context_metal.h b/shell/platform/darwin/ios/ios_context_metal.h index 644b4f5d3c3c2..8a3387c92f705 100644 --- a/shell/platform/darwin/ios/ios_context_metal.h +++ b/shell/platform/darwin/ios/ios_context_metal.h @@ -11,7 +11,7 @@ #include "flutter/fml/platform/darwin/cf_utils.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" #include "flutter/shell/platform/darwin/ios/ios_context.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -27,20 +27,20 @@ class IOSContextMetal final : public IOSContext { fml::scoped_nsprotocol> GetResourceCommandQueue() const; - sk_sp GetMainContext() const; + sk_sp GetMainContext() const; - sk_sp GetResourceContext() const; + sk_sp GetResourceContext() const; private: fml::scoped_nsprotocol> device_; fml::scoped_nsprotocol> main_queue_; - sk_sp main_context_; - sk_sp resource_context_; + sk_sp main_context_; + sk_sp resource_context_; fml::CFRef texture_cache_; bool is_valid_ = false; // |IOSContext| - sk_sp CreateResourceContext() override; + sk_sp CreateResourceContext() override; // |IOSContext| std::unique_ptr MakeCurrent() override; diff --git a/shell/platform/darwin/ios/ios_context_metal.mm b/shell/platform/darwin/ios/ios_context_metal.mm index 9d0a3cad62372..0f7aac0e299a8 100644 --- a/shell/platform/darwin/ios/ios_context_metal.mm +++ b/shell/platform/darwin/ios/ios_context_metal.mm @@ -40,9 +40,11 @@ static GrContextOptions CreateMetalGrContextOptions() { const auto& context_options = CreateMetalGrContextOptions(); // Skia expect arguments to `MakeMetal` transfer ownership of the reference in for release later - // when the GrContext is collected. - main_context_ = GrContext::MakeMetal([device_ retain], [main_queue_ retain], context_options); - resource_context_ = GrContext::MakeMetal([device_ retain], [main_queue_ retain], context_options); + // when the GrDirectContext is collected. + main_context_ = + GrDirectContext::MakeMetal([device_ retain], [main_queue_ retain], context_options); + resource_context_ = + GrDirectContext::MakeMetal([device_ retain], [main_queue_ retain], context_options); if (!main_context_ || !resource_context_) { FML_DLOG(ERROR) << "Could not create Skia Metal contexts."; @@ -82,16 +84,16 @@ static GrContextOptions CreateMetalGrContextOptions() { return main_queue_; } -sk_sp IOSContextMetal::GetMainContext() const { +sk_sp IOSContextMetal::GetMainContext() const { return main_context_; } -sk_sp IOSContextMetal::GetResourceContext() const { +sk_sp IOSContextMetal::GetResourceContext() const { return resource_context_; } // |IOSContext| -sk_sp IOSContextMetal::CreateResourceContext() { +sk_sp IOSContextMetal::CreateResourceContext() { return resource_context_; } diff --git a/shell/platform/darwin/ios/ios_context_software.h b/shell/platform/darwin/ios/ios_context_software.h index 9f98d8eb7c66a..e2ac59d0e79e0 100644 --- a/shell/platform/darwin/ios/ios_context_software.h +++ b/shell/platform/darwin/ios/ios_context_software.h @@ -18,7 +18,7 @@ class IOSContextSoftware final : public IOSContext { ~IOSContextSoftware(); // |IOSContext| - sk_sp CreateResourceContext() override; + sk_sp CreateResourceContext() override; // |IOSContext| std::unique_ptr MakeCurrent() override; diff --git a/shell/platform/darwin/ios/ios_context_software.mm b/shell/platform/darwin/ios/ios_context_software.mm index 4bec84f4b2c0d..12c191f79eb74 100644 --- a/shell/platform/darwin/ios/ios_context_software.mm +++ b/shell/platform/darwin/ios/ios_context_software.mm @@ -12,7 +12,7 @@ IOSContextSoftware::~IOSContextSoftware() = default; // |IOSContext| -sk_sp IOSContextSoftware::CreateResourceContext() { +sk_sp IOSContextSoftware::CreateResourceContext() { return nullptr; } diff --git a/shell/platform/darwin/ios/ios_external_texture_gl.h b/shell/platform/darwin/ios/ios_external_texture_gl.h index e8f8fa3763ddc..5c608506bb82f 100644 --- a/shell/platform/darwin/ios/ios_external_texture_gl.h +++ b/shell/platform/darwin/ios/ios_external_texture_gl.h @@ -30,7 +30,7 @@ class IOSExternalTextureGL final : public Texture { void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) override; // |Texture| diff --git a/shell/platform/darwin/ios/ios_external_texture_gl.mm b/shell/platform/darwin/ios/ios_external_texture_gl.mm index 25b3b2be5e125..bb56fc2849bcf 100644 --- a/shell/platform/darwin/ios/ios_external_texture_gl.mm +++ b/shell/platform/darwin/ios/ios_external_texture_gl.mm @@ -11,6 +11,7 @@ #include "flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h" #include "third_party/skia/include/core/SkSurface.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -63,7 +64,7 @@ void IOSExternalTextureGL::Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) { EnsureTextureCacheExists(); if (NeedUpdateTexture(freeze)) { diff --git a/shell/platform/darwin/ios/ios_external_texture_metal.h b/shell/platform/darwin/ios/ios_external_texture_metal.h index a3f916151fba2..9cbf84431eb9d 100644 --- a/shell/platform/darwin/ios/ios_external_texture_metal.h +++ b/shell/platform/darwin/ios/ios_external_texture_metal.h @@ -38,7 +38,7 @@ class IOSExternalTextureMetal final : public Texture { void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) override; // |Texture| @@ -54,7 +54,7 @@ class IOSExternalTextureMetal final : public Texture { void OnTextureUnregistered() override; sk_sp WrapExternalPixelBuffer(fml::CFRef pixel_buffer, - GrContext* context) const; + GrDirectContext* context) const; FML_DISALLOW_COPY_AND_ASSIGN(IOSExternalTextureMetal); }; diff --git a/shell/platform/darwin/ios/ios_external_texture_metal.mm b/shell/platform/darwin/ios/ios_external_texture_metal.mm index b5aefca817885..46eff3415273b 100644 --- a/shell/platform/darwin/ios/ios_external_texture_metal.mm +++ b/shell/platform/darwin/ios/ios_external_texture_metal.mm @@ -6,6 +6,7 @@ #include "flutter/fml/logging.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/skia/include/gpu/mtl/GrMtlTypes.h" namespace flutter { @@ -26,7 +27,7 @@ void IOSExternalTextureMetal::Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) { const bool needs_updated_texture = (!freeze && texture_frame_available_) || !external_image_; @@ -59,7 +60,7 @@ sk_sp IOSExternalTextureMetal::WrapExternalPixelBuffer( fml::CFRef pixel_buffer, - GrContext* context) const { + GrDirectContext* context) const { if (!pixel_buffer) { return nullptr; } diff --git a/shell/platform/darwin/ios/ios_surface.h b/shell/platform/darwin/ios/ios_surface.h index 4532ff42e0baa..041e3bacedb32 100644 --- a/shell/platform/darwin/ios/ios_surface.h +++ b/shell/platform/darwin/ios/ios_surface.h @@ -40,12 +40,12 @@ class IOSSurface : public ExternalViewEmbedder { virtual void UpdateStorageSizeIfNecessary() = 0; - // Creates a GPU surface. If no GrContext is supplied and the rendering mode + // Creates a GPU surface. If no GrDirectContext is supplied and the rendering mode // supports one, a new one will be created; otherwise, the software backend // will be used. // - // If a GrContext is supplied, creates a secondary surface. - virtual std::unique_ptr CreateGPUSurface(GrContext* gr_context = nullptr) = 0; + // If a GrDirectContext is supplied, creates a secondary surface. + virtual std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context = nullptr) = 0; protected: IOSSurface(std::shared_ptr ios_context, @@ -63,7 +63,7 @@ class IOSSurface : public ExternalViewEmbedder { // |ExternalViewEmbedder| void BeginFrame(SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) override; @@ -82,7 +82,7 @@ class IOSSurface : public ExternalViewEmbedder { SkCanvas* CompositeEmbeddedView(int view_id) override; // |ExternalViewEmbedder| - void SubmitFrame(GrContext* context, std::unique_ptr frame) override; + void SubmitFrame(GrDirectContext* context, std::unique_ptr frame) override; // |ExternalViewEmbedder| void EndFrame(bool should_resubmit_frame, diff --git a/shell/platform/darwin/ios/ios_surface.mm b/shell/platform/darwin/ios/ios_surface.mm index 216f766e07c73..de330fb58fc42 100644 --- a/shell/platform/darwin/ios/ios_surface.mm +++ b/shell/platform/darwin/ios/ios_surface.mm @@ -95,7 +95,7 @@ bool IsIosEmbeddedViewsPreviewEnabled() { // |ExternalViewEmbedder| void IOSSurface::BeginFrame(SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) { TRACE_EVENT0("flutter", "IOSSurface::BeginFrame"); @@ -135,7 +135,7 @@ bool IsIosEmbeddedViewsPreviewEnabled() { } // |ExternalViewEmbedder| -void IOSSurface::SubmitFrame(GrContext* context, std::unique_ptr frame) { +void IOSSurface::SubmitFrame(GrDirectContext* context, std::unique_ptr frame) { TRACE_EVENT0("flutter", "IOSSurface::SubmitFrame"); FML_CHECK(platform_views_controller_ != nullptr); bool submitted = diff --git a/shell/platform/darwin/ios/ios_surface_gl.h b/shell/platform/darwin/ios/ios_surface_gl.h index 42e8fcd4b753e..e6433eb83ef56 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.h +++ b/shell/platform/darwin/ios/ios_surface_gl.h @@ -31,7 +31,7 @@ class IOSSurfaceGL final : public IOSSurface, public GPUSurfaceGLDelegate { void UpdateStorageSizeIfNecessary() override; // |IOSSurface| - std::unique_ptr CreateGPUSurface(GrContext* gr_context) override; + std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context) override; // |GPUSurfaceGLDelegate| std::unique_ptr GLContextMakeCurrent() override; diff --git a/shell/platform/darwin/ios/ios_surface_gl.mm b/shell/platform/darwin/ios/ios_surface_gl.mm index cf685d4f79a52..3531f61c3c0df 100644 --- a/shell/platform/darwin/ios/ios_surface_gl.mm +++ b/shell/platform/darwin/ios/ios_surface_gl.mm @@ -36,7 +36,7 @@ } // |IOSSurface| -std::unique_ptr IOSSurfaceGL::CreateGPUSurface(GrContext* gr_context) { +std::unique_ptr IOSSurfaceGL::CreateGPUSurface(GrDirectContext* gr_context) { if (gr_context) { return std::make_unique(sk_ref_sp(gr_context), this, true); } diff --git a/shell/platform/darwin/ios/ios_surface_metal.h b/shell/platform/darwin/ios/ios_surface_metal.h index e700bc02a3eb2..6b353449322a8 100644 --- a/shell/platform/darwin/ios/ios_surface_metal.h +++ b/shell/platform/darwin/ios/ios_surface_metal.h @@ -33,7 +33,7 @@ class IOSSurfaceMetal final : public IOSSurface, public GPUSurfaceDelegate { void UpdateStorageSizeIfNecessary() override; // |IOSSurface| - std::unique_ptr CreateGPUSurface(GrContext* gr_context) override; + std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context) override; // |GPUSurfaceDelegate| ExternalViewEmbedder* GetExternalViewEmbedder() override; diff --git a/shell/platform/darwin/ios/ios_surface_metal.mm b/shell/platform/darwin/ios/ios_surface_metal.mm index db345b383ef7b..60afa6fd69775 100644 --- a/shell/platform/darwin/ios/ios_surface_metal.mm +++ b/shell/platform/darwin/ios/ios_surface_metal.mm @@ -43,7 +43,7 @@ } // |IOSSurface| -std::unique_ptr IOSSurfaceMetal::CreateGPUSurface(GrContext* /* unused */) { +std::unique_ptr IOSSurfaceMetal::CreateGPUSurface(GrDirectContext* /* unused */) { auto metal_context = CastToMetalContext(GetContext()); return std::make_unique(this, // Metal surface delegate diff --git a/shell/platform/darwin/ios/ios_surface_software.h b/shell/platform/darwin/ios/ios_surface_software.h index 86e6b6b209785..e8fd6832a5aa0 100644 --- a/shell/platform/darwin/ios/ios_surface_software.h +++ b/shell/platform/darwin/ios/ios_surface_software.h @@ -31,7 +31,7 @@ class IOSSurfaceSoftware final : public IOSSurface, public GPUSurfaceSoftwareDel void UpdateStorageSizeIfNecessary() override; // |IOSSurface| - std::unique_ptr CreateGPUSurface(GrContext* gr_context = nullptr) override; + std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context = nullptr) override; // |GPUSurfaceSoftwareDelegate| sk_sp AcquireBackingStore(const SkISize& size) override; diff --git a/shell/platform/darwin/ios/ios_surface_software.mm b/shell/platform/darwin/ios/ios_surface_software.mm index 06abe29c661e8..a68e0509f8ab4 100644 --- a/shell/platform/darwin/ios/ios_surface_software.mm +++ b/shell/platform/darwin/ios/ios_surface_software.mm @@ -33,7 +33,7 @@ // Android oddities. } -std::unique_ptr IOSSurfaceSoftware::CreateGPUSurface(GrContext* gr_context) { +std::unique_ptr IOSSurfaceSoftware::CreateGPUSurface(GrDirectContext* gr_context) { if (!IsValid()) { return nullptr; } diff --git a/shell/platform/darwin/ios/platform_view_ios.h b/shell/platform/darwin/ios/platform_view_ios.h index 7cd3f3468e627..16e79448d6a69 100644 --- a/shell/platform/darwin/ios/platform_view_ios.h +++ b/shell/platform/darwin/ios/platform_view_ios.h @@ -31,7 +31,7 @@ namespace flutter { * The shell provides and requests for UI related data and this PlatformView subclass fulfills * it with iOS specific capabilities. As an example, the iOS embedding (the `FlutterEngine` and the * `FlutterViewController`) sends pointer data to the shell and receives the shell's request for a - * Skia GrContext and supplies it. + * Skia GrDirectContext and supplies it. * * Despite the name "view", this class is unrelated to UIViews on iOS and doesn't have the same * lifecycle. It's a long lived bridge owned by the `FlutterEngine` and can be attached and @@ -138,7 +138,7 @@ class PlatformViewIOS final : public PlatformView { std::unique_ptr CreateRenderingSurface() override; // |PlatformView| - sk_sp CreateResourceContext() const override; + sk_sp CreateResourceContext() const override; // |PlatformView| void SetAccessibilityFeatures(int32_t flags) override; diff --git a/shell/platform/darwin/ios/platform_view_ios.mm b/shell/platform/darwin/ios/platform_view_ios.mm index 14fcc2141c478..c00ecb9c0bc05 100644 --- a/shell/platform/darwin/ios/platform_view_ios.mm +++ b/shell/platform/darwin/ios/platform_view_ios.mm @@ -138,7 +138,7 @@ new AccessibilityBridge(static_cast(owner_controller_.get().view), } // |PlatformView| -sk_sp PlatformViewIOS::CreateResourceContext() const { +sk_sp PlatformViewIOS::CreateResourceContext() const { return ios_context_->CreateResourceContext(); } diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index 30b90ef3d5d3c..6b3fa9ceaddbb 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -310,7 +310,7 @@ InferPlatformViewCreationCallback( } static sk_sp MakeSkSurfaceFromBackingStore( - GrContext* context, + GrDirectContext* context, const FlutterBackingStoreConfig& config, const FlutterOpenGLTexture* texture) { GrGLTextureInfo texture_info; @@ -350,7 +350,7 @@ static sk_sp MakeSkSurfaceFromBackingStore( } static sk_sp MakeSkSurfaceFromBackingStore( - GrContext* context, + GrDirectContext* context, const FlutterBackingStoreConfig& config, const FlutterOpenGLFramebuffer* framebuffer) { GrGLFramebufferInfo framebuffer_info = {}; @@ -389,7 +389,7 @@ static sk_sp MakeSkSurfaceFromBackingStore( } static sk_sp MakeSkSurfaceFromBackingStore( - GrContext* context, + GrDirectContext* context, const FlutterBackingStoreConfig& config, const FlutterSoftwareBackingStore* software) { const auto image_info = @@ -427,7 +427,7 @@ static sk_sp MakeSkSurfaceFromBackingStore( static std::unique_ptr CreateEmbedderRenderTarget(const FlutterCompositor* compositor, const FlutterBackingStoreConfig& config, - GrContext* context) { + GrDirectContext* context) { FlutterBackingStore backing_store = {}; backing_store.struct_size = sizeof(backing_store); @@ -517,7 +517,7 @@ InferExternalViewEmbedderFromArgs(const FlutterCompositor* compositor) { flutter::EmbedderExternalViewEmbedder::CreateRenderTargetCallback create_render_target_callback = - [captured_compositor](GrContext* context, const auto& config) { + [captured_compositor](GrDirectContext* context, const auto& config) { return CreateEmbedderRenderTarget(&captured_compositor, config, context); }; @@ -1005,7 +1005,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version, nullptr) != nullptr) { external_texture_callback = [ptr = open_gl_config->gl_external_texture_frame_callback, user_data]( - int64_t texture_identifier, GrContext* context, + int64_t texture_identifier, GrDirectContext* context, const SkISize& size) -> sk_sp { FlutterOpenGLTexture texture = {}; diff --git a/shell/platform/embedder/embedder_external_texture_gl.cc b/shell/platform/embedder/embedder_external_texture_gl.cc index 47d25721d169f..11432d104c449 100644 --- a/shell/platform/embedder/embedder_external_texture_gl.cc +++ b/shell/platform/embedder/embedder_external_texture_gl.cc @@ -21,11 +21,11 @@ EmbedderExternalTextureGL::~EmbedderExternalTextureGL() = default; void EmbedderExternalTextureGL::Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) { if (auto image = external_texture_callback_( Id(), // - canvas.getGrContext(), // + context, // SkISize::Make(bounds.width(), bounds.height()) // )) { last_image_ = image; diff --git a/shell/platform/embedder/embedder_external_texture_gl.h b/shell/platform/embedder/embedder_external_texture_gl.h index 30bb63238dc78..0ed2ca5770746 100644 --- a/shell/platform/embedder/embedder_external_texture_gl.h +++ b/shell/platform/embedder/embedder_external_texture_gl.h @@ -14,8 +14,10 @@ namespace flutter { class EmbedderExternalTextureGL : public flutter::Texture { public: - using ExternalTextureCallback = std::function< - sk_sp(int64_t texture_identifier, GrContext*, const SkISize&)>; + using ExternalTextureCallback = + std::function(int64_t texture_identifier, + GrDirectContext*, + const SkISize&)>; EmbedderExternalTextureGL(int64_t texture_identifier, const ExternalTextureCallback& callback); @@ -30,7 +32,7 @@ class EmbedderExternalTextureGL : public flutter::Texture { void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze, - GrContext* context, + GrDirectContext* context, SkFilterQuality filter_quality) override; // |flutter::Texture| diff --git a/shell/platform/embedder/embedder_external_view_embedder.cc b/shell/platform/embedder/embedder_external_view_embedder.cc index d4502187a2685..b69907a8ddbe5 100644 --- a/shell/platform/embedder/embedder_external_view_embedder.cc +++ b/shell/platform/embedder/embedder_external_view_embedder.cc @@ -8,7 +8,7 @@ #include "flutter/shell/platform/embedder/embedder_layers.h" #include "flutter/shell/platform/embedder/embedder_render_target.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -49,7 +49,7 @@ void EmbedderExternalViewEmbedder::CancelFrame() { // |ExternalViewEmbedder| void EmbedderExternalViewEmbedder::BeginFrame( SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) { Reset(); @@ -132,7 +132,7 @@ static FlutterBackingStoreConfig MakeBackingStoreConfig( // |ExternalViewEmbedder| void EmbedderExternalViewEmbedder::SubmitFrame( - GrContext* context, + GrDirectContext* context, std::unique_ptr frame) { auto [matched_render_targets, pending_keys] = render_target_cache_.GetExistingTargetsInCache(pending_views_); diff --git a/shell/platform/embedder/embedder_external_view_embedder.h b/shell/platform/embedder/embedder_external_view_embedder.h index 83473af6526ce..ffc6411b8ad5b 100644 --- a/shell/platform/embedder/embedder_external_view_embedder.h +++ b/shell/platform/embedder/embedder_external_view_embedder.h @@ -30,7 +30,7 @@ class EmbedderExternalViewEmbedder final : public ExternalViewEmbedder { public: using CreateRenderTargetCallback = std::function( - GrContext* context, + GrDirectContext* context, const FlutterBackingStoreConfig& config)>; using PresentCallback = std::function& layers)>; @@ -75,7 +75,7 @@ class EmbedderExternalViewEmbedder final : public ExternalViewEmbedder { // |ExternalViewEmbedder| void BeginFrame( SkISize frame_size, - GrContext* context, + GrDirectContext* context, double device_pixel_ratio, fml::RefPtr raster_thread_merger) override; @@ -91,7 +91,7 @@ class EmbedderExternalViewEmbedder final : public ExternalViewEmbedder { SkCanvas* CompositeEmbeddedView(int view_id) override; // |ExternalViewEmbedder| - void SubmitFrame(GrContext* context, + void SubmitFrame(GrDirectContext* context, std::unique_ptr frame) override; // |ExternalViewEmbedder| diff --git a/shell/platform/embedder/embedder_surface.h b/shell/platform/embedder/embedder_surface.h index b937a55024de2..ed8dbff74b8d0 100644 --- a/shell/platform/embedder/embedder_surface.h +++ b/shell/platform/embedder/embedder_surface.h @@ -21,7 +21,7 @@ class EmbedderSurface { virtual std::unique_ptr CreateGPUSurface() = 0; - virtual sk_sp CreateResourceContext() const = 0; + virtual sk_sp CreateResourceContext() const = 0; private: FML_DISALLOW_COPY_AND_ASSIGN(EmbedderSurface); diff --git a/shell/platform/embedder/embedder_surface_gl.cc b/shell/platform/embedder/embedder_surface_gl.cc index 527fbdd9b75a6..3deb7b5f3032c 100644 --- a/shell/platform/embedder/embedder_surface_gl.cc +++ b/shell/platform/embedder/embedder_surface_gl.cc @@ -90,7 +90,7 @@ std::unique_ptr EmbedderSurfaceGL::CreateGPUSurface() { } // |EmbedderSurface| -sk_sp EmbedderSurfaceGL::CreateResourceContext() const { +sk_sp EmbedderSurfaceGL::CreateResourceContext() const { auto callback = gl_dispatch_table_.gl_make_resource_current_callback; if (callback && callback()) { if (auto context = ShellIOManager::CreateCompatibleResourceLoadingContext( diff --git a/shell/platform/embedder/embedder_surface_gl.h b/shell/platform/embedder/embedder_surface_gl.h index b3c4e094f9eb5..2a3a76748db17 100644 --- a/shell/platform/embedder/embedder_surface_gl.h +++ b/shell/platform/embedder/embedder_surface_gl.h @@ -47,7 +47,7 @@ class EmbedderSurfaceGL final : public EmbedderSurface, std::unique_ptr CreateGPUSurface() override; // |EmbedderSurface| - sk_sp CreateResourceContext() const override; + sk_sp CreateResourceContext() const override; // |GPUSurfaceGLDelegate| std::unique_ptr GLContextMakeCurrent() override; diff --git a/shell/platform/embedder/embedder_surface_software.cc b/shell/platform/embedder/embedder_surface_software.cc index 988ed27d85be0..9472404f0d429 100644 --- a/shell/platform/embedder/embedder_surface_software.cc +++ b/shell/platform/embedder/embedder_surface_software.cc @@ -5,7 +5,7 @@ #include "flutter/shell/platform/embedder/embedder_surface_software.h" #include "flutter/fml/trace_event.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -43,7 +43,7 @@ std::unique_ptr EmbedderSurfaceSoftware::CreateGPUSurface() { } // |EmbedderSurface| -sk_sp EmbedderSurfaceSoftware::CreateResourceContext() const { +sk_sp EmbedderSurfaceSoftware::CreateResourceContext() const { return nullptr; } diff --git a/shell/platform/embedder/embedder_surface_software.h b/shell/platform/embedder/embedder_surface_software.h index 7dcce095634b9..8ed55ceec5b6a 100644 --- a/shell/platform/embedder/embedder_surface_software.h +++ b/shell/platform/embedder/embedder_surface_software.h @@ -39,7 +39,7 @@ class EmbedderSurfaceSoftware final : public EmbedderSurface, std::unique_ptr CreateGPUSurface() override; // |EmbedderSurface| - sk_sp CreateResourceContext() const override; + sk_sp CreateResourceContext() const override; // |GPUSurfaceSoftwareDelegate| sk_sp AcquireBackingStore(const SkISize& size) override; diff --git a/shell/platform/embedder/platform_view_embedder.cc b/shell/platform/embedder/platform_view_embedder.cc index 65e5d56b00714..67d0d3557460b 100644 --- a/shell/platform/embedder/platform_view_embedder.cc +++ b/shell/platform/embedder/platform_view_embedder.cc @@ -74,7 +74,7 @@ std::unique_ptr PlatformViewEmbedder::CreateRenderingSurface() { } // |PlatformView| -sk_sp PlatformViewEmbedder::CreateResourceContext() const { +sk_sp PlatformViewEmbedder::CreateResourceContext() const { if (embedder_surface_ == nullptr) { FML_LOG(ERROR) << "Embedder surface was null."; return nullptr; diff --git a/shell/platform/embedder/platform_view_embedder.h b/shell/platform/embedder/platform_view_embedder.h index c7959bc29372c..47c03d41a4596 100644 --- a/shell/platform/embedder/platform_view_embedder.h +++ b/shell/platform/embedder/platform_view_embedder.h @@ -76,7 +76,7 @@ class PlatformViewEmbedder final : public PlatformView { std::unique_ptr CreateRenderingSurface() override; // |PlatformView| - sk_sp CreateResourceContext() const override; + sk_sp CreateResourceContext() const override; // |PlatformView| std::unique_ptr CreateVSyncWaiter() override; diff --git a/shell/platform/embedder/tests/embedder_test_compositor.cc b/shell/platform/embedder/tests/embedder_test_compositor.cc index 843132643b4b2..04b86091dcc94 100644 --- a/shell/platform/embedder/tests/embedder_test_compositor.cc +++ b/shell/platform/embedder/tests/embedder_test_compositor.cc @@ -12,7 +12,7 @@ namespace flutter { namespace testing { EmbedderTestCompositor::EmbedderTestCompositor(SkISize surface_size, - sk_sp context) + sk_sp context) : surface_size_(surface_size), context_(context) { FML_CHECK(!surface_size_.isEmpty()) << "Surface size must not be empty"; FML_CHECK(context_); diff --git a/shell/platform/embedder/tests/embedder_test_compositor.h b/shell/platform/embedder/tests/embedder_test_compositor.h index ded5cc24b8b08..81481cfed097b 100644 --- a/shell/platform/embedder/tests/embedder_test_compositor.h +++ b/shell/platform/embedder/tests/embedder_test_compositor.h @@ -10,7 +10,7 @@ #include "flutter/fml/closure.h" #include "flutter/fml/macros.h" #include "flutter/shell/platform/embedder/embedder.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { namespace testing { @@ -23,7 +23,7 @@ class EmbedderTestCompositor { kSoftwareBuffer, }; - EmbedderTestCompositor(SkISize surface_size, sk_sp context); + EmbedderTestCompositor(SkISize surface_size, sk_sp context); ~EmbedderTestCompositor(); @@ -38,7 +38,7 @@ class EmbedderTestCompositor { using PlatformViewRendererCallback = std::function(const FlutterLayer& layer, - GrContext* context)>; + GrDirectContext* context)>; void SetPlatformViewRendererCallback( const PlatformViewRendererCallback& callback); @@ -75,7 +75,7 @@ class EmbedderTestCompositor { private: const SkISize surface_size_; - sk_sp context_; + sk_sp context_; RenderTargetType type_ = RenderTargetType::kOpenGLFramebuffer; PlatformViewRendererCallback platform_view_renderer_callback_; bool present_callback_is_one_shot_ = false; diff --git a/shell/platform/embedder/tests/embedder_unittests.cc b/shell/platform/embedder/tests/embedder_unittests.cc index e18157110b837..558669ddb550c 100644 --- a/shell/platform/embedder/tests/embedder_unittests.cc +++ b/shell/platform/embedder/tests/embedder_unittests.cc @@ -1023,7 +1023,7 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderToSoftwareBuffer) { } static sk_sp CreateRenderSurface(const FlutterLayer& layer, - GrContext* context) { + GrDirectContext* context) { const auto image_info = SkImageInfo::MakeN32Premul(layer.size.width, layer.size.height); auto surface = context ? SkSurface::MakeRenderTarget( @@ -1260,7 +1260,8 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderKnownScene) { }); context.GetCompositor().SetPlatformViewRendererCallback( - [&](const FlutterLayer& layer, GrContext* context) -> sk_sp { + [&](const FlutterLayer& layer, + GrDirectContext* context) -> sk_sp { auto surface = CreateRenderSurface(layer, context); auto canvas = surface->getCanvas(); FML_CHECK(canvas != nullptr); @@ -1432,7 +1433,7 @@ TEST_F(EmbedderTest, }); context.GetCompositor().SetPlatformViewRendererCallback( - [&](const FlutterLayer& layer, GrContext* + [&](const FlutterLayer& layer, GrDirectContext* /* don't use because software compositor */) -> sk_sp { auto surface = CreateRenderSurface( layer, nullptr /* null because software compositor */); @@ -1748,7 +1749,8 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderWithPlatformLayerOnBottom) { }); context.GetCompositor().SetPlatformViewRendererCallback( - [&](const FlutterLayer& layer, GrContext* context) -> sk_sp { + [&](const FlutterLayer& layer, + GrDirectContext* context) -> sk_sp { auto surface = CreateRenderSurface(layer, context); auto canvas = surface->getCanvas(); FML_CHECK(canvas != nullptr); @@ -1917,7 +1919,8 @@ TEST_F(EmbedderTest, }); context.GetCompositor().SetPlatformViewRendererCallback( - [&](const FlutterLayer& layer, GrContext* context) -> sk_sp { + [&](const FlutterLayer& layer, + GrDirectContext* context) -> sk_sp { auto surface = CreateRenderSurface(layer, context); auto canvas = surface->getCanvas(); FML_CHECK(canvas != nullptr); @@ -2219,7 +2222,8 @@ TEST_F(EmbedderTest, CanRenderGradientWithCompositorOnNonRootLayer) { }); context.GetCompositor().SetPlatformViewRendererCallback( - [&](const FlutterLayer& layer, GrContext* context) -> sk_sp { + [&](const FlutterLayer& layer, + GrDirectContext* context) -> sk_sp { auto surface = CreateRenderSurface(layer, context); auto canvas = surface->getCanvas(); FML_CHECK(canvas != nullptr); @@ -2329,7 +2333,8 @@ TEST_F(EmbedderTest, CanRenderGradientWithCompositorOnNonRootLayerWithXform) { }); context.GetCompositor().SetPlatformViewRendererCallback( - [&](const FlutterLayer& layer, GrContext* context) -> sk_sp { + [&](const FlutterLayer& layer, + GrDirectContext* context) -> sk_sp { auto surface = CreateRenderSurface(layer, context); auto canvas = surface->getCanvas(); FML_CHECK(canvas != nullptr); @@ -2991,7 +2996,8 @@ TEST_F(EmbedderTest, VerifyB143464703WithSoftwareBackend) { }); context.GetCompositor().SetPlatformViewRendererCallback( - [](const FlutterLayer& layer, GrContext* context) -> sk_sp { + [](const FlutterLayer& layer, + GrDirectContext* context) -> sk_sp { auto surface = CreateRenderSurface( layer, nullptr /* null because software compositor */); auto canvas = surface->getCanvas(); diff --git a/shell/platform/fuchsia/flutter/compositor_context.cc b/shell/platform/fuchsia/flutter/compositor_context.cc index b92e0f3d1a99f..b0bbfc7ecbc28 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.cc +++ b/shell/platform/fuchsia/flutter/compositor_context.cc @@ -5,6 +5,7 @@ #include "compositor_context.h" #include "flutter/flow/layers/layer_tree.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter_runner { @@ -112,7 +113,7 @@ CompositorContext::~CompositorContext() { std::unique_ptr CompositorContext::AcquireFrame( - GrContext* gr_context, + GrDirectContext* gr_context, SkCanvas* canvas, flutter::ExternalViewEmbedder* view_embedder, const SkMatrix& root_surface_transformation, diff --git a/shell/platform/fuchsia/flutter/compositor_context.h b/shell/platform/fuchsia/flutter/compositor_context.h index 04974bf21b15e..6ad28785b119c 100644 --- a/shell/platform/fuchsia/flutter/compositor_context.h +++ b/shell/platform/fuchsia/flutter/compositor_context.h @@ -49,7 +49,7 @@ class CompositorContext final : public flutter::CompositorContext { // |flutter::CompositorContext| std::unique_ptr AcquireFrame( - GrContext* gr_context, + GrDirectContext* gr_context, SkCanvas* canvas, flutter::ExternalViewEmbedder* view_embedder, const SkMatrix& root_surface_transformation, diff --git a/shell/platform/fuchsia/flutter/surface.cc b/shell/platform/fuchsia/flutter/surface.cc index 36252a8eeba01..ba916fce2a41e 100644 --- a/shell/platform/fuchsia/flutter/surface.cc +++ b/shell/platform/fuchsia/flutter/surface.cc @@ -35,7 +35,7 @@ std::unique_ptr Surface::AcquireFrame( } // |flutter::Surface| -GrContext* Surface::GetContext() { +GrDirectContext* Surface::GetContext() { return nullptr; } diff --git a/shell/platform/fuchsia/flutter/surface.h b/shell/platform/fuchsia/flutter/surface.h index 23e159086d48e..7040f0b742663 100644 --- a/shell/platform/fuchsia/flutter/surface.h +++ b/shell/platform/fuchsia/flutter/surface.h @@ -33,7 +33,7 @@ class Surface final : public flutter::Surface { const SkISize& size) override; // |flutter::Surface| - GrContext* GetContext() override; + GrDirectContext* GetContext() override; // |flutter::Surface| SkMatrix GetRootTransformation() const override; diff --git a/shell/platform/fuchsia/flutter/vulkan_surface.cc b/shell/platform/fuchsia/flutter/vulkan_surface.cc index 8587e0e1ae655..0d117047e7ea2 100644 --- a/shell/platform/fuchsia/flutter/vulkan_surface.cc +++ b/shell/platform/fuchsia/flutter/vulkan_surface.cc @@ -13,7 +13,7 @@ #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/gpu/GrBackendSemaphore.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter_runner { @@ -104,7 +104,7 @@ bool CreateVulkanImage(vulkan::VulkanProvider& vulkan_provider, } VulkanSurface::VulkanSurface(vulkan::VulkanProvider& vulkan_provider, - sk_sp context, + sk_sp context, scenic::Session* session, const SkISize& size) : vulkan_provider_(vulkan_provider), session_(session), wait_(this) { @@ -226,7 +226,7 @@ bool VulkanSurface::CreateFences() { return true; } -bool VulkanSurface::AllocateDeviceMemory(sk_sp context, +bool VulkanSurface::AllocateDeviceMemory(sk_sp context, const SkISize& size, zx::vmo& exported_vmo) { if (size.isEmpty()) { @@ -323,7 +323,7 @@ bool VulkanSurface::AllocateDeviceMemory(sk_sp context, image_create_info, memory_reqs); } -bool VulkanSurface::SetupSkiaSurface(sk_sp context, +bool VulkanSurface::SetupSkiaSurface(sk_sp context, const SkISize& size, SkColorType color_type, const VkImageCreateInfo& image_create_info, @@ -407,7 +407,7 @@ sk_sp VulkanSurface::GetSkiaSurface() const { return valid_ ? sk_surface_ : nullptr; } -bool VulkanSurface::BindToImage(sk_sp context, +bool VulkanSurface::BindToImage(sk_sp context, VulkanImage vulkan_image) { FML_DCHECK(vulkan_image.vk_memory_requirements.size <= vk_memory_info_.allocationSize); diff --git a/shell/platform/fuchsia/flutter/vulkan_surface.h b/shell/platform/fuchsia/flutter/vulkan_surface.h index 545808e0d49e8..e6b7eb4e8943a 100644 --- a/shell/platform/fuchsia/flutter/vulkan_surface.h +++ b/shell/platform/fuchsia/flutter/vulkan_surface.h @@ -48,7 +48,7 @@ class VulkanSurface final : public flutter::SceneUpdateContext::SurfaceProducerSurface { public: VulkanSurface(vulkan::VulkanProvider& vulkan_provider, - sk_sp context, + sk_sp context, scenic::Session* session, const SkISize& size); @@ -117,7 +117,7 @@ class VulkanSurface final // than or equal the amount of memory contained in |vk_memory_|. Returns // whether the swap was successful. The |VulkanSurface| will become invalid // if the swap was not successful. - bool BindToImage(sk_sp context, VulkanImage vulkan_image); + bool BindToImage(sk_sp context, VulkanImage vulkan_image); // Flutter may retain a |VulkanSurface| for a |flutter::Layer| subtree to // improve the performance. The |retained_key_| identifies which layer subtree @@ -162,11 +162,11 @@ class VulkanSurface final zx_status_t status, const zx_packet_signal_t* signal); - bool AllocateDeviceMemory(sk_sp context, + bool AllocateDeviceMemory(sk_sp context, const SkISize& size, zx::vmo& exported_vmo); - bool SetupSkiaSurface(sk_sp context, + bool SetupSkiaSurface(sk_sp context, const SkISize& size, SkColorType color_type, const VkImageCreateInfo& image_create_info, diff --git a/shell/platform/fuchsia/flutter/vulkan_surface_pool.cc b/shell/platform/fuchsia/flutter/vulkan_surface_pool.cc index 03eb1638ddb48..cb40dd25ddbb3 100644 --- a/shell/platform/fuchsia/flutter/vulkan_surface_pool.cc +++ b/shell/platform/fuchsia/flutter/vulkan_surface_pool.cc @@ -8,7 +8,7 @@ #include #include "flutter/fml/trace_event.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter_runner { @@ -22,7 +22,7 @@ std::string ToString(const SkISize& size) { } // namespace VulkanSurfacePool::VulkanSurfacePool(vulkan::VulkanProvider& vulkan_provider, - sk_sp context, + sk_sp context, scenic::Session* scenic_session) : vulkan_provider_(vulkan_provider), context_(std::move(context)), diff --git a/shell/platform/fuchsia/flutter/vulkan_surface_pool.h b/shell/platform/fuchsia/flutter/vulkan_surface_pool.h index 23f8551356265..302be9bac7b8a 100644 --- a/shell/platform/fuchsia/flutter/vulkan_surface_pool.h +++ b/shell/platform/fuchsia/flutter/vulkan_surface_pool.h @@ -21,7 +21,7 @@ class VulkanSurfacePool final { static constexpr int kMaxSurfaceAge = 3; VulkanSurfacePool(vulkan::VulkanProvider& vulkan_provider, - sk_sp context, + sk_sp context, scenic::Session* scenic_session); ~VulkanSurfacePool(); @@ -59,7 +59,7 @@ class VulkanSurfacePool final { }; vulkan::VulkanProvider& vulkan_provider_; - sk_sp context_; + sk_sp context_; scenic::Session* scenic_session_; std::vector> available_surfaces_; std::unordered_map> diff --git a/shell/platform/fuchsia/flutter/vulkan_surface_producer.cc b/shell/platform/fuchsia/flutter/vulkan_surface_producer.cc index 27b215181bd26..1e0d03df847a8 100644 --- a/shell/platform/fuchsia/flutter/vulkan_surface_producer.cc +++ b/shell/platform/fuchsia/flutter/vulkan_surface_producer.cc @@ -14,7 +14,7 @@ #include "flutter/fml/trace_event.h" #include "third_party/skia/include/gpu/GrBackendSemaphore.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/skia/include/gpu/vk/GrVkBackendContext.h" #include "third_party/skia/include/gpu/vk/GrVkExtensions.h" #include "third_party/skia/include/gpu/vk/GrVkTypes.h" @@ -138,10 +138,10 @@ bool VulkanSurfaceProducer::Initialize(scenic::Session* scenic_session) { countof(device_extensions), device_extensions); backend_context.fVkExtensions = &vk_extensions; - context_ = GrContext::MakeVulkan(backend_context); + context_ = GrDirectContext::MakeVulkan(backend_context); if (context_ == nullptr) { - FML_LOG(ERROR) << "Failed to create GrContext."; + FML_LOG(ERROR) << "Failed to create GrDirectContext."; return false; } diff --git a/shell/platform/fuchsia/flutter/vulkan_surface_producer.h b/shell/platform/fuchsia/flutter/vulkan_surface_producer.h index efc7275c53e66..403ecd19bebbe 100644 --- a/shell/platform/fuchsia/flutter/vulkan_surface_producer.h +++ b/shell/platform/fuchsia/flutter/vulkan_surface_producer.h @@ -66,7 +66,7 @@ class VulkanSurfaceProducer final width_change_factor, height_change_factor); } - GrContext* gr_context() { return context_.get(); } + GrDirectContext* gr_context() { return context_.get(); } private: // VulkanProvider @@ -86,7 +86,7 @@ class VulkanSurfaceProducer final fml::RefPtr vk_; std::unique_ptr application_; std::unique_ptr logical_device_; - sk_sp context_; + sk_sp context_; std::unique_ptr surface_pool_; bool valid_ = false; diff --git a/testing/test_gl_surface.cc b/testing/test_gl_surface.cc index 90a9fb1f70f10..2b5f40b126137 100644 --- a/testing/test_gl_surface.cc +++ b/testing/test_gl_surface.cc @@ -248,17 +248,15 @@ void* TestGLSurface::GetProcAddress(const char* name) const { return reinterpret_cast(symbol); } -sk_sp TestGLSurface::GetGrContext() { +sk_sp TestGLSurface::GetGrContext() { if (context_) { return context_; } - context_ = CreateGrContext(); - - return context_; + return CreateGrContext(); } -sk_sp TestGLSurface::CreateGrContext() { +sk_sp TestGLSurface::CreateGrContext() { if (!MakeCurrent()) { return nullptr; } @@ -290,7 +288,7 @@ sk_sp TestGLSurface::CreateGrContext() { return nullptr; } - context_ = GrContext::MakeGL(interface); + context_ = GrDirectContext::MakeGL(interface); return context_; } diff --git a/testing/test_gl_surface.h b/testing/test_gl_surface.h index f75b0afee2c8c..c7ceac4030341 100644 --- a/testing/test_gl_surface.h +++ b/testing/test_gl_surface.h @@ -8,7 +8,7 @@ #include #include "flutter/fml/macros.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { namespace testing { @@ -35,9 +35,9 @@ class TestGLSurface { sk_sp GetOnscreenSurface(); - sk_sp GetGrContext(); + sk_sp GetGrContext(); - sk_sp CreateGrContext(); + sk_sp CreateGrContext(); sk_sp GetRasterSurfaceSnapshot(); @@ -56,7 +56,7 @@ class TestGLSurface { EGLContext offscreen_context_; EGLSurface onscreen_surface_; EGLSurface offscreen_surface_; - sk_sp context_; + sk_sp context_; FML_DISALLOW_COPY_AND_ASSIGN(TestGLSurface); }; diff --git a/testing/test_metal_surface.cc b/testing/test_metal_surface.cc index d108681e0fcba..9d93715b7c107 100644 --- a/testing/test_metal_surface.cc +++ b/testing/test_metal_surface.cc @@ -35,7 +35,7 @@ bool TestMetalSurface::IsValid() const { return impl_ ? impl_->IsValid() : false; } -sk_sp TestMetalSurface::GetGrContext() const { +sk_sp TestMetalSurface::GetGrContext() const { return impl_ ? impl_->GetGrContext() : nullptr; } diff --git a/testing/test_metal_surface.h b/testing/test_metal_surface.h index e21ad4601cb10..ed81b4bf3346b 100644 --- a/testing/test_metal_surface.h +++ b/testing/test_metal_surface.h @@ -8,7 +8,7 @@ #include "flutter/fml/macros.h" #include "third_party/skia/include/core/SkSize.h" #include "third_party/skia/include/core/SkSurface.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" namespace flutter { @@ -27,7 +27,7 @@ class TestMetalSurface { virtual bool IsValid() const; - virtual sk_sp GetGrContext() const; + virtual sk_sp GetGrContext() const; virtual sk_sp GetSurface() const; diff --git a/testing/test_metal_surface_impl.h b/testing/test_metal_surface_impl.h index c92eceac291c2..5ef5e63d2bcc4 100644 --- a/testing/test_metal_surface_impl.h +++ b/testing/test_metal_surface_impl.h @@ -19,14 +19,14 @@ class TestMetalSurfaceImpl : public TestMetalSurface { private: bool is_valid_ = false; - sk_sp context_; + sk_sp context_; sk_sp surface_; // |TestMetalSurface| bool IsValid() const override; // |TestMetalSurface| - sk_sp GetGrContext() const override; + sk_sp GetGrContext() const override; // |TestMetalSurface| sk_sp GetSurface() const override; diff --git a/testing/test_metal_surface_impl.mm b/testing/test_metal_surface_impl.mm index 9f34530e0ab59..9ba283545f6c1 100644 --- a/testing/test_metal_surface_impl.mm +++ b/testing/test_metal_surface_impl.mm @@ -54,7 +54,7 @@ return; } - auto skia_context = GrContext::MakeMetal(device.get(), command_queue.get()); + auto skia_context = GrDirectContext::MakeMetal(device.get(), command_queue.get()); if (skia_context) { // Skia wants ownership of the device and queue. If a context was created, @@ -63,7 +63,7 @@ FML_ALLOW_UNUSED_LOCAL(device.release()); FML_ALLOW_UNUSED_LOCAL(command_queue.release()); } else { - FML_LOG(ERROR) << "Could not create the GrContext from the Metal Device " + FML_LOG(ERROR) << "Could not create the GrDirectContext from the Metal Device " "and command queue."; return; } @@ -108,7 +108,7 @@ return is_valid_; } // |TestMetalSurface| -sk_sp TestMetalSurfaceImpl::GetGrContext() const { +sk_sp TestMetalSurfaceImpl::GetGrContext() const { return IsValid() ? context_ : nullptr; } // |TestMetalSurface| diff --git a/vulkan/vulkan_swapchain.cc b/vulkan/vulkan_swapchain.cc index 9f53c5fce356b..1ef045e64df2d 100644 --- a/vulkan/vulkan_swapchain.cc +++ b/vulkan/vulkan_swapchain.cc @@ -5,7 +5,7 @@ #include "vulkan_swapchain.h" #include "third_party/skia/include/gpu/GrBackendSurface.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/skia/include/gpu/vk/GrVkTypes.h" #include "vulkan_backbuffer.h" #include "vulkan_device.h" @@ -39,7 +39,7 @@ static std::vector DesiredFormatInfos() { VulkanSwapchain::VulkanSwapchain(const VulkanProcTable& p_vk, const VulkanDevice& device, const VulkanSurface& surface, - GrContext* skia_context, + GrDirectContext* skia_context, std::unique_ptr old_swapchain, uint32_t queue_family_index) : vk(p_vk), @@ -208,7 +208,7 @@ SkISize VulkanSwapchain::GetSize() const { } sk_sp VulkanSwapchain::CreateSkiaSurface( - GrContext* gr_context, + GrDirectContext* gr_context, VkImage image, const SkISize& size, SkColorType color_type, @@ -246,7 +246,7 @@ sk_sp VulkanSwapchain::CreateSkiaSurface( ); } -bool VulkanSwapchain::CreateSwapchainImages(GrContext* skia_context, +bool VulkanSwapchain::CreateSwapchainImages(GrDirectContext* skia_context, SkColorType color_type, sk_sp color_space) { std::vector images = GetImages(); diff --git a/vulkan/vulkan_swapchain.h b/vulkan/vulkan_swapchain.h index 761b98d420aeb..570cbb1092078 100644 --- a/vulkan/vulkan_swapchain.h +++ b/vulkan/vulkan_swapchain.h @@ -28,7 +28,7 @@ class VulkanSwapchain { VulkanSwapchain(const VulkanProcTable& vk, const VulkanDevice& device, const VulkanSurface& surface, - GrContext* skia_context, + GrDirectContext* skia_context, std::unique_ptr old_swapchain, uint32_t queue_family_index); @@ -77,11 +77,11 @@ class VulkanSwapchain { std::vector GetImages() const; - bool CreateSwapchainImages(GrContext* skia_context, + bool CreateSwapchainImages(GrDirectContext* skia_context, SkColorType color_type, sk_sp color_space); - sk_sp CreateSkiaSurface(GrContext* skia_context, + sk_sp CreateSkiaSurface(GrDirectContext* skia_context, VkImage image, const SkISize& size, SkColorType color_type, diff --git a/vulkan/vulkan_swapchain_stub.cc b/vulkan/vulkan_swapchain_stub.cc index 8d9416e4dcf9d..457c6649f1ec2 100644 --- a/vulkan/vulkan_swapchain_stub.cc +++ b/vulkan/vulkan_swapchain_stub.cc @@ -1,6 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// FLUTTER_NOLINT #include "vulkan_swapchain.h" @@ -9,7 +10,7 @@ namespace vulkan { VulkanSwapchain::VulkanSwapchain(const VulkanProcTable& p_vk, const VulkanDevice& device, const VulkanSurface& surface, - GrContext* skia_context, + GrDirectContext* skia_context, std::unique_ptr old_swapchain, uint32_t queue_family_index) {} diff --git a/vulkan/vulkan_window.cc b/vulkan/vulkan_window.cc index 81c635f0a9d09..2e1b99567438f 100644 --- a/vulkan/vulkan_window.cc +++ b/vulkan/vulkan_window.cc @@ -8,7 +8,7 @@ #include #include -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" #include "vulkan_application.h" #include "vulkan_device.h" #include "vulkan_native_surface.h" @@ -75,7 +75,7 @@ VulkanWindow::VulkanWindow(fml::RefPtr proc_table, return; } - // Create the Skia GrContext. + // Create the Skia GrDirectContext. if (!CreateSkiaGrContext()) { FML_DLOG(INFO) << "Could not create Skia context."; @@ -98,7 +98,7 @@ bool VulkanWindow::IsValid() const { return valid_; } -GrContext* VulkanWindow::GetSkiaGrContext() { +GrDirectContext* VulkanWindow::GetSkiaGrContext() { return skia_gr_context_.get(); } @@ -109,7 +109,7 @@ bool VulkanWindow::CreateSkiaGrContext() { return false; } - sk_sp context = GrContext::MakeVulkan(backend_context); + sk_sp context = GrDirectContext::MakeVulkan(backend_context); if (context == nullptr) { return false; diff --git a/vulkan/vulkan_window.h b/vulkan/vulkan_window.h index cc9858da6a237..b67f49707d5db 100644 --- a/vulkan/vulkan_window.h +++ b/vulkan/vulkan_window.h @@ -15,7 +15,7 @@ #include "third_party/skia/include/core/SkRefCnt.h" #include "third_party/skia/include/core/SkSize.h" #include "third_party/skia/include/core/SkSurface.h" -#include "third_party/skia/include/gpu/GrContext.h" +#include "third_party/skia/include/gpu/GrDirectContext.h" #include "third_party/skia/include/gpu/vk/GrVkBackendContext.h" #include "vulkan_proc_table.h" @@ -39,7 +39,7 @@ class VulkanWindow { bool IsValid() const; - GrContext* GetSkiaGrContext(); + GrDirectContext* GetSkiaGrContext(); sk_sp AcquireSurface(); @@ -52,7 +52,7 @@ class VulkanWindow { std::unique_ptr logical_device_; std::unique_ptr surface_; std::unique_ptr swapchain_; - sk_sp skia_gr_context_; + sk_sp skia_gr_context_; bool CreateSkiaGrContext();