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
3 // found in the LICENSE file.
5 #include "content/browser/compositor/onscreen_display_client.h"
7 #include "base/debug/trace_event.h"
8 #include "cc/output/output_surface.h"
9 #include "cc/surfaces/surface_factory.h"
10 #include "cc/surfaces/surface_manager.h"
11 #include "content/common/host_shared_bitmap_manager.h"
15 OnscreenDisplayClient::OnscreenDisplayClient(
16 const scoped_refptr
<cc::ContextProvider
>& onscreen_context_provider
,
17 scoped_ptr
<cc::OutputSurface
> software_surface
,
18 cc::SurfaceManager
* manager
,
19 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner
)
20 : onscreen_context_provider_(onscreen_context_provider
),
21 software_surface_(software_surface
.Pass()),
23 new cc::Display(this, manager
, HostSharedBitmapManager::current())),
24 task_runner_(task_runner
),
25 scheduled_draw_(false),
26 weak_ptr_factory_(this) {
29 OnscreenDisplayClient::~OnscreenDisplayClient() {
32 scoped_ptr
<cc::OutputSurface
> OnscreenDisplayClient::CreateOutputSurface() {
33 if (!onscreen_context_provider_
.get())
34 return software_surface_
.Pass();
35 return make_scoped_ptr(new cc::OutputSurface(onscreen_context_provider_
))
39 void OnscreenDisplayClient::DisplayDamaged() {
42 TRACE_EVENT0("content", "OnscreenDisplayClient::DisplayDamaged");
43 scheduled_draw_
= true;
44 task_runner_
->PostTask(
46 base::Bind(&OnscreenDisplayClient::Draw
, weak_ptr_factory_
.GetWeakPtr()));
49 void OnscreenDisplayClient::Draw() {
50 TRACE_EVENT0("content", "OnscreenDisplayClient::Draw");
51 scheduled_draw_
= false;
55 } // namespace content