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

Side by Side Diff: content/renderer/gpu/compositor_thread.cc

Issue 10546115: Quad list IPC infrastructure. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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
« no previous file with comments | « content/renderer/gpu/compositor_thread.h ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/renderer/gpu/compositor_thread.h" 5 #include "content/renderer/gpu/compositor_thread.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "content/common/view_messages.h"
9 #include "content/renderer/gpu/input_event_filter.h" 10 #include "content/renderer/gpu/input_event_filter.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingPa rameters.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingPa rameters.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorFrame.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan dlerClient.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan dlerClient.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan dler.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositorInputHan dler.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
14 16
15 using WebKit::WebCompositorInputHandler; 17 using WebKit::WebCompositorInputHandler;
16 using WebKit::WebInputEvent; 18 using WebKit::WebInputEvent;
17 19
18 //------------------------------------------------------------------------------ 20 //------------------------------------------------------------------------------
19 21
20 class CompositorThread::InputHandlerWrapper 22 class CompositorThread::InputHandlerWrapper
21 : public WebKit::WebCompositorInputHandlerClient, 23 : public WebKit::WebCompositorInputHandlerClient,
22 public base::RefCountedThreadSafe<InputHandlerWrapper> { 24 public base::RefCountedThreadSafe<InputHandlerWrapper> {
23 public: 25 public:
24 InputHandlerWrapper(CompositorThread* compositor_thread, 26 InputHandlerWrapper(CompositorThread* compositor_thread,
25 int routing_id, 27 int routing_id,
28 IPC::Message::Sender* sender,
26 WebKit::WebCompositorInputHandler* input_handler, 29 WebKit::WebCompositorInputHandler* input_handler,
27 scoped_refptr<base::MessageLoopProxy> main_loop, 30 scoped_refptr<base::MessageLoopProxy> main_loop,
28 const base::WeakPtr<RenderViewImpl>& render_view_impl) 31 const base::WeakPtr<RenderViewImpl>& render_view_impl)
29 : compositor_thread_(compositor_thread), 32 : compositor_thread_(compositor_thread),
30 routing_id_(routing_id), 33 routing_id_(routing_id),
34 sender_(sender),
31 input_handler_(input_handler), 35 input_handler_(input_handler),
32 main_loop_(main_loop), 36 main_loop_(main_loop),
33 render_view_impl_(render_view_impl) { 37 render_view_impl_(render_view_impl) {
34 input_handler_->setClient(this); 38 input_handler_->setClient(this);
35 } 39 }
36 40
37 virtual void transferActiveWheelFlingAnimation( 41 virtual void transferActiveWheelFlingAnimation(
38 const WebKit::WebActiveWheelFlingParameters& params) { 42 const WebKit::WebActiveWheelFlingParameters& params) {
39 main_loop_->PostTask( 43 main_loop_->PostTask(
40 FROM_HERE, 44 FROM_HERE,
(...skipping 13 matching lines...) Expand all
54 } 58 }
55 59
56 virtual void didHandleInputEvent() { 60 virtual void didHandleInputEvent() {
57 compositor_thread_->filter_->DidHandleInputEvent(); 61 compositor_thread_->filter_->DidHandleInputEvent();
58 } 62 }
59 63
60 virtual void didNotHandleInputEvent(bool send_to_widget) { 64 virtual void didNotHandleInputEvent(bool send_to_widget) {
61 compositor_thread_->filter_->DidNotHandleInputEvent(send_to_widget); 65 compositor_thread_->filter_->DidNotHandleInputEvent(send_to_widget);
62 } 66 }
63 67
68 virtual void sendCompositorFrame(const WebKit::WebCompositorFrame& frame) {
69 std::vector<WebKit::WebCompositorQuad> quads;
70 for (unsigned int i = 0; i < frame.quadList.size(); i++)
71 quads.push_back(frame.quadList[i]);
72
73 CompositorHostMsg_DrawFrame_Params params;
74 params.quads = quads;
75 params.framebuffer_output_rect = frame.framebufferOutputRect;
76 sender_->Send(new CompositorHostMsg_DrawFrame(routing_id_, params));
77 }
78
64 private: 79 private:
65 friend class base::RefCountedThreadSafe<InputHandlerWrapper>; 80 friend class base::RefCountedThreadSafe<InputHandlerWrapper>;
66 81
67 virtual ~InputHandlerWrapper() { 82 virtual ~InputHandlerWrapper() {
68 input_handler_->setClient(NULL); 83 input_handler_->setClient(NULL);
69 } 84 }
70 85
71 CompositorThread* compositor_thread_; 86 CompositorThread* compositor_thread_;
72 int routing_id_; 87 int routing_id_;
88 IPC::Message::Sender* sender_;
73 WebKit::WebCompositorInputHandler* input_handler_; 89 WebKit::WebCompositorInputHandler* input_handler_;
74 scoped_refptr<base::MessageLoopProxy> main_loop_; 90 scoped_refptr<base::MessageLoopProxy> main_loop_;
75 91
76 // Can only be accessed on the main thread. 92 // Can only be accessed on the main thread.
77 base::WeakPtr<RenderViewImpl> render_view_impl_; 93 base::WeakPtr<RenderViewImpl> render_view_impl_;
78 94
79 DISALLOW_COPY_AND_ASSIGN(InputHandlerWrapper); 95 DISALLOW_COPY_AND_ASSIGN(InputHandlerWrapper);
80 }; 96 };
81 97
82 //------------------------------------------------------------------------------ 98 //------------------------------------------------------------------------------
83 99
84 CompositorThread::CompositorThread(IPC::Channel::Listener* main_listener) 100 CompositorThread::CompositorThread(IPC::Channel::Listener* main_listener)
85 : thread_("Compositor") { 101 : thread_("Compositor") {
86 filter_ = 102 filter_ =
87 new InputEventFilter(main_listener, 103 new InputEventFilter(main_listener,
88 thread_.message_loop()->message_loop_proxy(), 104 thread_.message_loop()->message_loop_proxy(),
89 base::Bind(&CompositorThread::HandleInputEvent, 105 base::Bind(&CompositorThread::HandleInputEvent,
90 base::Unretained(this))); 106 base::Unretained(this)));
91 } 107 }
92 108
93 CompositorThread::~CompositorThread() { 109 CompositorThread::~CompositorThread() {
94 } 110 }
95 111
96 IPC::ChannelProxy::MessageFilter* CompositorThread::GetMessageFilter() const { 112 IPC::ChannelProxy::MessageFilter* CompositorThread::GetMessageFilter() const {
97 return filter_; 113 return filter_;
98 } 114 }
99 115
100 void CompositorThread::AddInputHandler( 116 void CompositorThread::AddInputHandler(
101 int routing_id, int input_handler_id, 117 int routing_id, IPC::Message::Sender* sender, int input_handler_id,
102 const base::WeakPtr<RenderViewImpl>& render_view_impl) { 118 const base::WeakPtr<RenderViewImpl>& render_view_impl) {
103 DCHECK_NE(thread_.message_loop(), MessageLoop::current()); 119 DCHECK_NE(thread_.message_loop(), MessageLoop::current());
104 120
105 thread_.message_loop()->PostTask( 121 thread_.message_loop()->PostTask(
106 FROM_HERE, 122 FROM_HERE,
107 base::Bind(&CompositorThread::AddInputHandlerOnCompositorThread, 123 base::Bind(&CompositorThread::AddInputHandlerOnCompositorThread,
108 base::Unretained(this), 124 base::Unretained(this),
109 routing_id, 125 routing_id,
126 sender,
110 input_handler_id, 127 input_handler_id,
111 base::MessageLoopProxy::current(), 128 base::MessageLoopProxy::current(),
112 render_view_impl)); 129 render_view_impl));
113 } 130 }
114 131
115 void CompositorThread::AddInputHandlerOnCompositorThread( 132 void CompositorThread::AddInputHandlerOnCompositorThread(
116 int routing_id, int input_handler_id, 133 int routing_id, IPC::Message::Sender* sender, int input_handler_id,
117 scoped_refptr<base::MessageLoopProxy> main_loop, 134 scoped_refptr<base::MessageLoopProxy> main_loop,
118 const base::WeakPtr<RenderViewImpl>& render_view_impl) { 135 const base::WeakPtr<RenderViewImpl>& render_view_impl) {
119 136
120 DCHECK_EQ(thread_.message_loop(), MessageLoop::current()); 137 DCHECK_EQ(thread_.message_loop(), MessageLoop::current());
121 138
122 WebCompositorInputHandler* input_handler = 139 WebCompositorInputHandler* input_handler =
123 WebCompositorInputHandler::fromIdentifier(input_handler_id); 140 WebCompositorInputHandler::fromIdentifier(input_handler_id);
124 if (!input_handler) 141 if (!input_handler)
125 return; 142 return;
126 143
127 if (input_handlers_.count(routing_id) != 0) { 144 if (input_handlers_.count(routing_id) != 0) {
128 // It's valid to call AddInputHandler() for the same routing id with the 145 // It's valid to call AddInputHandler() for the same routing id with the
129 // same input_handler many times, but it's not valid to change the 146 // same input_handler many times, but it's not valid to change the
130 // input_handler for a route. 147 // input_handler for a route.
131 DCHECK_EQ(input_handlers_[routing_id]->input_handler(), input_handler); 148 DCHECK_EQ(input_handlers_[routing_id]->input_handler(), input_handler);
132 return; 149 return;
133 } 150 }
134 151
135 TRACE_EVENT0("CompositorThread::AddInputHandler", "AddingRoute"); 152 TRACE_EVENT0("CompositorThread::AddInputHandler", "AddingRoute");
136 filter_->AddRoute(routing_id); 153 filter_->AddRoute(routing_id);
137 input_handlers_[routing_id] = 154 input_handlers_[routing_id] =
138 make_scoped_refptr(new InputHandlerWrapper(this, 155 make_scoped_refptr(new InputHandlerWrapper(this,
139 routing_id, input_handler, main_loop, render_view_impl)); 156 routing_id, sender, input_handler, main_loop, render_view_impl));
140 } 157 }
141 158
142 void CompositorThread::RemoveInputHandler(int routing_id) { 159 void CompositorThread::RemoveInputHandler(int routing_id) {
143 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); 160 DCHECK_EQ(MessageLoop::current(), thread_.message_loop());
144 161
145 TRACE_EVENT0("CompositorThread::RemoveInputHandler", "RemovingRoute"); 162 TRACE_EVENT0("CompositorThread::RemoveInputHandler", "RemovingRoute");
146 163
147 filter_->RemoveRoute(routing_id); 164 filter_->RemoveRoute(routing_id);
148 input_handlers_.erase(routing_id); 165 input_handlers_.erase(routing_id);
149 } 166 }
150 167
151 void CompositorThread::HandleInputEvent( 168 void CompositorThread::HandleInputEvent(
152 int routing_id, 169 int routing_id,
153 const WebInputEvent* input_event) { 170 const WebInputEvent* input_event) {
154 DCHECK_EQ(MessageLoop::current(), thread_.message_loop()); 171 DCHECK_EQ(MessageLoop::current(), thread_.message_loop());
155 172
156 InputHandlerMap::iterator it = input_handlers_.find(routing_id); 173 InputHandlerMap::iterator it = input_handlers_.find(routing_id);
157 if (it == input_handlers_.end()) { 174 if (it == input_handlers_.end()) {
158 TRACE_EVENT0("CompositorThread::HandleInputEvent", "NoInputHandlerFound"); 175 TRACE_EVENT0("CompositorThread::HandleInputEvent", "NoInputHandlerFound");
159 // Oops, we no longer have an interested input handler.. 176 // Oops, we no longer have an interested input handler..
160 filter_->DidNotHandleInputEvent(true); 177 filter_->DidNotHandleInputEvent(true);
161 return; 178 return;
162 } 179 }
163 180
164 it->second->input_handler()->handleInputEvent(*input_event); 181 it->second->input_handler()->handleInputEvent(*input_event);
165 } 182 }
OLDNEW
« no previous file with comments | « content/renderer/gpu/compositor_thread.h ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698