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

Unified Diff: android_webview/renderer/aw_render_view_ext.cc

Issue 11861008: Expose the capturePicture feature in RenderView for Android WebView legacy API support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed sync IPC issues. Created 7 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/renderer/aw_render_view_ext.cc
diff --git a/android_webview/renderer/aw_render_view_ext.cc b/android_webview/renderer/aw_render_view_ext.cc
index b3813521e1d0be38fa479c2a028aa2ad9ff62065..a193d89e62e1efb24aab852de1b2062b6e0e18f3 100644
--- a/android_webview/renderer/aw_render_view_ext.cc
+++ b/android_webview/renderer/aw_render_view_ext.cc
@@ -15,6 +15,7 @@
#include "content/public/renderer/android_content_detection_prefixes.h"
#include "content/public/renderer/document_state.h"
#include "content/public/renderer/render_view.h"
+#include "skia/ext/refptr.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebURL.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
@@ -27,6 +28,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+#include "third_party/skia/include/core/SkPicture.h"
namespace android_webview {
@@ -127,18 +129,13 @@ void PopulateHitTestData(const GURL& absolute_link_url,
AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view)
: content::RenderViewObserver(render_view) {
render_view->GetWebView()->setPermissionClient(this);
- // TODO(leandrogracia): enable once the feature is available in RenderView.
// TODO(leandrogracia): remove when SW rendering uses Ubercompositor.
// Until then we need the callback enabled for SW mode invalidation.
// http://crbug.com/170086.
- //render_view->SetCapturePictureCallback(
- // base::Bind(&AwRenderViewExt::OnPictureUpdate, AsWeakPtr()));
+ capture_picture_enabled_ = true;
}
AwRenderViewExt::~AwRenderViewExt() {
- // TODO(leandrogracia): enable once the feature is available in RenderView.
- //render_view()->SetCapturePictureCallback(
- // content::RenderView::CapturePictureCallback());
RendererPictureMap::GetInstance()->ClearRendererPicture(routing_id());
}
@@ -229,6 +226,15 @@ void AwRenderViewExt::FocusedNodeChanged(const WebKit::WebNode& node) {
Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data));
}
+void AwRenderViewExt::DidCommitCompositorFrame() {
+ if (!capture_picture_enabled_)
+ return;
+
+ skia::RefPtr<SkPicture> picture = render_view()->CapturePicture();
+ RendererPictureMap::GetInstance()->SetRendererPicture(routing_id(), picture);
+ Send(new AwViewHostMsg_PictureUpdated(routing_id()));
+}
+
void AwRenderViewExt::OnDoHitTest(int view_x, int view_y) {
if (!render_view() || !render_view()->GetWebView())
return;
@@ -251,21 +257,12 @@ void AwRenderViewExt::OnDoHitTest(int view_x, int view_y) {
}
void AwRenderViewExt::OnEnableCapturePictureCallback(bool enable) {
- // TODO(leandrogracia): enable once the feature is available in RenderView.
- //render_view()->SetCapturePictureCallback(enable ?
- // base::Bind(&AwRenderViewExt::OnPictureUpdate, AsWeakPtr()) :
- // content::RenderView::CapturePictureCallback());
-}
-
-void AwRenderViewExt::OnPictureUpdate(skia::RefPtr<SkPicture> picture) {
- RendererPictureMap::GetInstance()->SetRendererPicture(routing_id(), picture);
- Send(new AwViewHostMsg_PictureUpdated(routing_id()));
+ capture_picture_enabled_ = enable;
}
void AwRenderViewExt::OnCapturePictureSync() {
- // TODO(leandrogracia): enable once the feature is available in RenderView.
- //RendererPictureMap::GetInstance()->SetRendererPicture(
- // routing_id(), render_view()->CapturePicture());
+ RendererPictureMap::GetInstance()->SetRendererPicture(
+ routing_id(), render_view()->CapturePicture());
}
} // namespace android_webview

Powered by Google App Engine
This is Rietveld 408576698