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

Side by Side Diff: content/plugin/webplugin_proxy.cc

Issue 9460006: check for null-device before using the windowless canvas (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | « no previous file | 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) 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/plugin/webplugin_proxy.h" 5 #include "content/plugin/webplugin_proxy.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 params.notify_redirects = notify_redirects; 332 params.notify_redirects = notify_redirects;
333 333
334 Send(new PluginHostMsg_URLRequest(route_id_, params)); 334 Send(new PluginHostMsg_URLRequest(route_id_, params));
335 } 335 }
336 336
337 void WebPluginProxy::Paint(const gfx::Rect& rect) { 337 void WebPluginProxy::Paint(const gfx::Rect& rect) {
338 #if defined(OS_MACOSX) 338 #if defined(OS_MACOSX)
339 if (!windowless_context()) 339 if (!windowless_context())
340 return; 340 return;
341 #else 341 #else
342 if (!windowless_canvas()) 342 if (!windowless_canvas() || !windowless_canvas()->getDevice())
343 return; 343 return;
344 #endif 344 #endif
345 345
346 // Clear the damaged area so that if the plugin doesn't paint there we won't 346 // Clear the damaged area so that if the plugin doesn't paint there we won't
347 // end up with the old values. 347 // end up with the old values.
348 gfx::Rect offset_rect = rect; 348 gfx::Rect offset_rect = rect;
349 offset_rect.Offset(delegate_->GetRect().origin()); 349 offset_rect.Offset(delegate_->GetRect().origin());
350 #if defined(OS_MACOSX) 350 #if defined(OS_MACOSX)
351 CGContextSaveGState(windowless_context()); 351 CGContextSaveGState(windowless_context());
352 // It is possible for windowless_contexts_ to change during plugin painting 352 // It is possible for windowless_contexts_ to change during plugin painting
(...skipping 30 matching lines...) Expand all
383 windowless_canvas()->save(); 383 windowless_canvas()->save();
384 384
385 // The given clip rect is relative to the plugin coordinate system. 385 // The given clip rect is relative to the plugin coordinate system.
386 SkRect sk_rect = { SkIntToScalar(rect.x()), 386 SkRect sk_rect = { SkIntToScalar(rect.x()),
387 SkIntToScalar(rect.y()), 387 SkIntToScalar(rect.y()),
388 SkIntToScalar(rect.right()), 388 SkIntToScalar(rect.right()),
389 SkIntToScalar(rect.bottom()) }; 389 SkIntToScalar(rect.bottom()) };
390 windowless_canvas()->clipRect(sk_rect); 390 windowless_canvas()->clipRect(sk_rect);
391 391
392 // Setup the background. 392 // Setup the background.
393 if (background_canvas_.get()) { 393 if (background_canvas_.get() && background_canvas_.get()->getDevice()) {
394 // When a background canvas is given, we're in transparent mode. This means 394 // When a background canvas is given, we're in transparent mode. This means
395 // the plugin wants to have the image of the page in the canvas it's drawing 395 // the plugin wants to have the image of the page in the canvas it's drawing
396 // into (which is windowless_canvases_) so it can do blending. So we copy 396 // into (which is windowless_canvases_) so it can do blending. So we copy
397 // the background bitmap into the windowless canvas. 397 // the background bitmap into the windowless canvas.
398 const SkBitmap& background_bitmap = 398 const SkBitmap& background_bitmap =
399 skia::GetTopDevice(*background_canvas_)->accessBitmap(false); 399 skia::GetTopDevice(*background_canvas_)->accessBitmap(false);
400 windowless_canvas()->drawBitmap(background_bitmap, 0, 0); 400 windowless_canvas()->drawBitmap(background_bitmap, 0, 0);
401 } else { 401 } else {
402 // In non-transparent mode, the plugin doesn't care what's underneath, so we 402 // In non-transparent mode, the plugin doesn't care what's underneath, so we
403 // can just give it black. 403 // can just give it black.
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 // Retrieve the IME status from a plug-in and send it to a renderer process 775 // Retrieve the IME status from a plug-in and send it to a renderer process
776 // when the plug-in has updated it. 776 // when the plug-in has updated it.
777 int input_type; 777 int input_type;
778 gfx::Rect caret_rect; 778 gfx::Rect caret_rect;
779 if (!delegate_->GetIMEStatus(&input_type, &caret_rect)) 779 if (!delegate_->GetIMEStatus(&input_type, &caret_rect))
780 return; 780 return;
781 781
782 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect)); 782 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect));
783 } 783 }
784 #endif 784 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698