summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_widget.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-24 05:39:15 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-24 05:39:15 +0000
commitca4847f0a19f9565b6ca19fa47729bb746f5f736 (patch)
treeb8dd17796537fa49e00f66b8d3f9ac8d1c90b9d8 /chrome/renderer/render_widget.cc
parent61b4a61bf1ea2a610c076cb28de59aa1137b3c4f (diff)
downloadchromium_src-ca4847f0a19f9565b6ca19fa47729bb746f5f736.zip
chromium_src-ca4847f0a19f9565b6ca19fa47729bb746f5f736.tar.gz
chromium_src-ca4847f0a19f9565b6ca19fa47729bb746f5f736.tar.bz2
Add some optimizations to plugin painting.
The simplest one is to disable blending when the plugin is opaque. The more complicated one is to bypass webkit painting the background of plugins when we know the plugin to be always on top and also opaque. The always on top flag is currently set by a new "Private2" API. Bypassing WebKit makes animations faster. This is a re-land of the previous patch with a trivial compilation fix. This also adds a clip rect to the GetBitmap... function so we can properly handle plugins in nested iframes with proper clipping. BUG=none TEST=none Original review URL: http://codereview.chromium.org/3421030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60426 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_widget.cc')
-rw-r--r--chrome/renderer/render_widget.cc33
1 files changed, 28 insertions, 5 deletions
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index 3252097..f5a7ebe 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -505,11 +505,24 @@ void RenderWidget::DoDeferredUpdate() {
gfx::Rect scroll_damage = update.GetScrollDamage();
gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage);
+ // A plugin may be able to do an optimized paint. First check this, in which
+ // case we can skip all of the bitmap generation and regular paint code.
+ TransportDIB::Id dib_id = TransportDIB::Id();
+ TransportDIB* dib = NULL;
std::vector<gfx::Rect> copy_rects;
- if (!is_gpu_rendering_active_) {
+ gfx::Rect optimized_copy_rect, optimized_copy_location;
+ if (update.scroll_rect.IsEmpty() &&
+ !is_gpu_rendering_active_ &&
+ GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location,
+ &optimized_copy_rect)) {
+ bounds = optimized_copy_location;
+ copy_rects.push_back(optimized_copy_rect);
+ dib_id = dib->id();
+ } else if (!is_gpu_rendering_active_) {
// Compute a buffer for painting and cache it.
- scoped_ptr<skia::PlatformCanvas> canvas
- (RenderProcess::current()->GetDrawingCanvas(&current_paint_buf_, bounds));
+ scoped_ptr<skia::PlatformCanvas> canvas(
+ RenderProcess::current()->GetDrawingCanvas(&current_paint_buf_,
+ bounds));
if (!canvas.get()) {
NOTREACHED();
return;
@@ -538,6 +551,8 @@ void RenderWidget::DoDeferredUpdate() {
for (size_t i = 0; i < copy_rects.size(); ++i)
PaintRect(copy_rects[i], bounds.origin(), canvas.get());
+
+ dib_id = current_paint_buf_->id();
} else { // Accelerated compositing path
// Begin painting.
bool finish = next_paint_is_resize_ack();
@@ -546,8 +561,7 @@ void RenderWidget::DoDeferredUpdate() {
// sending an ack to browser process that the paint is complete...
ViewHostMsg_UpdateRect_Params params;
- params.bitmap =
- current_paint_buf_ ? current_paint_buf_->id() : TransportDIB::Id();
+ params.bitmap = dib_id;
params.bitmap_rect = bounds;
params.dx = update.scroll_delta.x();
params.dy = update.scroll_delta.y();
@@ -889,6 +903,15 @@ void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
webwidget_->setTextDirection(direction);
}
+bool RenderWidget::GetBitmapForOptimizedPluginPaint(
+ const gfx::Rect& paint_bounds,
+ TransportDIB** dib,
+ gfx::Rect* location,
+ gfx::Rect* clip) {
+ // Normal RenderWidgets don't support optimized plugin painting.
+ return false;
+}
+
void RenderWidget::SetHidden(bool hidden) {
if (is_hidden_ == hidden)
return;