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

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

Issue 485043003: cc: Use correct message loop proxy in BlockingTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits. Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/surface_aggregator.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 "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "cc/output/compositor_frame.h" 9 #include "cc/output/compositor_frame.h"
10 #include "cc/output/compositor_frame_ack.h" 10 #include "cc/output/compositor_frame_ack.h"
11 #include "cc/output/direct_renderer.h" 11 #include "cc/output/direct_renderer.h"
12 #include "cc/output/gl_renderer.h" 12 #include "cc/output/gl_renderer.h"
13 #include "cc/output/software_renderer.h" 13 #include "cc/output/software_renderer.h"
14 #include "cc/surfaces/display_client.h" 14 #include "cc/surfaces/display_client.h"
15 #include "cc/surfaces/surface.h" 15 #include "cc/surfaces/surface.h"
16 #include "cc/surfaces/surface_aggregator.h" 16 #include "cc/surfaces/surface_aggregator.h"
17 #include "cc/surfaces/surface_manager.h" 17 #include "cc/surfaces/surface_manager.h"
18 #include "cc/trees/blocking_task_runner.h"
18 19
19 namespace cc { 20 namespace cc {
20 21
21 Display::Display(DisplayClient* client, 22 Display::Display(DisplayClient* client,
22 SurfaceManager* manager, 23 SurfaceManager* manager,
23 SharedBitmapManager* bitmap_manager) 24 SharedBitmapManager* bitmap_manager)
24 : client_(client), manager_(manager), bitmap_manager_(bitmap_manager) { 25 : client_(client),
26 manager_(manager),
27 bitmap_manager_(bitmap_manager),
28 blocking_main_thread_task_runner_(
29 BlockingTaskRunner::Create(base::MessageLoopProxy::current())) {
25 manager_->AddObserver(this); 30 manager_->AddObserver(this);
26 } 31 }
27 32
28 Display::~Display() { 33 Display::~Display() {
29 manager_->RemoveObserver(this); 34 manager_->RemoveObserver(this);
30 } 35 }
31 36
32 void Display::Resize(SurfaceId id, const gfx::Size& size) { 37 void Display::Resize(SurfaceId id, const gfx::Size& size) {
33 current_surface_id_ = id; 38 current_surface_id_ = id;
34 current_surface_size_ = size; 39 current_surface_size_ = size;
35 client_->DisplayDamaged(); 40 client_->DisplayDamaged();
36 } 41 }
37 42
38 void Display::InitializeOutputSurface() { 43 void Display::InitializeOutputSurface() {
39 if (output_surface_) 44 if (output_surface_)
40 return; 45 return;
41 scoped_ptr<OutputSurface> output_surface = client_->CreateOutputSurface(); 46 scoped_ptr<OutputSurface> output_surface = client_->CreateOutputSurface();
42 if (!output_surface->BindToClient(this)) 47 if (!output_surface->BindToClient(this))
43 return; 48 return;
44 49
45 int highp_threshold_min = 0; 50 int highp_threshold_min = 0;
46 bool use_rgba_4444_texture_format = false; 51 bool use_rgba_4444_texture_format = false;
47 size_t id_allocation_chunk_size = 1; 52 size_t id_allocation_chunk_size = 1;
48 bool use_distance_field_text = false; 53 bool use_distance_field_text = false;
49 scoped_ptr<ResourceProvider> resource_provider = 54 scoped_ptr<ResourceProvider> resource_provider =
50 ResourceProvider::Create(output_surface.get(), 55 ResourceProvider::Create(output_surface.get(),
51 bitmap_manager_, 56 bitmap_manager_,
57 blocking_main_thread_task_runner_.get(),
52 highp_threshold_min, 58 highp_threshold_min,
53 use_rgba_4444_texture_format, 59 use_rgba_4444_texture_format,
54 id_allocation_chunk_size, 60 id_allocation_chunk_size,
55 use_distance_field_text); 61 use_distance_field_text);
56 if (!resource_provider) 62 if (!resource_provider)
57 return; 63 return;
58 64
59 if (output_surface->context_provider()) { 65 if (output_surface->context_provider()) {
60 TextureMailboxDeleter* texture_mailbox_deleter = NULL; 66 TextureMailboxDeleter* texture_mailbox_deleter = NULL;
61 scoped_ptr<GLRenderer> renderer = 67 scoped_ptr<GLRenderer> renderer =
(...skipping 20 matching lines...) Expand all
82 } 88 }
83 89
84 bool Display::Draw() { 90 bool Display::Draw() {
85 if (current_surface_id_.is_null()) 91 if (current_surface_id_.is_null())
86 return false; 92 return false;
87 93
88 InitializeOutputSurface(); 94 InitializeOutputSurface();
89 if (!output_surface_) 95 if (!output_surface_)
90 return false; 96 return false;
91 97
98 // TODO(skyostil): We should hold a BlockingTaskRunner::CapturePostTasks
99 // while Aggregate is called to immediately run release callbacks afterward.
92 scoped_ptr<CompositorFrame> frame = 100 scoped_ptr<CompositorFrame> frame =
93 aggregator_->Aggregate(current_surface_id_); 101 aggregator_->Aggregate(current_surface_id_);
94 if (!frame) 102 if (!frame)
95 return false; 103 return false;
96 104
97 TRACE_EVENT0("cc", "Display::Draw"); 105 TRACE_EVENT0("cc", "Display::Draw");
98 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); 106 DelegatedFrameData* frame_data = frame->delegated_frame_data.get();
99 107
100 // Only reshape when we know we are going to draw. Otherwise, the reshape 108 // Only reshape when we know we are going to draw. Otherwise, the reshape
101 // can leave the window at the wrong size if we never draw and the proper 109 // can leave the window at the wrong size if we never draw and the proper
(...skipping 26 matching lines...) Expand all
128 void Display::OnSurfaceDamaged(SurfaceId surface) { 136 void Display::OnSurfaceDamaged(SurfaceId surface) {
129 if (aggregator_ && aggregator_->previous_contained_surfaces().count(surface)) 137 if (aggregator_ && aggregator_->previous_contained_surfaces().count(surface))
130 client_->DisplayDamaged(); 138 client_->DisplayDamaged();
131 } 139 }
132 140
133 SurfaceId Display::CurrentSurfaceId() { 141 SurfaceId Display::CurrentSurfaceId() {
134 return current_surface_id_; 142 return current_surface_id_;
135 } 143 }
136 144
137 } // namespace cc 145 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/display.h ('k') | cc/surfaces/surface_aggregator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698