Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Unified Diff: mandoline/ui/aura/surface_binding.cc

Issue 1281663002: Mandoline: Allow submitting CompositorFrames directly to mojo::Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a TODO Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mandoline/ui/aura/surface_binding.cc
diff --git a/mandoline/ui/aura/surface_binding.cc b/mandoline/ui/aura/surface_binding.cc
index 0307112933fceeb8ce58269451d00152e885bbbb..8cc60f63a241d506ba05c2bfcfcede53f63d81dd 100644
--- a/mandoline/ui/aura/surface_binding.cc
+++ b/mandoline/ui/aura/surface_binding.cc
@@ -17,87 +17,15 @@
#include "components/view_manager/public/cpp/view.h"
#include "components/view_manager/public/cpp/view_manager.h"
#include "components/view_manager/public/interfaces/gpu.mojom.h"
-#include "components/view_manager/public/interfaces/surfaces.mojom.h"
#include "mandoline/ui/aura/window_tree_host_mojo.h"
#include "mojo/application/public/cpp/connect.h"
#include "mojo/application/public/interfaces/shell.mojom.h"
#include "mojo/cc/context_provider_mojo.h"
+#include "mojo/cc/output_surface_mojo.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/surfaces/surfaces_type_converters.h"
namespace mandoline {
-namespace {
-
-// OutputSurface ---------------------------------------------------------------
-
-// OutputSurface implementation for a view. Pushes the surface id to View when
-// appropriate.
-class OutputSurfaceImpl : public cc::OutputSurface {
- public:
- OutputSurfaceImpl(mojo::View* view,
- const scoped_refptr<cc::ContextProvider>& context_provider,
- mojo::Surface* surface,
- uint32_t id_namespace,
- uint32_t* next_local_id);
- ~OutputSurfaceImpl() override;
-
- // cc::OutputSurface:
- void SwapBuffers(cc::CompositorFrame* frame) override;
-
- private:
- mojo::View* view_;
- mojo::Surface* surface_;
- uint32_t id_namespace_;
- uint32_t* next_local_id_; // Owned by PerViewManagerState.
- uint32_t local_id_;
- gfx::Size surface_size_;
-
- DISALLOW_COPY_AND_ASSIGN(OutputSurfaceImpl);
-};
-
-OutputSurfaceImpl::OutputSurfaceImpl(
- mojo::View* view,
- const scoped_refptr<cc::ContextProvider>& context_provider,
- mojo::Surface* surface,
- uint32_t id_namespace,
- uint32_t* next_local_id)
- : cc::OutputSurface(context_provider),
- view_(view),
- surface_(surface),
- id_namespace_(id_namespace),
- next_local_id_(next_local_id),
- local_id_(0u) {
- capabilities_.delegated_rendering = true;
- capabilities_.max_frames_pending = 1;
-}
-
-OutputSurfaceImpl::~OutputSurfaceImpl() {
-}
-
-void OutputSurfaceImpl::SwapBuffers(cc::CompositorFrame* frame) {
- gfx::Size frame_size =
- frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
- if (frame_size != surface_size_) {
- if (local_id_ != 0u)
- surface_->DestroySurface(local_id_);
- local_id_ = (*next_local_id_)++;
- surface_->CreateSurface(local_id_);
- auto qualified_id = mojo::SurfaceId::New();
- qualified_id->local = local_id_;
- qualified_id->id_namespace = id_namespace_;
- view_->SetSurfaceId(qualified_id.Pass());
- surface_size_ = frame_size;
- }
-
- surface_->SubmitFrame(local_id_,
- mojo::CompositorFrame::From(*frame),
- mojo::Closure());
-
- client_->DidSwapBuffers();
- client_->DidSwapBuffersComplete();
-}
-
-} // namespace
// PerViewManagerState ---------------------------------------------------------
@@ -130,8 +58,6 @@ class SurfaceBinding::PerViewManagerState
void ReturnResources(
mojo::Array<mojo::ReturnedResourcePtr> resources) override;
- void SetIdNamespace(uint32_t id_namespace);
-
static base::LazyInstance<
base::ThreadLocalPointer<ViewManagerToStateMap>>::Leaky view_states;
@@ -140,10 +66,7 @@ class SurfaceBinding::PerViewManagerState
// Set of state needed to create an OutputSurface.
mojo::GpuPtr gpu_;
- mojo::SurfacePtr surface_;
mojo::Binding<mojo::ResourceReturner> returner_binding_;
- uint32_t id_namespace_;
- uint32_t next_local_id_;
DISALLOW_COPY_AND_ASSIGN(PerViewManagerState);
};
@@ -175,10 +98,14 @@ SurfaceBinding::PerViewManagerState::CreateOutputSurface(mojo::View* view) {
// value outliving this?
mojo::CommandBufferPtr cb;
gpu_->CreateOffscreenGLES2Context(GetProxy(&cb));
+
+ mojo::CompositorFrameReceiverPtr cc_frame_receiver;
+ view->RequestCompositorFrameReceiver(GetProxy(&cc_frame_receiver));
scoped_refptr<cc::ContextProvider> context_provider(
new mojo::ContextProviderMojo(cb.PassInterface().PassHandle()));
- return make_scoped_ptr(new OutputSurfaceImpl(
- view, context_provider, surface_.get(), id_namespace_, &next_local_id_));
+ return make_scoped_ptr(
+ new mojo::OutputSurfaceMojo(context_provider,
+ cc_frame_receiver.PassInterface()));
}
SurfaceBinding::PerViewManagerState::PerViewManagerState(
@@ -186,9 +113,7 @@ SurfaceBinding::PerViewManagerState::PerViewManagerState(
mojo::ViewManager* view_manager)
: shell_(shell),
view_manager_(view_manager),
- returner_binding_(this),
- id_namespace_(0u),
- next_local_id_(0u) {
+ returner_binding_(this) {
}
SurfaceBinding::PerViewManagerState::~PerViewManagerState() {
@@ -203,41 +128,14 @@ SurfaceBinding::PerViewManagerState::~PerViewManagerState() {
}
void SurfaceBinding::PerViewManagerState::Init() {
- DCHECK(!surface_.get());
-
- mojo::ServiceProviderPtr surfaces_service_provider;
+ mojo::ServiceProviderPtr service_provider;
mojo::URLRequestPtr request(mojo::URLRequest::New());
request->url = mojo::String::From("mojo:view_manager");
shell_->ConnectToApplication(request.Pass(),
- GetProxy(&surfaces_service_provider),
+ GetProxy(&service_provider),
nullptr,
nullptr);
- ConnectToService(surfaces_service_provider.get(), &surface_);
- surface_->GetIdNamespace(
- base::Bind(&SurfaceBinding::PerViewManagerState::SetIdNamespace,
- base::Unretained(this)));
- // Block until we receive our id namespace.
- surface_.WaitForIncomingResponse();
- DCHECK_NE(0u, id_namespace_);
-
- mojo::ResourceReturnerPtr returner_ptr;
- returner_binding_.Bind(GetProxy(&returner_ptr));
- surface_->SetResourceReturner(returner_ptr.Pass());
-
- mojo::ServiceProviderPtr gpu_service_provider;
- // TODO(jamesr): Should be mojo:gpu_service
- mojo::URLRequestPtr request2(mojo::URLRequest::New());
- request2->url = mojo::String::From("mojo:view_manager");
- shell_->ConnectToApplication(request2.Pass(),
- GetProxy(&gpu_service_provider),
- nullptr,
- nullptr);
- ConnectToService(gpu_service_provider.get(), &gpu_);
-}
-
-void SurfaceBinding::PerViewManagerState::SetIdNamespace(
- uint32_t id_namespace) {
- id_namespace_ = id_namespace;
+ ConnectToService(service_provider.get(), &gpu_);
}
void SurfaceBinding::PerViewManagerState::ReturnResources(

Powered by Google App Engine
This is Rietveld 408576698