summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc20
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.h14
-rw-r--r--chrome/renderer/render_view.cc9
-rw-r--r--chrome/renderer/render_view.h5
-rw-r--r--chrome/renderer/render_widget.cc33
-rw-r--r--chrome/renderer/render_widget.h15
6 files changed, 91 insertions, 5 deletions
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index 7ca9d4e..31b89ff 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -53,6 +53,10 @@ class PlatformImage2DImpl : public pepper::PluginDelegate::PlatformImage2D {
return reinterpret_cast<intptr_t>(dib_.get());
}
+ virtual TransportDIB* GetTransportDIB() const {
+ return dib_.get();
+ }
+
private:
int width_;
int height_;
@@ -520,6 +524,22 @@ void PepperPluginDelegateImpl::ViewFlushedPaint() {
}
}
+bool PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint(
+ const gfx::Rect& paint_bounds,
+ TransportDIB** dib,
+ gfx::Rect* location,
+ gfx::Rect* clip) {
+ for (std::set<pepper::PluginInstance*>::iterator i =
+ active_instances_.begin();
+ i != active_instances_.end(); ++i) {
+ pepper::PluginInstance* instance = *i;
+ if (instance->GetBitmapForOptimizedPluginPaint(
+ paint_bounds, dib, location, clip))
+ return true;
+ }
+ return false;
+}
+
void PepperPluginDelegateImpl::InstanceCreated(
pepper::PluginInstance* instance) {
active_instances_.insert(instance);
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.h b/chrome/renderer/pepper_plugin_delegate_impl.h
index a5808d5..8bacb44 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.h
+++ b/chrome/renderer/pepper_plugin_delegate_impl.h
@@ -19,6 +19,10 @@
class FilePath;
class RenderView;
+namespace gfx {
+class Rect;
+}
+
namespace pepper {
class FileIO;
class PluginInstance;
@@ -29,6 +33,8 @@ class WebFileChooserCompletion;
struct WebFileChooserParams;
}
+class TransportDIB;
+
class PepperPluginDelegateImpl
: public pepper::PluginDelegate,
public base::SupportsWeakPtr<PepperPluginDelegateImpl> {
@@ -41,6 +47,14 @@ class PepperPluginDelegateImpl
void ViewInitiatedPaint();
void ViewFlushedPaint();
+ // Called by RenderView to implement the corresponding function in its base
+ // class RenderWidget (see that for more).
+ bool GetBitmapForOptimizedPluginPaint(
+ const gfx::Rect& paint_bounds,
+ TransportDIB** dib,
+ gfx::Rect* location,
+ gfx::Rect* clip);
+
// Called by RenderView when ViewMsg_AsyncOpenFile_ACK.
void OnAsyncFileOpened(base::PlatformFileError error_code,
base::PlatformFile file,
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 9666b67..98fa378 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -4728,6 +4728,15 @@ void RenderView::DidFlushPaint() {
}
}
+bool RenderView::GetBitmapForOptimizedPluginPaint(
+ const gfx::Rect& paint_bounds,
+ TransportDIB** dib,
+ gfx::Rect* location,
+ gfx::Rect* clip) {
+ return pepper_delegate_.GetBitmapForOptimizedPluginPaint(
+ paint_bounds, dib, location, clip);
+}
+
void RenderView::OnClearFocusedNode() {
if (webview())
webview()->clearFocusedNode();
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index f0dad4d4..f267de6 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -619,6 +619,11 @@ class RenderView : public RenderWidget,
const gfx::Rect& resizer_rect);
virtual void DidInitiatePaint();
virtual void DidFlushPaint();
+ virtual bool GetBitmapForOptimizedPluginPaint(
+ const gfx::Rect& paint_bounds,
+ TransportDIB** dib,
+ gfx::Rect* location,
+ gfx::Rect* clip);
virtual void DidHandleKeyEvent();
virtual void DidHandleMouseEvent(const WebKit::WebMouseEvent& event);
virtual void OnSetFocus(bool enable);
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;
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index 6d80b62..e1dacf3 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -201,6 +201,21 @@ class RenderWidget : public IPC::Channel::Listener,
virtual void DidInitiatePaint() {}
virtual void DidFlushPaint() {}
+ // Detects if a suitable opaque plugin covers the given paint bounds with no
+ // compositing necessary.
+ //
+ // Returns true 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 false means optimized painting can not be used and we
+ // should continue with the normal painting code path.
+ virtual bool GetBitmapForOptimizedPluginPaint(
+ const gfx::Rect& paint_bounds,
+ TransportDIB** dib,
+ gfx::Rect* location,
+ gfx::Rect* clip);
+
// Sets the "hidden" state of this widget. All accesses to is_hidden_ should
// use this method so that we can properly inform the RenderThread of our
// state.