Commit 1a8376c7 authored by powei@chromium.org's avatar powei@chromium.org

android: Fix snapshot height by including toolbar offset

The Android snapshot was found to be chopping off the bottom content.  This is
due to not accounting for the height of the toolbar.  This patch enlarges the
snapshot by that offset.

BUG=384551

Review URL: https://codereview.chromium.org/340603002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278843 0039d316-1c4b-4281-b951-d872f2087c98
parent af86ae79
...@@ -394,11 +394,8 @@ void ContentViewCoreImpl::UpdateFrameInfo( ...@@ -394,11 +394,8 @@ void ContentViewCoreImpl::UpdateFrameInfo(
return; return;
if (window_android_) { if (window_android_) {
gfx::Vector2dF window_offset(
Java_ContentViewCore_getLocationInWindowX(env, obj.obj()),
Java_ContentViewCore_getLocationInWindowY(env, obj.obj()));
window_android_->set_content_offset( window_android_->set_content_offset(
gfx::ScaleVector2d(content_offset, dpi_scale_) + window_offset); gfx::ScaleVector2d(content_offset, dpi_scale_));
} }
Java_ContentViewCore_updateFrameInfo( Java_ContentViewCore_updateFrameInfo(
......
...@@ -29,8 +29,6 @@ public class ContentView extends FrameLayout ...@@ -29,8 +29,6 @@ public class ContentView extends FrameLayout
protected final ContentViewCore mContentViewCore; protected final ContentViewCore mContentViewCore;
private final int[] mLocationInWindow = new int[2];
/** /**
* Creates an instance of a ContentView. * Creates an instance of a ContentView.
* @param context The Context the view is running in, through which it can * @param context The Context the view is running in, through which it can
...@@ -80,15 +78,6 @@ public class ContentView extends FrameLayout ...@@ -80,15 +78,6 @@ public class ContentView extends FrameLayout
TraceEvent.end(); TraceEvent.end();
} }
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (changed) {
getLocationInWindow(mLocationInWindow);
mContentViewCore.onLocationInWindowChanged(mLocationInWindow[0], mLocationInWindow[1]);
}
}
@Override @Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) { public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
return mContentViewCore.onCreateInputConnection(outAttrs); return mContentViewCore.onCreateInputConnection(outAttrs);
......
...@@ -257,8 +257,6 @@ public class ContentViewCore ...@@ -257,8 +257,6 @@ public class ContentViewCore
private int mOverdrawBottomHeightPix; private int mOverdrawBottomHeightPix;
private int mViewportSizeOffsetWidthPix; private int mViewportSizeOffsetWidthPix;
private int mViewportSizeOffsetHeightPix; private int mViewportSizeOffsetHeightPix;
private int mLocationInWindowX;
private int mLocationInWindowY;
// Cached copy of all positions and scales as reported by the renderer. // Cached copy of all positions and scales as reported by the renderer.
private final RenderCoordinates mRenderCoordinates; private final RenderCoordinates mRenderCoordinates;
...@@ -1493,15 +1491,6 @@ public class ContentViewCore ...@@ -1493,15 +1491,6 @@ public class ContentViewCore
updateAfterSizeChanged(); updateAfterSizeChanged();
} }
/**
* Called when the ContentView's position in the activity window changed. This information is
* used for cropping screenshots.
*/
public void onLocationInWindowChanged(int x, int y) {
mLocationInWindowX = x;
mLocationInWindowY = y;
}
/** /**
* Called when the underlying surface the compositor draws to changes size. * Called when the underlying surface the compositor draws to changes size.
* This may be larger than the viewport size. * This may be larger than the viewport size.
...@@ -2995,16 +2984,6 @@ public class ContentViewCore ...@@ -2995,16 +2984,6 @@ public class ContentViewCore
return mRenderCoordinates; return mRenderCoordinates;
} }
@CalledByNative
private int getLocationInWindowX() {
return mLocationInWindowX;
}
@CalledByNative
private int getLocationInWindowY() {
return mLocationInWindowY;
}
@CalledByNative @CalledByNative
private static Rect createRect(int x, int y, int right, int bottom) { private static Rect createRect(int x, int y, int right, int bottom) {
return new Rect(x, y, right, bottom); return new Rect(x, y, right, bottom);
......
...@@ -24,4 +24,8 @@ class PixelExpectations(test_expectations.TestExpectations): ...@@ -24,4 +24,8 @@ class PixelExpectations(test_expectations.TestExpectations):
# self.Fail('Pixel.Canvas2DRedBox', # self.Fail('Pixel.Canvas2DRedBox',
# ['mac', 'amd', ('nvidia', 0x1234)], bug=123) # ['mac', 'amd', ('nvidia', 0x1234)], bug=123)
self.Fail('Pixel.Canvas2DRedBox', bug=384551)
self.Fail('Pixel.CSS3DBlueBox', bug=384551)
self.Fail('Pixel.WebGLGreenTriangle', bug=384551)
pass pass
...@@ -32,19 +32,19 @@ class PixelTestsPageSet(page_set_module.PageSet): ...@@ -32,19 +32,19 @@ class PixelTestsPageSet(page_set_module.PageSet):
url='file://../../data/gpu/pixel_canvas2d.html', url='file://../../data/gpu/pixel_canvas2d.html',
name='Pixel.Canvas2DRedBox', name='Pixel.Canvas2DRedBox',
test_rect=[0, 0, 300, 300], test_rect=[0, 0, 300, 300],
revision=3, revision=4,
page_set=self)) page_set=self))
self.AddPage(PixelTestsPage( self.AddPage(PixelTestsPage(
url='file://../../data/gpu/pixel_css3d.html', url='file://../../data/gpu/pixel_css3d.html',
name='Pixel.CSS3DBlueBox', name='Pixel.CSS3DBlueBox',
test_rect=[0, 0, 300, 300], test_rect=[0, 0, 300, 300],
revision=8, revision=9,
page_set=self)) page_set=self))
self.AddPage(PixelTestsPage( self.AddPage(PixelTestsPage(
url='file://../../data/gpu/pixel_webgl.html', url='file://../../data/gpu/pixel_webgl.html',
name='Pixel.WebGLGreenTriangle', name='Pixel.WebGLGreenTriangle',
test_rect=[0, 0, 300, 300], test_rect=[0, 0, 300, 300],
revision=7, revision=8,
page_set=self)) page_set=self))
...@@ -36,6 +36,10 @@ class UI_BASE_EXPORT WindowAndroid { ...@@ -36,6 +36,10 @@ class UI_BASE_EXPORT WindowAndroid {
content_offset_ = content_offset; content_offset_ = content_offset;
} }
gfx::Vector2dF content_offset() const {
return content_offset_;
}
// Compositor callback relay. // Compositor callback relay.
void OnCompositingDidCommit(); void OnCompositingDidCommit();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ui/base/android/window_android.h" #include "ui/base/android/window_android.h"
#include "ui/base/android/window_android_compositor.h" #include "ui/base/android/window_android_compositor.h"
#include "ui/gfx/display.h" #include "ui/gfx/display.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "ui/snapshot/snapshot_async.h" #include "ui/snapshot/snapshot_async.h"
...@@ -44,7 +45,14 @@ static void MakeAsyncCopyRequest( ...@@ -44,7 +45,14 @@ static void MakeAsyncCopyRequest(
gfx::Rect source_rect_in_pixel = gfx::Rect source_rect_in_pixel =
gfx::ToEnclosingRect(gfx::ScaleRect(source_rect, device_scale_factor)); gfx::ToEnclosingRect(gfx::ScaleRect(source_rect, device_scale_factor));
request->set_area(source_rect_in_pixel); // Account for the toolbar offset.
gfx::Vector2dF offset = window->content_offset();
gfx::Rect adjusted_source_rect(gfx::ToRoundedPoint(
gfx::PointF(source_rect_in_pixel.x() + offset.x(),
source_rect_in_pixel.y() + offset.y())),
source_rect_in_pixel.size());
request->set_area(adjusted_source_rect);
window->GetCompositor()->RequestCopyOfOutputOnRootLayer(request.Pass()); window->GetCompositor()->RequestCopyOfOutputOnRootLayer(request.Pass());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment