Chromium Code Reviews| Index: cc/surfaces/display.cc |
| diff --git a/cc/surfaces/display.cc b/cc/surfaces/display.cc |
| index b9929ba370c505379597580d50c4b74506fc669a..68f521f1ef0be9091e8e8fffd94260b12a3d3031 100644 |
| --- a/cc/surfaces/display.cc |
| +++ b/cc/surfaces/display.cc |
| @@ -20,15 +20,22 @@ namespace cc { |
| Display::Display(DisplayClient* client, |
| SurfaceManager* manager, |
| SharedBitmapManager* bitmap_manager) |
| - : client_(client), manager_(manager), bitmap_manager_(bitmap_manager) { |
| + : client_(client), |
| + manager_(manager), |
| + bitmap_manager_(bitmap_manager), |
| + scheduled_draw_(false), |
| + weak_ptr_factory_(this) { |
| } |
| Display::~Display() { |
| + ClearSurfaceList(); |
| } |
| void Display::Resize(SurfaceId id, const gfx::Size& size) { |
| current_surface_id_ = id; |
| current_surface_size_ = size; |
| + ClearSurfaceList(); |
| + Draw(); |
| } |
| void Display::InitializeOutputSurface() { |
| @@ -78,19 +85,36 @@ void Display::InitializeOutputSurface() { |
| } |
| bool Display::Draw() { |
| + if (scheduled_draw_) |
| + return true; |
| + scheduled_draw_ = true; |
| + base::MessageLoopProxy::current()->PostTask( |
|
jamesr
2014/08/07 21:04:06
the Display should not self-schedule. tell the cli
piman
2014/08/07 21:09:32
drive-by: also going to MessageLoopProxy::current(
|
| + FROM_HERE, base::Bind(&Display::DoDraw, weak_ptr_factory_.GetWeakPtr())); |
| + return true; |
| +} |
| + |
| +void Display::DoDraw() { |
| + TRACE_EVENT0("cc", "Display::DoDraw"); |
| + scheduled_draw_ = false; |
| if (current_surface_id_.is_null()) |
| - return false; |
| + return; |
| InitializeOutputSurface(); |
| if (!output_surface_) |
| - return false; |
| + return; |
| + ClearSurfaceList(); |
| scoped_ptr<CompositorFrame> frame = |
| - aggregator_->Aggregate(current_surface_id_); |
| + aggregator_->Aggregate(current_surface_id_, &contained_surfaces_); |
| + |
| + for (std::set<Surface*>::iterator it = contained_surfaces_.begin(); |
| + it != contained_surfaces_.end(); |
| + ++it) { |
| + (*it)->containing_displays().insert(this); |
| + } |
| if (!frame) |
| - return false; |
| + return; |
| - TRACE_EVENT0("cc", "Display::Draw"); |
| DelegatedFrameData* frame_data = frame->delegated_frame_data.get(); |
| // Only reshape when we know we are going to draw. Otherwise, the reshape |
| @@ -110,7 +134,16 @@ bool Display::Draw() { |
| disable_picture_quad_image_filtering); |
| CompositorFrameMetadata metadata; |
| renderer_->SwapBuffers(metadata); |
| - return true; |
| +} |
| + |
| +void Display::ClearSurfaceList() { |
| + for (std::set<Surface*>::iterator it = contained_surfaces_.begin(); |
| + it != contained_surfaces_.end(); |
| + ++it) { |
| + (*it)->containing_displays().erase(this); |
| + } |
| + |
| + contained_surfaces_.clear(); |
| } |
| SurfaceId Display::CurrentSurfaceId() { |