OLD | NEW |
---|---|
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 21 matching lines...) Expand all Loading... | |
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 |
92 scoped_ptr<CompositorFrame> frame = | 98 scoped_ptr<CompositorFrame> frame = |
93 aggregator_->Aggregate(current_surface_id_); | 99 aggregator_->Aggregate(current_surface_id_); |
danakj
2014/08/28 17:10:46
can you add a TODO here that "We should hold a Blo
Sami
2014/08/28 18:21:16
Done.
| |
94 if (!frame) | 100 if (!frame) |
95 return false; | 101 return false; |
96 | 102 |
97 TRACE_EVENT0("cc", "Display::Draw"); | 103 TRACE_EVENT0("cc", "Display::Draw"); |
98 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); | 104 DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); |
99 | 105 |
100 // Only reshape when we know we are going to draw. Otherwise, the reshape | 106 // 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 | 107 // can leave the window at the wrong size if we never draw and the proper |
102 // viewport size is never set. | 108 // viewport size is never set. |
103 output_surface_->Reshape(current_surface_size_, 1.f); | 109 output_surface_->Reshape(current_surface_size_, 1.f); |
(...skipping 24 matching lines...) Expand all Loading... | |
128 void Display::OnSurfaceDamaged(SurfaceId surface) { | 134 void Display::OnSurfaceDamaged(SurfaceId surface) { |
129 if (aggregator_ && aggregator_->previous_contained_surfaces().count(surface)) | 135 if (aggregator_ && aggregator_->previous_contained_surfaces().count(surface)) |
130 client_->DisplayDamaged(); | 136 client_->DisplayDamaged(); |
131 } | 137 } |
132 | 138 |
133 SurfaceId Display::CurrentSurfaceId() { | 139 SurfaceId Display::CurrentSurfaceId() { |
134 return current_surface_id_; | 140 return current_surface_id_; |
135 } | 141 } |
136 | 142 |
137 } // namespace cc | 143 } // namespace cc |
OLD | NEW |