Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: content/browser/aura/browser_compositor_output_surface.cc

Issue 137893007: Add the UI compositor to the Mac build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missed file Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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.
4
5 #include "content/browser/aura/browser_compositor_output_surface.h"
6
7 #include "base/bind.h"
8 #include "base/command_line.h"
9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "content/browser/aura/reflector_impl.h"
13 #include "content/common/gpu/client/context_provider_command_buffer.h"
14 #include "ui/compositor/compositor.h"
15 #include "ui/compositor/compositor_switches.h"
16
17 namespace content {
18
19 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
20 const scoped_refptr<ContextProviderCommandBuffer>& context_provider,
21 int surface_id,
22 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
23 base::MessageLoopProxy* compositor_message_loop,
24 base::WeakPtr<ui::Compositor> compositor)
25 : OutputSurface(context_provider),
26 surface_id_(surface_id),
27 output_surface_map_(output_surface_map),
28 compositor_message_loop_(compositor_message_loop),
29 compositor_(compositor) {
30 Initialize();
31 }
32
33 BrowserCompositorOutputSurface::BrowserCompositorOutputSurface(
34 scoped_ptr<cc::SoftwareOutputDevice> software_device,
35 int surface_id,
36 IDMap<BrowserCompositorOutputSurface>* output_surface_map,
37 base::MessageLoopProxy* compositor_message_loop,
38 base::WeakPtr<ui::Compositor> compositor)
39 : OutputSurface(software_device.Pass()),
40 surface_id_(surface_id),
41 output_surface_map_(output_surface_map),
42 compositor_message_loop_(compositor_message_loop),
43 compositor_(compositor) {
44 Initialize();
45 }
46
47 BrowserCompositorOutputSurface::~BrowserCompositorOutputSurface() {
48 DCHECK(CalledOnValidThread());
49 if (!HasClient())
50 return;
51 output_surface_map_->Remove(surface_id_);
52 }
53
54 void BrowserCompositorOutputSurface::Initialize() {
55 CommandLine* command_line = CommandLine::ForCurrentProcess();
56 if (command_line->HasSwitch(switches::kUIMaxFramesPending)) {
57 std::string string_value = command_line->GetSwitchValueASCII(
58 switches::kUIMaxFramesPending);
59 int int_value;
60 if (base::StringToInt(string_value, &int_value))
61 capabilities_.max_frames_pending = int_value;
62 else
63 LOG(ERROR) << "Trouble parsing --" << switches::kUIMaxFramesPending;
64 }
65 capabilities_.adjust_deadline_for_parent = false;
66
67 DetachFromThread();
68 }
69
70 bool BrowserCompositorOutputSurface::BindToClient(
71 cc::OutputSurfaceClient* client) {
72 DCHECK(CalledOnValidThread());
73
74 if (!OutputSurface::BindToClient(client))
75 return false;
76
77 output_surface_map_->AddWithID(this, surface_id_);
78 if (reflector_)
79 reflector_->OnSourceSurfaceReady(surface_id_);
80 return true;
81 }
82
83 void BrowserCompositorOutputSurface::Reshape(gfx::Size size,
84 float scale_factor) {
85 OutputSurface::Reshape(size, scale_factor);
86 if (reflector_.get())
87 reflector_->OnReshape(size);
88 }
89
90 void BrowserCompositorOutputSurface::OnUpdateVSyncParameters(
91 base::TimeTicks timebase,
92 base::TimeDelta interval) {
93 DCHECK(CalledOnValidThread());
94 DCHECK(HasClient());
95 OnVSyncParametersChanged(timebase, interval);
96 compositor_message_loop_->PostTask(
97 FROM_HERE,
98 base::Bind(&ui::Compositor::OnUpdateVSyncParameters,
99 compositor_, timebase, interval));
100 }
101
102 void BrowserCompositorOutputSurface::SetReflector(ReflectorImpl* reflector) {
103 reflector_ = reflector;
104 }
105
106 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698