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

Unified Diff: cc/surfaces/surface_display_output_surface.cc

Issue 2036563002: Delete OnscreenDisplayClient and TopLevelDisplayClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: onscreendisplayclient: webview-scoped-allow-gl-for-hardwarerenderer-constructor Created 4 years, 6 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: cc/surfaces/surface_display_output_surface.cc
diff --git a/cc/surfaces/surface_display_output_surface.cc b/cc/surfaces/surface_display_output_surface.cc
index d2093ac026a8de76ea6b87fbdcdff878f284b2d1..73dd6e3581b67d74fd306e87b77818b4749a9465 100644
--- a/cc/surfaces/surface_display_output_surface.cc
+++ b/cc/surfaces/surface_display_output_surface.cc
@@ -8,103 +8,121 @@
#include "cc/output/compositor_frame.h"
#include "cc/output/compositor_frame_ack.h"
#include "cc/surfaces/display.h"
-#include "cc/surfaces/onscreen_display_client.h"
#include "cc/surfaces/surface.h"
+#include "cc/surfaces/surface_id_allocator.h"
#include "cc/surfaces/surface_manager.h"
namespace cc {
SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface(
SurfaceManager* surface_manager,
- SurfaceIdAllocator* allocator,
+ SurfaceIdAllocator* surface_id_allocator,
+ Display* display,
scoped_refptr<ContextProvider> context_provider,
scoped_refptr<ContextProvider> worker_context_provider)
: OutputSurface(std::move(context_provider),
std::move(worker_context_provider),
nullptr),
- display_client_(nullptr),
- factory_(surface_manager, this),
- allocator_(allocator) {
- factory_.set_needs_sync_points(false);
+ surface_manager_(surface_manager),
+ surface_id_allocator_(surface_id_allocator),
+ display_(display),
+ factory_(surface_manager, this) {
+ DCHECK(thread_checker_.CalledOnValidThread());
capabilities_.delegated_rendering = true;
capabilities_.adjust_deadline_for_parent = true;
capabilities_.can_force_reclaim_resources = true;
+
// Display and SurfaceDisplayOutputSurface share a GL context, so sync
// points aren't needed when passing resources between them.
capabilities_.delegated_sync_points_required = false;
+ factory_.set_needs_sync_points(false);
}
SurfaceDisplayOutputSurface::SurfaceDisplayOutputSurface(
SurfaceManager* surface_manager,
- SurfaceIdAllocator* allocator,
+ SurfaceIdAllocator* surface_id_allocator,
+ Display* display,
scoped_refptr<VulkanContextProvider> vulkan_context_provider)
: OutputSurface(std::move(vulkan_context_provider)),
- display_client_(nullptr),
- factory_(surface_manager, this),
- allocator_(allocator) {
+ surface_manager_(surface_manager),
+ surface_id_allocator_(surface_id_allocator),
+ display_(display),
+ factory_(surface_manager, this) {
+ DCHECK(thread_checker_.CalledOnValidThread());
capabilities_.delegated_rendering = true;
capabilities_.adjust_deadline_for_parent = true;
capabilities_.can_force_reclaim_resources = true;
}
SurfaceDisplayOutputSurface::~SurfaceDisplayOutputSurface() {
+ DCHECK(thread_checker_.CalledOnValidThread());
if (HasClient())
DetachFromClient();
- if (!surface_id_.is_null()) {
- factory_.Destroy(surface_id_);
- }
}
void SurfaceDisplayOutputSurface::SwapBuffers(CompositorFrame* frame) {
gfx::Size frame_size =
frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
- if (frame_size.IsEmpty() || frame_size != display_size_) {
- if (!surface_id_.is_null()) {
- factory_.Destroy(surface_id_);
+ if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) {
+ if (!delegated_surface_id_.is_null()) {
+ factory_.Destroy(delegated_surface_id_);
}
- surface_id_ = allocator_->GenerateId();
- factory_.Create(surface_id_);
- display_size_ = frame_size;
+ delegated_surface_id_ = surface_id_allocator_->GenerateId();
+ factory_.Create(delegated_surface_id_);
+ last_swap_frame_size_ = frame_size;
}
- display_client_->display()->SetSurfaceId(surface_id_,
- frame->metadata.device_scale_factor);
+ display_->SetSurfaceId(delegated_surface_id_,
+ frame->metadata.device_scale_factor);
client_->DidSwapBuffers();
std::unique_ptr<CompositorFrame> frame_copy(new CompositorFrame());
frame->AssignTo(frame_copy.get());
factory_.SubmitCompositorFrame(
- surface_id_, std::move(frame_copy),
+ delegated_surface_id_, std::move(frame_copy),
base::Bind(&SurfaceDisplayOutputSurface::SwapBuffersComplete,
base::Unretained(this)));
}
bool SurfaceDisplayOutputSurface::BindToClient(OutputSurfaceClient* client) {
- DCHECK(client);
- DCHECK(display_client_);
- client_ = client;
- factory_.manager()->RegisterSurfaceFactoryClient(allocator_->id_namespace(),
- this);
-
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!OutputSurface::BindToClient(client))
+ return false;
+
+ // We want the Display's output surface to hear about lost context, and since
+ // this shares a context with it, we should not be listening for lost context
+ // callbacks on the context here.
+ if (context_provider())
+ context_provider()->SetLostContextCallback(base::Closure());
+
+ surface_manager_->RegisterSurfaceFactoryClient(
+ surface_id_allocator_->id_namespace(), this);
// Avoid initializing GL context here, as this should be sharing the
// Display's context.
- return display_client_->Initialize();
+ bool init = display_->Initialize(this);
+ // Since this class shares its GL context with the Display, Initialize should
+ // not be possible to fail.
+ DCHECK(init);
+ return true;
}
void SurfaceDisplayOutputSurface::ForceReclaimResources() {
- if (!surface_id_.is_null())
- factory_.SubmitCompositorFrame(surface_id_, nullptr,
+ if (!delegated_surface_id_.is_null()) {
+ factory_.SubmitCompositorFrame(delegated_surface_id_, nullptr,
SurfaceFactory::DrawCallback());
+ }
}
void SurfaceDisplayOutputSurface::DetachFromClient() {
DCHECK(HasClient());
// Unregister the SurfaceFactoryClient here instead of the dtor so that only
// one client is alive for this namespace at any given time.
- factory_.manager()->UnregisterSurfaceFactoryClient(
- allocator_->id_namespace());
+ surface_manager_->UnregisterSurfaceFactoryClient(
+ surface_id_allocator_->id_namespace());
+ if (!delegated_surface_id_.is_null())
+ factory_.Destroy(delegated_surface_id_);
+
OutputSurface::DetachFromClient();
- DCHECK(!HasClient());
}
void SurfaceDisplayOutputSurface::ReturnResources(
@@ -121,8 +139,19 @@ void SurfaceDisplayOutputSurface::SetBeginFrameSource(
client_->SetBeginFrameSource(begin_frame_source);
}
+void SurfaceDisplayOutputSurface::DisplayOutputSurfaceLost() {
+ output_surface_lost_ = true;
+ DidLoseOutputSurface();
+}
+
+void SurfaceDisplayOutputSurface::DisplaySetMemoryPolicy(
+ const ManagedMemoryPolicy& policy) {
+ SetMemoryPolicy(policy);
+}
+
void SurfaceDisplayOutputSurface::SwapBuffersComplete(SurfaceDrawStatus drawn) {
- if (client_ && !display_client_->output_surface_lost())
+ // TODO(danakj): Why the lost check?
+ if (!output_surface_lost_)
client_->DidSwapBuffersComplete();
}
« no previous file with comments | « cc/surfaces/surface_display_output_surface.h ('k') | cc/surfaces/surface_display_output_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698