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

Side by Side Diff: components/mus/surfaces/display_compositor.cc

Issue 1976663003: Pull parts of TopLevelDisplayClient into DisplayCompositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RegisterSurfaceIdNamespace Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/mus/surfaces/display_compositor.h"
6
7 #include "cc/output/copy_output_request.h"
8 #include "cc/output/output_surface.h"
9 #include "cc/output/renderer_settings.h"
10 #include "cc/surfaces/display.h"
11 #include "components/mus/surfaces/direct_output_surface.h"
12 #include "components/mus/surfaces/surfaces_context_provider.h"
13 #include "components/mus/surfaces/top_level_display_client.h"
14
15 #if defined(USE_OZONE)
16 #include "components/mus/surfaces/direct_output_surface_ozone.h"
17 #include "gpu/command_buffer/client/gles2_interface.h"
18 #endif
19
20 namespace mus {
21
22 DisplayCompositor::DisplayCompositor(
23 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
24 gfx::AcceleratedWidget widget,
25 const scoped_refptr<GpuState>& gpu_state,
26 const scoped_refptr<SurfacesState>& surfaces_state)
27 : task_runner_(task_runner),
28 surfaces_state_(surfaces_state),
29 factory_(surfaces_state->manager(), this),
30 allocator_(surfaces_state->next_id_namespace()) {
31 allocator_.RegisterSurfaceIdNamespace(surfaces_state_->manager());
32 surfaces_state_->manager()->RegisterSurfaceFactoryClient(
33 allocator_.id_namespace(), this);
34
35 scoped_refptr<SurfacesContextProvider> surfaces_context_provider(
36 new SurfacesContextProvider(widget, gpu_state));
37 // TODO(rjkroege): If there is something better to do than CHECK, add it.
38 CHECK(surfaces_context_provider->BindToCurrentThread());
39
40 std::unique_ptr<cc::OutputSurface> output_surface;
41 if (surfaces_context_provider->ContextCapabilities().surfaceless) {
42 #if defined(USE_OZONE)
43 output_surface = base::WrapUnique(new DirectOutputSurfaceOzone(
44 surfaces_context_provider, widget, task_runner_.get(), GL_TEXTURE_2D,
45 GL_RGB));
46 #else
47 NOTREACHED();
48 #endif
49 } else {
50 output_surface = base::WrapUnique(
51 new DirectOutputSurface(surfaces_context_provider, task_runner_.get()));
52 }
53
54 int max_frames_pending = output_surface->capabilities().max_frames_pending;
55 DCHECK_GT(max_frames_pending, 0);
56
57 display_client_.reset(new TopLevelDisplayClient(
58 std::move(output_surface), surfaces_state_->manager(),
59 nullptr /* bitmap_manager */, nullptr /* gpu_memory_buffer_manager */,
60 cc::RendererSettings(), task_runner_, allocator_.id_namespace()));
61
62 display_client_->Initialize();
63 }
64
65 DisplayCompositor::~DisplayCompositor() {
66 surfaces_state_->manager()->UnregisterSurfaceFactoryClient(
67 allocator_.id_namespace());
68 }
69
70 void DisplayCompositor::SubmitCompositorFrame(
71 std::unique_ptr<cc::CompositorFrame> frame,
72 const base::Callback<void(cc::SurfaceDrawStatus)>& callback) {
73 gfx::Size frame_size =
74 frame->delegated_frame_data->render_pass_list.back()->output_rect.size();
75 if (frame_size.IsEmpty() || frame_size != display_size_) {
76 if (!surface_id_.is_null())
77 factory_.Destroy(surface_id_);
78 surface_id_ = allocator_.GenerateId();
79 factory_.Create(surface_id_);
80 display_size_ = frame_size;
81 display_client_->display()->Resize(display_size_);
82 }
83 display_client_->display()->SetSurfaceId(surface_id_,
84 frame->metadata.device_scale_factor);
85 factory_.SubmitCompositorFrame(surface_id_, std::move(frame), callback);
86 }
87
88 void DisplayCompositor::RequestCopyOfOutput(
89 std::unique_ptr<cc::CopyOutputRequest> output_request) {
90 factory_.RequestCopyOfSurface(surface_id_, std::move(output_request));
91 }
92
93 void DisplayCompositor::ReturnResources(
94 const cc::ReturnedResourceArray& resources) {
95 // TODO(fsamuel): Implement this.
96 }
97
98 void DisplayCompositor::SetBeginFrameSource(
99 cc::BeginFrameSource* begin_frame_source) {
100 // TODO(fsamuel): Implement this.
101 }
102
103 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/surfaces/display_compositor.h ('k') | components/mus/surfaces/top_level_display_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698