Loosen up heuristics for detecting account creation forms.
[chromium-blink-merge.git] / content / renderer / gpu / compositor_output_surface.cc
blob1f1257ebd612ddc75dc02560bf43563d461d3f62
1 // Copyright (c) 2012 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/renderer/gpu/compositor_output_surface.h"
7 #include "base/message_loop_proxy.h"
8 #include "content/common/view_messages.h"
9 #include "content/renderer/render_thread_impl.h"
10 #include "ipc/ipc_forwarding_message_filter.h"
11 #include "ipc/ipc_sync_channel.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurfaceClient.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
15 using WebKit::WebGraphicsContext3D;
17 //------------------------------------------------------------------------------
19 // static
20 IPC::ForwardingMessageFilter* CompositorOutputSurface::CreateFilter(
21 base::TaskRunner* target_task_runner)
23 uint32 messages_to_filter[] = {ViewMsg_UpdateVSyncParameters::ID};
24 return new IPC::ForwardingMessageFilter(
25 messages_to_filter, arraysize(messages_to_filter),
26 target_task_runner);
29 CompositorOutputSurface::CompositorOutputSurface(
30 int32 routing_id,
31 WebGraphicsContext3D* context3D)
32 : output_surface_filter_(
33 RenderThreadImpl::current()->compositor_output_surface_filter())
34 , client_(NULL)
35 , routing_id_(routing_id)
36 , context3D_(context3D) {
37 DCHECK(output_surface_filter_);
38 capabilities_.hasParentCompositor = false;
39 DetachFromThread();
42 CompositorOutputSurface::~CompositorOutputSurface() {
43 DCHECK(CalledOnValidThread());
44 if (!client_)
45 return;
46 output_surface_filter_->RemoveRoute(routing_id_);
49 const WebKit::WebCompositorOutputSurface::Capabilities&
50 CompositorOutputSurface::capabilities() const {
51 DCHECK(CalledOnValidThread());
52 return capabilities_;
55 bool CompositorOutputSurface::bindToClient(
56 WebKit::WebCompositorOutputSurfaceClient* client) {
57 DCHECK(CalledOnValidThread());
58 DCHECK(!client_);
59 if (!context3D_->makeContextCurrent())
60 return false;
62 client_ = client;
64 output_surface_filter_->AddRoute(
65 routing_id_,
66 base::Bind(&CompositorOutputSurface::OnMessageReceived,
67 base::Unretained(this)));
69 return true;
72 WebGraphicsContext3D* CompositorOutputSurface::context3D() const {
73 DCHECK(CalledOnValidThread());
74 return context3D_.get();
77 void CompositorOutputSurface::sendFrameToParentCompositor(
78 const WebKit::WebCompositorFrame&) {
79 DCHECK(CalledOnValidThread());
80 NOTREACHED();
83 void CompositorOutputSurface::OnMessageReceived(const IPC::Message& message) {
84 DCHECK(CalledOnValidThread());
85 if (!client_)
86 return;
87 IPC_BEGIN_MESSAGE_MAP(CompositorOutputSurface, message)
88 IPC_MESSAGE_HANDLER(ViewMsg_UpdateVSyncParameters, OnUpdateVSyncParameters);
89 IPC_END_MESSAGE_MAP()
92 void CompositorOutputSurface::OnUpdateVSyncParameters(
93 base::TimeTicks timebase,
94 base::TimeDelta interval) {
95 DCHECK(CalledOnValidThread());
96 DCHECK(client_);
97 double monotonicTimebase = timebase.ToInternalValue() /
98 static_cast<double>(base::Time::kMicrosecondsPerSecond);
99 double intervalInSeconds = interval.ToInternalValue() /
100 static_cast<double>(base::Time::kMicrosecondsPerSecond);
101 client_->onVSyncParametersChanged(monotonicTimebase, intervalInSeconds);