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

Side by Side Diff: chrome/renderer/webplugin_delegate_proxy.cc

Issue 10792: Fix the painting problem with Stree View and Flash 10. After the size of the... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 12 years 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 | « chrome/renderer/webplugin_delegate_proxy.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/renderer/webplugin_delegate_proxy.h" 5 #include "chrome/renderer/webplugin_delegate_proxy.h"
6 6
7 #include <atlbase.h> 7 #include <atlbase.h>
8 8
9 #include "generated_resources.h" 9 #include "generated_resources.h"
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 132
133 WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type, 133 WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type,
134 const std::string& clsid, 134 const std::string& clsid,
135 RenderView* render_view) 135 RenderView* render_view)
136 : render_view_(render_view), 136 : render_view_(render_view),
137 mime_type_(mime_type), 137 mime_type_(mime_type),
138 clsid_(clsid), 138 clsid_(clsid),
139 plugin_(NULL), 139 plugin_(NULL),
140 windowless_(false), 140 windowless_(false),
141 first_paint_(true),
142 npobject_(NULL), 141 npobject_(NULL),
143 send_deferred_update_geometry_(false), 142 send_deferred_update_geometry_(false),
144 visible_(false), 143 visible_(false),
145 sad_plugin_(NULL), 144 sad_plugin_(NULL),
146 window_script_object_(NULL), 145 window_script_object_(NULL),
147 transparent_(false), 146 transparent_(false),
148 invalidate_pending_(false) { 147 invalidate_pending_(false) {
149 } 148 }
150 149
151 WebPluginDelegateProxy::~WebPluginDelegateProxy() { 150 WebPluginDelegateProxy::~WebPluginDelegateProxy() {
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 return 4 * rect.width() * rect.height(); 386 return 4 * rect.width() * rect.height();
388 } 387 }
389 388
390 void WebPluginDelegateProxy::ResetWindowlessBitmaps() { 389 void WebPluginDelegateProxy::ResetWindowlessBitmaps() {
391 backing_store_.reset(); 390 backing_store_.reset();
392 transport_store_.reset(); 391 transport_store_.reset();
393 backing_store_canvas_.reset(); 392 backing_store_canvas_.reset();
394 transport_store_canvas_.reset(); 393 transport_store_canvas_.reset();
395 background_store_.reset(); 394 background_store_.reset();
396 background_store_canvas_.release(); 395 background_store_canvas_.release();
396 backing_store_painted_ = gfx::Rect();
397 } 397 }
398 398
399 bool WebPluginDelegateProxy::CreateBitmap( 399 bool WebPluginDelegateProxy::CreateBitmap(
400 scoped_ptr<base::SharedMemory>* memory, 400 scoped_ptr<base::SharedMemory>* memory,
401 scoped_ptr<gfx::PlatformCanvasWin>* canvas) { 401 scoped_ptr<gfx::PlatformCanvasWin>* canvas) {
402 size_t size = GetPaintBufSize(plugin_rect_); 402 size_t size = GetPaintBufSize(plugin_rect_);
403 scoped_ptr<base::SharedMemory> new_shared_memory(new base::SharedMemory()); 403 scoped_ptr<base::SharedMemory> new_shared_memory(new base::SharedMemory());
404 if (!new_shared_memory->Create(L"", false, true, size)) 404 if (!new_shared_memory->Create(L"", false, true, size))
405 return false; 405 return false;
406 406
407 scoped_ptr<gfx::PlatformCanvasWin> new_canvas(new gfx::PlatformCanvasWin); 407 scoped_ptr<gfx::PlatformCanvasWin> new_canvas(new gfx::PlatformCanvasWin);
408 if (!new_canvas->initialize(plugin_rect_.width(), plugin_rect_.height(), 408 if (!new_canvas->initialize(plugin_rect_.width(), plugin_rect_.height(),
409 true, new_shared_memory->handle())) { 409 true, new_shared_memory->handle())) {
410 return false; 410 return false;
411 } 411 }
412 412
413 memory->swap(new_shared_memory); 413 memory->swap(new_shared_memory);
414 canvas->swap(new_canvas); 414 canvas->swap(new_canvas);
415 return true; 415 return true;
416 } 416 }
417 417
418 void WebPluginDelegateProxy::Paint(HDC hdc, const gfx::Rect& damaged_rect) { 418 void WebPluginDelegateProxy::Paint(HDC hdc, const gfx::Rect& damaged_rect) {
419 // If the plugin is no longer connected (channel crashed) draw a crashed 419 // If the plugin is no longer connected (channel crashed) draw a crashed
420 // plugin bitmap 420 // plugin bitmap
421 if (!channel_host_->channel_valid()) { 421 if (!channel_host_->channel_valid()) {
422 PaintSadPlugin(hdc, damaged_rect); 422 PaintSadPlugin(hdc, damaged_rect);
423 return; 423 return;
424 } 424 }
425 425
426 // No paint events for windowed plugins. However, if it is the first paint 426 // No paint events for windowed plugins.
427 // we don't know yet whether the plugin is windowless or not, so we have to 427 if (!windowless_)
428 // send the event.
429 if (!windowless_ && !first_paint_) {
430 // TODO(maruel): That's not true for printing and thumbnail capture.
431 // We shall use PrintWindow() to draw the window.
432 return; 428 return;
433 }
434 429
435 // We got a paint before the plugin's coordinates, so there's no buffer to 430 // We got a paint before the plugin's coordinates, so there's no buffer to
436 // copy from. 431 // copy from.
437 if (!backing_store_canvas_.get()) 432 if (!backing_store_canvas_.get())
438 return; 433 return;
439 434
440 // Limit the damaged rectangle to whatever is contained inside the plugin 435 // Limit the damaged rectangle to whatever is contained inside the plugin
441 // rectangle, as that's the rectangle that we'll bitblt to the hdc. 436 // rectangle, as that's the rectangle that we'll bitblt to the hdc.
442 gfx::Rect rect = damaged_rect.Intersect(plugin_rect_); 437 gfx::Rect rect = damaged_rect.Intersect(plugin_rect_);
443 438
444 bool background_changed = false; 439 bool background_changed = false;
445 if (background_store_canvas_.get() && BackgroundChanged(hdc, rect)) { 440 if (background_store_canvas_.get() && BackgroundChanged(hdc, rect)) {
446 background_changed = true; 441 background_changed = true;
447 HDC background_hdc = 442 HDC background_hdc =
448 background_store_canvas_->getTopPlatformDevice().getBitmapDC(); 443 background_store_canvas_->getTopPlatformDevice().getBitmapDC();
449 BitBlt(background_hdc, rect.x()-plugin_rect_.x(), rect.y()-plugin_rect_.y(), 444 BitBlt(background_hdc, rect.x()-plugin_rect_.x(), rect.y()-plugin_rect_.y(),
450 rect.width(), rect.height(), hdc, rect.x(), rect.y(), SRCCOPY); 445 rect.width(), rect.height(), hdc, rect.x(), rect.y(), SRCCOPY);
451 } 446 }
452 447
453 if (first_paint_ || background_changed) { 448 gfx::Rect offset_rect = rect;
454 gfx::Rect offset_rect = rect; 449 offset_rect.Offset(-plugin_rect_.x(), -plugin_rect_.y());
455 offset_rect.Offset(-plugin_rect_.x(), -plugin_rect_.y()); 450 if (background_changed || !backing_store_painted_.Contains(offset_rect)) {
456 Send(new PluginMsg_Paint(instance_id_, offset_rect)); 451 Send(new PluginMsg_Paint(instance_id_, offset_rect));
457 CopyFromTransportToBacking(offset_rect); 452 CopyFromTransportToBacking(offset_rect);
458 } 453 }
459 454
460 first_paint_ = false;
461 HDC backing_hdc = backing_store_canvas_->getTopPlatformDevice().getBitmapDC(); 455 HDC backing_hdc = backing_store_canvas_->getTopPlatformDevice().getBitmapDC();
462 BitBlt(hdc, rect.x(), rect.y(), rect.width(), rect.height(), backing_hdc, 456 BitBlt(hdc, rect.x(), rect.y(), rect.width(), rect.height(), backing_hdc,
463 rect.x()-plugin_rect_.x(), rect.y()-plugin_rect_.y(), SRCCOPY); 457 rect.x()-plugin_rect_.x(), rect.y()-plugin_rect_.y(), SRCCOPY);
464 458
465 if (invalidate_pending_) { 459 if (invalidate_pending_) {
466 // Only send the PaintAck message if this paint is in response to an 460 // Only send the PaintAck message if this paint is in response to an
467 // invalidate from the plugin, since this message acts as an access token 461 // invalidate from the plugin, since this message acts as an access token
468 // to ensure only one process is using the transport dib at a time. 462 // to ensure only one process is using the transport dib at a time.
469 invalidate_pending_ = false; 463 invalidate_pending_ = false;
470 Send(new PluginMsg_DidPaint(instance_id_)); 464 Send(new PluginMsg_DidPaint(instance_id_));
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 return; 689 return;
696 } 690 }
697 691
698 void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) { 692 void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) {
699 if (!backing_store_canvas_.get()) 693 if (!backing_store_canvas_.get())
700 return; 694 return;
701 695
702 // Copy the damaged rect from the transport bitmap to the backing store. 696 // Copy the damaged rect from the transport bitmap to the backing store.
703 HDC backing = backing_store_canvas_->getTopPlatformDevice().getBitmapDC(); 697 HDC backing = backing_store_canvas_->getTopPlatformDevice().getBitmapDC();
704 HDC transport = transport_store_canvas_->getTopPlatformDevice().getBitmapDC(); 698 HDC transport = transport_store_canvas_->getTopPlatformDevice().getBitmapDC();
705
706 BitBlt(backing, rect.x(), rect.y(), rect.width(), rect.height(), 699 BitBlt(backing, rect.x(), rect.y(), rect.width(), rect.height(),
707 transport, rect.x(), rect.y(), SRCCOPY); 700 transport, rect.x(), rect.y(), SRCCOPY);
701 backing_store_painted_ = backing_store_painted_.Union(rect);
708 } 702 }
709 703
710 void WebPluginDelegateProxy::OnHandleURLRequest( 704 void WebPluginDelegateProxy::OnHandleURLRequest(
711 const PluginHostMsg_URLRequest_Params& params) { 705 const PluginHostMsg_URLRequest_Params& params) {
712 const char* data = NULL; 706 const char* data = NULL;
713 if (params.buffer.size()) 707 if (params.buffer.size())
714 data = &params.buffer[0]; 708 data = &params.buffer[0];
715 709
716 const char* target = NULL; 710 const char* target = NULL;
717 if (params.target.length()) 711 if (params.target.length())
(...skipping 27 matching lines...) Expand all
745 plugin_->CancelDocumentLoad(); 739 plugin_->CancelDocumentLoad();
746 } 740 }
747 741
748 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( 742 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest(
749 const std::string& url, const std::string& range_info, 743 const std::string& url, const std::string& range_info,
750 HANDLE existing_stream, bool notify_needed, HANDLE notify_data) { 744 HANDLE existing_stream, bool notify_needed, HANDLE notify_data) {
751 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), 745 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(),
752 existing_stream, notify_needed, 746 existing_stream, notify_needed,
753 notify_data); 747 notify_data);
754 } 748 }
OLDNEW
« no previous file with comments | « chrome/renderer/webplugin_delegate_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698