diff options
author | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-09 04:22:18 +0000 |
---|---|---|
committer | jbauman@chromium.org <jbauman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-09 04:22:18 +0000 |
commit | 9fcec0ad20328b6d36e65312632bf615ab94e8c0 (patch) | |
tree | b721425f078c76c451383c3bf4cf212ba8d81329 /content/renderer | |
parent | b2d8328f9940eea1b3052bd6f73be8b3dc4c8476 (diff) | |
download | chromium_src-9fcec0ad20328b6d36e65312632bf615ab94e8c0.zip chromium_src-9fcec0ad20328b6d36e65312632bf615ab94e8c0.tar.gz chromium_src-9fcec0ad20328b6d36e65312632bf615ab94e8c0.tar.bz2 |
Remove optimized plugin paint.
This won't be hit because the legacy 2D path is disabled everywhere. Putting the pepper content in its own layer gets most of the benefit anyway.
BUG=
Review URL: https://codereview.chromium.org/227683009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262617 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.cc | 59 | ||||
-rw-r--r-- | content/renderer/pepper/pepper_plugin_instance_impl.h | 11 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 21 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 6 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 103 | ||||
-rw-r--r-- | content/renderer/render_widget.h | 17 | ||||
-rw-r--r-- | content/renderer/render_widget_fullscreen_pepper.cc | 14 | ||||
-rw-r--r-- | content/renderer/render_widget_fullscreen_pepper.h | 6 |
8 files changed, 15 insertions, 222 deletions
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc index 931979d..30ff0f8 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.cc +++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc @@ -1227,65 +1227,6 @@ void PepperPluginInstanceImpl::ViewFlushedPaint() { bound_graphics_3d_->ViewFlushedPaint(); } -bool PepperPluginInstanceImpl::GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* location, - gfx::Rect* clip, - float* scale_factor) { - if (!always_on_top_) - return false; - if (!bound_graphics_2d_platform_ || - !bound_graphics_2d_platform_->IsAlwaysOpaque()) { - return false; - } - - // We specifically want to compare against the area covered by the backing - // store when seeing if we cover the given paint bounds, since the backing - // store could be smaller than the declared plugin area. - PPB_ImageData_Impl* image_data = bound_graphics_2d_platform_->ImageData(); - // ImageDatas created by NaCl don't have a TransportDIB, so can't be - // optimized this way. - if (!image_data->GetTransportDIB()) - return false; - - gfx::Point plugin_origin = PP_ToGfxPoint(view_data_.rect.point); - gfx::Vector2d plugin_offset = plugin_origin.OffsetFromOrigin(); - // Convert |paint_bounds| to be relative to the left-top corner of the plugin. - gfx::Rect relative_paint_bounds(paint_bounds); - relative_paint_bounds.Offset(-plugin_offset); - - gfx::Rect pixel_plugin_backing_store_rect( - 0, 0, image_data->width(), image_data->height()); - float scale = bound_graphics_2d_platform_->GetScale(); - gfx::Rect plugin_backing_store_rect = gfx::ToEnclosedRect( - gfx::ScaleRect(pixel_plugin_backing_store_rect, scale)); - - gfx::Rect clip_page = PP_ToGfxRect(view_data_.clip_rect); - gfx::Rect plugin_paint_rect = - gfx::IntersectRects(plugin_backing_store_rect, clip_page); - if (!plugin_paint_rect.Contains(relative_paint_bounds)) - return false; - - // Don't do optimized painting if the area to paint intersects with the - // cut-out rects, otherwise we will paint over them. - for (std::vector<gfx::Rect>::const_iterator iter = cut_outs_rects_.begin(); - iter != cut_outs_rects_.end(); ++iter) { - if (relative_paint_bounds.Intersects(*iter)) - return false; - } - - *dib = image_data->GetTransportDIB(); - plugin_backing_store_rect.Offset(plugin_offset); - *location = plugin_backing_store_rect; - clip_page.Offset(plugin_offset); - *clip = clip_page; - // The plugin scale factor is inverted, e.g. for a device scale factor of 2x - // the plugin scale factor is 0.5. - *scale_factor = 1.0 / scale; - return true; -} - void PepperPluginInstanceImpl::SetSelectedText( const base::string16& selected_text) { selected_text_ = selected_text; diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h index 12f54fe..b69a192 100644 --- a/content/renderer/pepper/pepper_plugin_instance_impl.h +++ b/content/renderer/pepper/pepper_plugin_instance_impl.h @@ -220,17 +220,6 @@ class CONTENT_EXPORT PepperPluginInstanceImpl void ViewInitiatedPaint(); void ViewFlushedPaint(); - // If this plugin can be painted merely by copying the backing store to the - // screen, and the plugin bounds encloses the given paint bounds, returns - // true. In this case, the location, clipping, and ID of the backing store - // will be filled into the given output parameters. - bool GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* dib_bounds, - gfx::Rect* clip, - float* scale_factor); - // Tracks all live PluginObjects. void AddPluginObject(PluginObject* plugin_object); void RemovePluginObject(PluginObject* plugin_object); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 1a6c94c..e53ccc7 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -3733,27 +3733,6 @@ void RenderViewImpl::DidFlushPaint() { } } -PepperPluginInstanceImpl* RenderViewImpl::GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* location, - gfx::Rect* clip, - float* scale_factor) { -#if defined(ENABLE_PLUGINS) - for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); - i != active_pepper_instances_.end(); ++i) { - PepperPluginInstanceImpl* instance = *i; - // In Flash fullscreen , the plugin contents should be painted onto the - // fullscreen widget instead of the web page. - if (!instance->FlashIsFullscreenOrPending() && - instance->GetBitmapForOptimizedPluginPaint(paint_bounds, dib, location, - clip, scale_factor)) - return *i; - } -#endif - return NULL; -} - gfx::Vector2d RenderViewImpl::GetScrollOffset() { WebSize scroll_offset = webview()->mainFrame()->scrollOffset(); return gfx::Vector2d(scroll_offset.width, scroll_offset.height); diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 6e4d0a5..ab03ab9 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -674,12 +674,6 @@ class CONTENT_EXPORT RenderViewImpl virtual void OnResize(const ViewMsg_Resize_Params& params) OVERRIDE; virtual void DidInitiatePaint() OVERRIDE; virtual void DidFlushPaint() OVERRIDE; - virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* location, - gfx::Rect* clip, - float* scale_factor) OVERRIDE; virtual gfx::Vector2d GetScrollOffset() OVERRIDE; virtual void DidHandleKeyEvent() OVERRIDE; virtual void WillProcessUserGesture() OVERRIDE; diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 0f54094..8f142d7 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -1305,61 +1305,23 @@ void RenderWidget::PaintRect(const gfx::Rect& rect, canvas->restore(); } - // First see if this rect is a plugin that can paint itself faster. - TransportDIB* optimized_dib = NULL; - gfx::Rect optimized_copy_rect, optimized_copy_location; - float dib_scale_factor; - PepperPluginInstanceImpl* optimized_instance = - GetBitmapForOptimizedPluginPaint(rect, &optimized_dib, - &optimized_copy_location, - &optimized_copy_rect, - &dib_scale_factor); - if (optimized_instance) { -#if defined(ENABLE_PLUGINS) - // This plugin can be optimize-painted and we can just ask it to paint - // itself. We don't actually need the TransportDIB in this case. - // - // This is an optimization for PPAPI plugins that know they're on top of - // the page content. If this rect is inside such a plugin, we can save some - // time and avoid re-rendering the page content which we know will be - // covered by the plugin later (this time can be significant, especially - // for a playing movie that is invalidating a lot). - // - // In the plugin movie case, hopefully the similar call to - // GetBitmapForOptimizedPluginPaint in DoDeferredUpdate handles the - // painting, because that avoids copying the plugin image to a different - // paint rect. Unfortunately, if anything on the page is animating other - // than the movie, it break this optimization since the union of the - // invalid regions will be larger than the plugin. - // - // This code optimizes that case, where we can still avoid painting in - // WebKit and filling the background (which can be slow) and just painting - // the plugin. Unlike the DoDeferredUpdate case, an extra copy is still - // required. - SkAutoCanvasRestore auto_restore(canvas, true); - canvas->scale(device_scale_factor_, device_scale_factor_); - optimized_instance->Paint(canvas, optimized_copy_location, rect); - canvas->restore(); -#endif - } else { - // Normal painting case. - base::TimeTicks start_time; - if (!is_accelerated_compositing_active_) - start_time = legacy_software_mode_stats_->StartRecording(); - - webwidget_->paint(canvas, rect); - - if (!is_accelerated_compositing_active_) { - base::TimeDelta paint_time = - legacy_software_mode_stats_->EndRecording(start_time); - int64 painted_pixel_count = rect.width() * rect.height(); - legacy_software_mode_stats_->AddPaint(paint_time, painted_pixel_count); - } + // Normal painting case. + base::TimeTicks start_time; + if (!is_accelerated_compositing_active_) + start_time = legacy_software_mode_stats_->StartRecording(); - // Flush to underlying bitmap. TODO(darin): is this needed? - skia::GetTopDevice(*canvas)->accessBitmap(false); + webwidget_->paint(canvas, rect); + + if (!is_accelerated_compositing_active_) { + base::TimeDelta paint_time = + legacy_software_mode_stats_->EndRecording(start_time); + int64 painted_pixel_count = rect.width() * rect.height(); + legacy_software_mode_stats_->AddPaint(paint_time, painted_pixel_count); } + // Flush to underlying bitmap. TODO(darin): is this needed? + skia::GetTopDevice(*canvas)->accessBitmap(false); + PaintDebugBorder(rect, canvas); canvas->restore(); } @@ -1589,20 +1551,6 @@ void RenderWidget::DoDeferredUpdate() { gfx::Rect scroll_damage = update.GetScrollDamage(); gfx::Rect bounds = gfx::UnionRects(update.GetPaintBounds(), 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. - // This optimization allows PPAPI plugins that declare themselves on top of - // the page (like a traditional windowed plugin) to be able to animate (think - // movie playing) without repeatedly re-painting the page underneath, or - // copying the plugin backing store (since we can send the plugin's backing - // store directly to the browser). - // - // This optimization only works when the entire invalid region is contained - // within the plugin. There is a related optimization in PaintRect for the - // case where there may be multiple invalid regions. - TransportDIB* dib = NULL; - gfx::Rect optimized_copy_rect, optimized_copy_location; - float dib_scale_factor = 1; DCHECK(!pending_update_params_.get()); pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params); pending_update_params_->scroll_delta = update.scroll_delta; @@ -1621,18 +1569,7 @@ void RenderWidget::DoDeferredUpdate() { latency_info_.clear(); - if (update.scroll_rect.IsEmpty() && - !is_accelerated_compositing_active_ && - GetBitmapForOptimizedPluginPaint(bounds, &dib, &optimized_copy_location, - &optimized_copy_rect, - &dib_scale_factor)) { - // Only update the part of the plugin that actually changed. - optimized_copy_rect.Intersect(bounds); - pending_update_params_->bitmap = dib->id(); - pending_update_params_->bitmap_rect = optimized_copy_location; - pending_update_params_->copy_rects.push_back(optimized_copy_rect); - pending_update_params_->scale_factor = dib_scale_factor; - } else if (!is_accelerated_compositing_active_) { + if (!is_accelerated_compositing_active_) { // Compute a buffer for painting and cache it. bool fractional_scale = device_scale_factor_ - @@ -2358,16 +2295,6 @@ void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { } } -PepperPluginInstanceImpl* RenderWidget::GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* location, - gfx::Rect* clip, - float* scale_factor) { - // Bare RenderWidgets don't support optimized plugin painting. - return NULL; -} - gfx::Vector2d RenderWidget::GetScrollOffset() { // Bare RenderWidgets don't support scroll offset. return gfx::Vector2d(); diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index 411d102..7c8762d 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -407,23 +407,6 @@ class CONTENT_EXPORT RenderWidget virtual bool ForceCompositingModeEnabled(); - // Detects if a suitable opaque plugin covers the given paint bounds with no - // compositing necessary. - // - // Returns the plugin instance that's the source of the paint if the paint - // can be handled by just blitting the plugin bitmap. In this case, the - // location, clipping, and ID of the backing store will be filled into the - // given output parameters. - // - // A return value of null means optimized painting can not be used and we - // should continue with the normal painting code path. - virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* location, - gfx::Rect* clip, - float* scale_factor); - // Gets the scroll offset of this widget, if this widget has a notion of // scroll offset. virtual gfx::Vector2d GetScrollOffset(); diff --git a/content/renderer/render_widget_fullscreen_pepper.cc b/content/renderer/render_widget_fullscreen_pepper.cc index 988b8ce..af8fd83 100644 --- a/content/renderer/render_widget_fullscreen_pepper.cc +++ b/content/renderer/render_widget_fullscreen_pepper.cc @@ -458,20 +458,6 @@ void RenderWidgetFullscreenPepper::Close() { RenderWidget::Close(); } -PepperPluginInstanceImpl* - RenderWidgetFullscreenPepper::GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* location, - gfx::Rect* clip, - float* scale_factor) { - if (plugin_ && plugin_->GetBitmapForOptimizedPluginPaint( - paint_bounds, dib, location, clip, scale_factor)) { - return plugin_; - } - return NULL; -} - void RenderWidgetFullscreenPepper::OnResize( const ViewMsg_Resize_Params& params) { if (layer_) diff --git a/content/renderer/render_widget_fullscreen_pepper.h b/content/renderer/render_widget_fullscreen_pepper.h index 5e2952c..0b97c9eb 100644 --- a/content/renderer/render_widget_fullscreen_pepper.h +++ b/content/renderer/render_widget_fullscreen_pepper.h @@ -61,12 +61,6 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen, virtual void DidInitiatePaint() OVERRIDE; virtual void DidFlushPaint() OVERRIDE; virtual void Close() OVERRIDE; - virtual PepperPluginInstanceImpl* GetBitmapForOptimizedPluginPaint( - const gfx::Rect& paint_bounds, - TransportDIB** dib, - gfx::Rect* location, - gfx::Rect* clip, - float* scale_factor) OVERRIDE; virtual void OnResize(const ViewMsg_Resize_Params& params) OVERRIDE; // RenderWidgetFullscreen API. |