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

Side by Side Diff: webkit/glue/plugins/pepper_plugin_instance.cc

Issue 2712002: First pass at implementing real Flush callbacks. This does not currently... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/plugins/pepper_plugin_instance.h ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_plugin_instance.h" 5 #include "webkit/glue/plugins/pepper_plugin_instance.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "gfx/rect.h" 9 #include "gfx/rect.h"
10 #include "third_party/ppapi/c/pp_instance.h" 10 #include "third_party/ppapi/c/pp_instance.h"
11 #include "third_party/ppapi/c/pp_event.h" 11 #include "third_party/ppapi/c/pp_event.h"
12 #include "third_party/ppapi/c/pp_rect.h" 12 #include "third_party/ppapi/c/pp_rect.h"
13 #include "third_party/ppapi/c/pp_resource.h" 13 #include "third_party/ppapi/c/pp_resource.h"
14 #include "third_party/ppapi/c/pp_var.h" 14 #include "third_party/ppapi/c/pp_var.h"
15 #include "third_party/ppapi/c/ppb_instance.h" 15 #include "third_party/ppapi/c/ppb_instance.h"
16 #include "third_party/ppapi/c/ppp_instance.h" 16 #include "third_party/ppapi/c/ppp_instance.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" 17 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" 18 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
19 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 19 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
20 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" 20 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
21 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" 21 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
22 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
22 #include "webkit/glue/plugins/pepper_device_context_2d.h" 23 #include "webkit/glue/plugins/pepper_device_context_2d.h"
23 #include "webkit/glue/plugins/pepper_plugin_module.h" 24 #include "webkit/glue/plugins/pepper_plugin_module.h"
24 #include "webkit/glue/plugins/pepper_resource_tracker.h" 25 #include "webkit/glue/plugins/pepper_resource_tracker.h"
25 #include "webkit/glue/plugins/pepper_var.h" 26 #include "webkit/glue/plugins/pepper_var.h"
26 27
27 using WebKit::WebFrame; 28 using WebKit::WebFrame;
28 using WebKit::WebInputEvent; 29 using WebKit::WebInputEvent;
29 using WebKit::WebPluginContainer; 30 using WebKit::WebPluginContainer;
30 31
31 namespace pepper { 32 namespace pepper {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return reinterpret_cast<intptr_t>(this); 166 return reinterpret_cast<intptr_t>(this);
166 } 167 }
167 168
168 void PluginInstance::Paint(WebKit::WebCanvas* canvas, 169 void PluginInstance::Paint(WebKit::WebCanvas* canvas,
169 const gfx::Rect& plugin_rect, 170 const gfx::Rect& plugin_rect,
170 const gfx::Rect& paint_rect) { 171 const gfx::Rect& paint_rect) {
171 if (device_context_2d_) 172 if (device_context_2d_)
172 device_context_2d_->Paint(canvas, plugin_rect, paint_rect); 173 device_context_2d_->Paint(canvas, plugin_rect, paint_rect);
173 } 174 }
174 175
176 void PluginInstance::InvalidateRect(const gfx::Rect& rect) {
177 if (!container_ || position_.IsEmpty())
178 return; // Nothing to do.
179 if (rect.IsEmpty())
180 container_->invalidate();
181 else
182 container_->invalidateRect(rect);
183 }
184
175 PP_Var PluginInstance::GetWindowObject() { 185 PP_Var PluginInstance::GetWindowObject() {
176 if (!container_) 186 if (!container_)
177 return PP_MakeVoid(); 187 return PP_MakeVoid();
178 188
179 WebFrame* frame = container_->element().document().frame(); 189 WebFrame* frame = container_->element().document().frame();
180 if (!frame) 190 if (!frame)
181 return PP_MakeVoid(); 191 return PP_MakeVoid();
182 192
183 return NPObjectToPPVar(frame->windowObject()); 193 return NPObjectToPPVar(frame->windowObject());
184 } 194 }
185 195
186 PP_Var PluginInstance::GetOwnerElementObject() { 196 PP_Var PluginInstance::GetOwnerElementObject() {
187 if (!container_) 197 if (!container_)
188 return PP_MakeVoid(); 198 return PP_MakeVoid();
189 199
190 return NPObjectToPPVar(container_->scriptableObjectForElement()); 200 return NPObjectToPPVar(container_->scriptableObjectForElement());
191 } 201 }
192 202
193 bool PluginInstance::BindGraphicsDeviceContext(PP_Resource device_id) { 203 bool PluginInstance::BindGraphicsDeviceContext(PP_Resource device_id) {
204 if (!device_id) {
205 // Special-case clearing the current device.
206 if (device_context_2d_) {
207 device_context_2d_->BindToInstance(NULL);
208 device_context_2d_ = NULL;
209 InvalidateRect(gfx::Rect());
210 }
211 return true;
212 }
213
194 scoped_refptr<Resource> device_resource = 214 scoped_refptr<Resource> device_resource =
195 ResourceTracker::Get()->GetResource(device_id); 215 ResourceTracker::Get()->GetResource(device_id);
196 if (!device_resource.get()) 216 if (!device_resource.get())
197 return false; 217 return false;
198 218
199 DeviceContext2D* device_2d = device_resource->AsDeviceContext2D(); 219 DeviceContext2D* device_2d = device_resource->AsDeviceContext2D();
200 if (device_2d) { 220 if (device_2d) {
221 if (!device_2d->BindToInstance(this))
222 return false; // Can't bind to more than one instance.
201 device_context_2d_ = device_2d; 223 device_context_2d_ = device_2d;
202 // TODO(brettw) repaint the plugin. 224 // BindToInstance will have invalidated the plugin if necessary.
203 } 225 }
204 226
205 return true; 227 return true;
206 } 228 }
207 229
208 void PluginInstance::Delete() { 230 void PluginInstance::Delete() {
209 instance_interface_->Delete(GetPPInstance()); 231 instance_interface_->Delete(GetPPInstance());
210 232
211 container_ = NULL; 233 container_ = NULL;
212 } 234 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 285 }
264 return instance_interface_->HandleEvent(GetPPInstance(), &pp_event); 286 return instance_interface_->HandleEvent(GetPPInstance(), &pp_event);
265 } 287 }
266 288
267 PP_Var PluginInstance::GetInstanceObject() { 289 PP_Var PluginInstance::GetInstanceObject() {
268 return instance_interface_->GetInstanceObject(GetPPInstance()); 290 return instance_interface_->GetInstanceObject(GetPPInstance());
269 } 291 }
270 292
271 void PluginInstance::ViewChanged(const gfx::Rect& position, 293 void PluginInstance::ViewChanged(const gfx::Rect& position,
272 const gfx::Rect& clip) { 294 const gfx::Rect& clip) {
295 position_ = position;
296 if (clip.IsEmpty()) {
297 // WebKit can give weird (x,y) positions for empty clip rects (since the
298 // position technically doesn't matter). But we want to make these
299 // consistent since this is given to the plugin, so force everything to 0
300 // in the "everything is clipped" case.
301 clip_ = gfx::Rect();
302 } else {
303 clip_ = clip;
304 }
305
273 PP_Rect pp_position, pp_clip; 306 PP_Rect pp_position, pp_clip;
274 RectToPPRect(position, &pp_position); 307 RectToPPRect(position_, &pp_position);
275 RectToPPRect(clip, &pp_clip); 308 RectToPPRect(clip_, &pp_clip);
276 instance_interface_->ViewChanged(GetPPInstance(), &pp_position, &pp_clip); 309 instance_interface_->ViewChanged(GetPPInstance(), &pp_position, &pp_clip);
277 } 310 }
278 311
312 void PluginInstance::ViewInitiatedPaint() {
313 if (device_context_2d_)
314 device_context_2d_->ViewInitiatedPaint();
315 }
316
317 void PluginInstance::ViewFlushedPaint() {
318 if (device_context_2d_)
319 device_context_2d_->ViewFlushedPaint();
320 }
321
279 } // namespace pepper 322 } // namespace pepper
OLDNEW
« no previous file with comments | « webkit/glue/plugins/pepper_plugin_instance.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698