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

Side by Side Diff: cc/surfaces/display.cc

Issue 2144393003: cc: Allow TestDelegatingOutputSurface to be used for non-pixel tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/display_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/surfaces/display.h" 5 #include "cc/surfaces/display.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 14 matching lines...) Expand all
25 #include "cc/surfaces/surface_manager.h" 25 #include "cc/surfaces/surface_manager.h"
26 #include "gpu/command_buffer/client/gles2_interface.h" 26 #include "gpu/command_buffer/client/gles2_interface.h"
27 #include "ui/gfx/buffer_types.h" 27 #include "ui/gfx/buffer_types.h"
28 28
29 #if defined(ENABLE_VULKAN) 29 #if defined(ENABLE_VULKAN)
30 #include "cc/output/vulkan_renderer.h" 30 #include "cc/output/vulkan_renderer.h"
31 #endif 31 #endif
32 32
33 namespace cc { 33 namespace cc {
34 34
35 Display::Display(SurfaceManager* manager, 35 Display::Display(SharedBitmapManager* bitmap_manager,
36 SharedBitmapManager* bitmap_manager,
37 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 36 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
38 const RendererSettings& settings, 37 const RendererSettings& settings,
39 uint32_t compositor_surface_namespace,
40 std::unique_ptr<BeginFrameSource> begin_frame_source, 38 std::unique_ptr<BeginFrameSource> begin_frame_source,
41 std::unique_ptr<OutputSurface> output_surface, 39 std::unique_ptr<OutputSurface> output_surface,
42 std::unique_ptr<DisplayScheduler> scheduler, 40 std::unique_ptr<DisplayScheduler> scheduler,
43 std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter) 41 std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter)
44 : surface_manager_(manager), 42 : bitmap_manager_(bitmap_manager),
45 bitmap_manager_(bitmap_manager),
46 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), 43 gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
47 settings_(settings), 44 settings_(settings),
48 compositor_surface_namespace_(compositor_surface_namespace),
49 begin_frame_source_(std::move(begin_frame_source)), 45 begin_frame_source_(std::move(begin_frame_source)),
50 output_surface_(std::move(output_surface)), 46 output_surface_(std::move(output_surface)),
51 scheduler_(std::move(scheduler)), 47 scheduler_(std::move(scheduler)),
52 texture_mailbox_deleter_(std::move(texture_mailbox_deleter)) { 48 texture_mailbox_deleter_(std::move(texture_mailbox_deleter)) {
53 DCHECK(surface_manager_);
54 DCHECK(output_surface_); 49 DCHECK(output_surface_);
55 DCHECK_EQ(!scheduler_, !begin_frame_source_); 50 DCHECK_EQ(!scheduler_, !begin_frame_source_);
56
57 surface_manager_->AddObserver(this);
58
59 if (scheduler_) 51 if (scheduler_)
60 scheduler_->SetClient(this); 52 scheduler_->SetClient(this);
61 } 53 }
62 54
63 Display::~Display() { 55 Display::~Display() {
64 // Only do this if Initialize() happened. 56 // Only do this if Initialize() happened.
65 if (begin_frame_source_ && client_) 57 if (client_) {
66 surface_manager_->UnregisterBeginFrameSource(begin_frame_source_.get()); 58 if (begin_frame_source_)
67 59 surface_manager_->UnregisterBeginFrameSource(begin_frame_source_.get());
68 surface_manager_->RemoveObserver(this); 60 surface_manager_->RemoveObserver(this);
61 }
69 if (aggregator_) { 62 if (aggregator_) {
70 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) { 63 for (const auto& id_entry : aggregator_->previous_contained_surfaces()) {
71 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first); 64 Surface* surface = surface_manager_->GetSurfaceForId(id_entry.first);
72 if (surface) 65 if (surface)
73 surface->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED); 66 surface->RunDrawCallbacks(SurfaceDrawStatus::DRAW_SKIPPED);
74 } 67 }
75 } 68 }
76 } 69 }
77 70
78 void Display::Initialize(DisplayClient* client) { 71 void Display::Initialize(DisplayClient* client,
72 SurfaceManager* surface_manager,
73 uint32_t compositor_surface_namespace) {
79 DCHECK(client); 74 DCHECK(client);
75 DCHECK(surface_manager);
80 client_ = client; 76 client_ = client;
77 surface_manager_ = surface_manager;
78 compositor_surface_namespace_ = compositor_surface_namespace;
79
80 surface_manager_->AddObserver(this);
81 81
82 // This must be done in Initialize() so that the caller can delay this until 82 // This must be done in Initialize() so that the caller can delay this until
83 // they are ready to receive a BeginFrameSource. 83 // they are ready to receive a BeginFrameSource.
84 if (begin_frame_source_) { 84 if (begin_frame_source_) {
85 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(), 85 surface_manager_->RegisterBeginFrameSource(begin_frame_source_.get(),
86 compositor_surface_namespace_); 86 compositor_surface_namespace_);
87 } 87 }
88 88
89 bool ok = output_surface_->BindToClient(this); 89 bool ok = output_surface_->BindToClient(this);
90 // The context given to the Display's OutputSurface should already be 90 // The context given to the Display's OutputSurface should already be
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 422
423 if (surface_id == current_surface_id_) 423 if (surface_id == current_surface_id_)
424 UpdateRootSurfaceResourcesLocked(); 424 UpdateRootSurfaceResourcesLocked();
425 } 425 }
426 426
427 const SurfaceId& Display::CurrentSurfaceId() { 427 const SurfaceId& Display::CurrentSurfaceId() {
428 return current_surface_id_; 428 return current_surface_id_;
429 } 429 }
430 430
431 } // namespace cc 431 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/display_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698