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

Unified Diff: android_webview/native/aw_contents.cc

Issue 11732002: [Android WebView] Update SW rendering to use SkPicture and fix scrolling cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: extend to fix sw rendering scroll. Created 7 years, 12 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
« no previous file with comments | « android_webview/native/aw_contents.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_contents.cc
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index 778400ef776ec363460d0d7a0ed7a02df37a27ac..c32940decc7eca6b943a19398cec3c6f9b411fb2 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -160,7 +160,6 @@ AwContents::AwContents(JNIEnv* env,
view_visible_(false),
compositor_visible_(false),
is_composite_pending_(false),
- last_scroll_x_(0), last_scroll_y_(0),
last_frame_context_(NULL) {
RendererPictureMap::CreateInstance();
android_webview::AwBrowserDependencyFactory* dependency_factory =
@@ -313,7 +312,6 @@ void AwContents::DrawGL(AwDrawGLInfo* draw_info) {
last_frame_context_ = current_context;
}
- gfx::Transform transform;
compositor_->SetWindowBounds(gfx::Size(draw_info->width, draw_info->height));
if (draw_info->is_layer) {
@@ -322,6 +320,7 @@ void AwContents::DrawGL(AwDrawGLInfo* draw_info) {
// The Android framework will composite us afterwards.
compositor_->SetHasTransparentBackground(false);
view_clip_layer_->setMasksToBounds(false);
+ transform_layer_->setTransform(gfx::Transform());
scissor_clip_layer_->setMasksToBounds(false);
scissor_clip_layer_->setPosition(gfx::PointF());
scissor_clip_layer_->setBounds(gfx::Size());
@@ -346,15 +345,17 @@ void AwContents::DrawGL(AwDrawGLInfo* draw_info) {
undo_clip_position.Translate(-clip_rect.x(), -clip_rect.y());
scissor_clip_layer_->setSublayerTransform(undo_clip_position);
+ gfx::Transform transform;
transform.matrix().setColMajorf(draw_info->transform);
+
+ // The scrolling values of the Android Framework affect the transformation
+ // matrix. This needs to be undone to let the compositor handle scrolling.
+ transform.Translate(hw_rendering_scroll_.x(), hw_rendering_scroll_.y());
+ transform_layer_->setTransform(transform);
+
view_clip_layer_->setMasksToBounds(true);
}
- // The scrolling values of the Android Framework affect the transformation
- // matrix. This needs to be undone to let the compositor handle scrolling.
- transform.Translate(last_scroll_x_, last_scroll_y_);
- transform_layer_->setTransform(transform);
-
compositor_->Composite();
is_composite_pending_ = false;
@@ -421,7 +422,8 @@ void AwContents::DrawGL(AwDrawGLInfo* draw_info) {
// ---------------------------------------------------------------------------
}
-bool AwContents::DrawSW(JNIEnv* env, jobject obj, jobject java_canvas) {
+bool AwContents::DrawSW(JNIEnv* env, jobject obj, jobject java_canvas,
+ jint scroll_x, jint scroll_y) {
scoped_refptr<cc::PicturePileImpl> picture =
RendererPictureMap::GetInstance()->GetRendererPicture(
web_contents_->GetRoutingID());
@@ -450,6 +452,9 @@ bool AwContents::DrawSW(JNIEnv* env, jobject obj, jobject java_canvas) {
}
canvas.setMatrix(matrix);
+ // Scroll needs to be undone to let the Chrome compositor handle scrolling.
+ canvas.translate(scroll_x, scroll_y);
Leandro GraciĆ” Gil 2013/01/04 21:21:24 As part of the review of https://codereview.chromi
+
SkRegion clip;
if (pixels->clip_region_size) {
size_t bytes_read = clip.readFromMemory(pixels->clip_region);
@@ -459,12 +464,10 @@ bool AwContents::DrawSW(JNIEnv* env, jobject obj, jobject java_canvas) {
clip.setRect(SkIRect::MakeWH(pixels->width, pixels->height));
}
- SkIRect sk_clip_rect = clip.getBounds();
- gfx::Rect clip_rect(sk_clip_rect.x(), sk_clip_rect.y(),
- sk_clip_rect.width(), sk_clip_rect.height());
-
cc::RenderingStats stats;
- picture->Raster(&canvas, clip_rect, 1.0, &stats);
+ gfx::Rect content_rect(scroll_x, scroll_y, view_size_.width(),
+ view_size_.height());
+ picture->Raster(&canvas, content_rect, 1.0, &stats);
}
g_draw_sw_functions->release_pixels(pixels);
@@ -860,8 +863,7 @@ jboolean AwContents::RestoreFromOpaqueState(
void AwContents::SetScrollForHWFrame(JNIEnv* env, jobject obj,
int scroll_x, int scroll_y) {
- last_scroll_x_ = scroll_x;
- last_scroll_y_ = scroll_y;
+ hw_rendering_scroll_ = gfx::Point(scroll_x, scroll_y);
}
void AwContents::SetPendingWebContentsForPopup(
« no previous file with comments | « android_webview/native/aw_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698