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 "content/browser/compositor/onscreen_display_client.h" | 5 #include "content/browser/compositor/onscreen_display_client.h" |
6 | 6 |
| 7 #include "base/debug/trace_event.h" |
7 #include "cc/output/output_surface.h" | 8 #include "cc/output/output_surface.h" |
8 #include "cc/surfaces/surface_factory.h" | 9 #include "cc/surfaces/surface_factory.h" |
9 #include "cc/surfaces/surface_manager.h" | 10 #include "cc/surfaces/surface_manager.h" |
10 #include "content/common/host_shared_bitmap_manager.h" | 11 #include "content/common/host_shared_bitmap_manager.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 OnscreenDisplayClient::OnscreenDisplayClient( | 15 OnscreenDisplayClient::OnscreenDisplayClient( |
15 const scoped_refptr<cc::ContextProvider>& onscreen_context_provider, | 16 const scoped_refptr<cc::ContextProvider>& onscreen_context_provider, |
16 scoped_ptr<cc::OutputSurface> software_surface, | 17 scoped_ptr<cc::OutputSurface> software_surface, |
17 cc::SurfaceManager* manager) | 18 cc::SurfaceManager* manager, |
| 19 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
18 : onscreen_context_provider_(onscreen_context_provider), | 20 : onscreen_context_provider_(onscreen_context_provider), |
19 software_surface_(software_surface.Pass()), | 21 software_surface_(software_surface.Pass()), |
20 display_(new cc::Display(this, | 22 display_( |
21 manager, | 23 new cc::Display(this, manager, HostSharedBitmapManager::current())), |
22 HostSharedBitmapManager::current())) { | 24 task_runner_(task_runner), |
| 25 scheduled_draw_(false), |
| 26 weak_ptr_factory_(this) { |
23 } | 27 } |
24 | 28 |
25 OnscreenDisplayClient::~OnscreenDisplayClient() { | 29 OnscreenDisplayClient::~OnscreenDisplayClient() { |
26 } | 30 } |
27 | 31 |
28 scoped_ptr<cc::OutputSurface> OnscreenDisplayClient::CreateOutputSurface() { | 32 scoped_ptr<cc::OutputSurface> OnscreenDisplayClient::CreateOutputSurface() { |
29 if (!onscreen_context_provider_) | 33 if (!onscreen_context_provider_) |
30 return software_surface_.Pass(); | 34 return software_surface_.Pass(); |
31 return make_scoped_ptr(new cc::OutputSurface(onscreen_context_provider_)) | 35 return make_scoped_ptr(new cc::OutputSurface(onscreen_context_provider_)) |
32 .Pass(); | 36 .Pass(); |
33 } | 37 } |
34 | 38 |
| 39 void OnscreenDisplayClient::DisplayDamaged() { |
| 40 if (scheduled_draw_) |
| 41 return; |
| 42 TRACE_EVENT0("content", "OnscreenDisplayClient::DisplayDamaged"); |
| 43 scheduled_draw_ = true; |
| 44 task_runner_->PostTask( |
| 45 FROM_HERE, |
| 46 base::Bind(&OnscreenDisplayClient::Draw, weak_ptr_factory_.GetWeakPtr())); |
| 47 } |
| 48 |
| 49 void OnscreenDisplayClient::Draw() { |
| 50 TRACE_EVENT0("content", "OnscreenDisplayClient::Draw"); |
| 51 scheduled_draw_ = false; |
| 52 display_->Draw(); |
| 53 } |
| 54 |
35 } // namespace content | 55 } // namespace content |
OLD | NEW |