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