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

Unified Diff: services/native_viewport/viewport_surface.cc

Issue 826423008: Use local ids for Surfaces APIs that can only apply to local surfaces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « services/native_viewport/viewport_surface.h ('k') | services/surfaces/surfaces_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/native_viewport/viewport_surface.cc
diff --git a/services/native_viewport/viewport_surface.cc b/services/native_viewport/viewport_surface.cc
index 56149e0c37f9935ac3ce6b365c197c2d4d236065..1ca886d8de1df1059aad9ec1be48802e8829722a 100644
--- a/services/native_viewport/viewport_surface.cc
+++ b/services/native_viewport/viewport_surface.cc
@@ -5,7 +5,6 @@
#include "services/native_viewport/viewport_surface.h"
#include "base/bind.h"
-#include "cc/surfaces/surface_id_allocator.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
#include "mojo/converters/surfaces/surfaces_type_converters.h"
#include "mojo/services/surfaces/public/cpp/surfaces_utils.h"
@@ -14,20 +13,22 @@
using mojo::Size;
using mojo::SurfaceId;
+static uint32_t kGLES2BoundSurfaceLocalId = 1u;
+
namespace native_viewport {
-ViewportSurface::ViewportSurface(mojo::SurfacesService* surfaces_service,
+ViewportSurface::ViewportSurface(mojo::SurfacePtr surface,
mojo::Gpu* gpu_service,
const gfx::Size& size,
cc::SurfaceId child_id)
- : gpu_service_(gpu_service),
+ : surface_(surface.Pass()),
+ gpu_service_(gpu_service),
widget_id_(0u),
size_(size),
+ gles2_bound_surface_created_(false),
child_id_(child_id),
weak_factory_(this) {
- surfaces_service->CreateSurfaceConnection(
- base::Bind(&ViewportSurface::OnSurfaceConnectionCreated,
- weak_factory_.GetWeakPtr()));
+ surface_.set_client(this);
}
ViewportSurface::~ViewportSurface() {
@@ -35,8 +36,7 @@ ViewportSurface::~ViewportSurface() {
void ViewportSurface::SetWidgetId(uint64_t widget_id) {
widget_id_ = widget_id;
- if (id_allocator_)
- BindSurfaceToNativeViewport();
+ BindSurfaceToNativeViewport();
}
void ViewportSurface::SetSize(const gfx::Size& size) {
@@ -44,10 +44,10 @@ void ViewportSurface::SetSize(const gfx::Size& size) {
return;
size_ = size;
- if (id_.is_null())
+ if (!gles2_bound_surface_created_)
return;
- surface_->DestroySurface(SurfaceId::From(id_));
+ surface_->DestroySurface(kGLES2BoundSurfaceLocalId);
if (widget_id_)
BindSurfaceToNativeViewport();
}
@@ -57,15 +57,6 @@ void ViewportSurface::SetChildId(cc::SurfaceId child_id) {
SubmitFrame();
}
-void ViewportSurface::OnSurfaceConnectionCreated(mojo::SurfacePtr surface,
- uint32_t id_namespace) {
- surface_ = surface.Pass();
- surface_.set_client(this);
- id_allocator_.reset(new cc::SurfaceIdAllocator(id_namespace));
- if (widget_id_ != 0u)
- BindSurfaceToNativeViewport();
-}
-
void ViewportSurface::BindSurfaceToNativeViewport() {
mojo::ViewportParameterListenerPtr listener;
auto listener_request = GetProxy(&listener);
@@ -74,15 +65,16 @@ void ViewportSurface::BindSurfaceToNativeViewport() {
GetProxy(&command_buffer),
listener.Pass());
- id_ = id_allocator_->GenerateId();
- surface_->CreateGLES2BoundSurface(command_buffer.Pass(), SurfaceId::From(id_),
+ gles2_bound_surface_created_ = true;
+ surface_->CreateGLES2BoundSurface(command_buffer.Pass(),
+ kGLES2BoundSurfaceLocalId,
Size::From(size_), listener_request.Pass());
SubmitFrame();
}
void ViewportSurface::SubmitFrame() {
- if (child_id_.is_null() || id_.is_null())
+ if (child_id_.is_null() || !gles2_bound_surface_created_)
return;
auto surface_quad_state = mojo::SurfaceQuadState::New();
@@ -108,10 +100,13 @@ void ViewportSurface::SubmitFrame() {
auto frame = mojo::Frame::New();
frame->passes.push_back(pass.Pass());
frame->resources.resize(0u);
- surface_->SubmitFrame(SurfaceId::From(id_), frame.Pass(), mojo::Closure());
+ surface_->SubmitFrame(kGLES2BoundSurfaceLocalId, frame.Pass(),
+ mojo::Closure());
}
void ViewportSurface::SetIdNamespace(uint32_t id_namespace) {
+ // We never pass our surface ID to anyone else, so we never need to generate a
+ // fully qualified id and thus don't care about our namespace.
}
void ViewportSurface::ReturnResources(
« no previous file with comments | « services/native_viewport/viewport_surface.h ('k') | services/surfaces/surfaces_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698