summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authordtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-06 22:40:25 +0000
committerdtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-06 22:40:25 +0000
commitdddabb1061c751d3e5f843c9cde986062539f8bd (patch)
treed2833da4862b8738aa1e05b382b31fd73e214276 /content
parent1c210f69e18070b479821fd2f023f6e9b55ef29d (diff)
downloadchromium_src-dddabb1061c751d3e5f843c9cde986062539f8bd.zip
chromium_src-dddabb1061c751d3e5f843c9cde986062539f8bd.tar.gz
chromium_src-dddabb1061c751d3e5f843c9cde986062539f8bd.tar.bz2
Push ContentViewCore size change to RWHV
- Properly propagate onSizeChanged events to ContentViewCore native and RWHVA. - Tie RWHVA's size to the ContentViewCore, making sure it always pulls the right size. - Fix what looks like a bug in TextureImageTransportSurface (thanks sievers@!). We were exposing the size of the old buffer through GetSize() when we were dispatching swap messages. BUG=http://crbug.com/158430 Review URL: https://chromiumcodereview.appspot.com/11367021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166288 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/android/content_view_core_impl.cc20
-rw-r--r--content/browser/android/content_view_core_impl.h1
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.cc15
-rw-r--r--content/browser/renderer_host/render_widget_host_view_android.h4
-rw-r--r--content/common/gpu/image_transport_surface.cc6
-rw-r--r--content/common/gpu/image_transport_surface_mac.cc2
-rw-r--r--content/common/gpu/image_transport_surface_win.cc1
-rw-r--r--content/common/gpu/texture_image_transport_surface.cc3
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java20
9 files changed, 52 insertions, 20 deletions
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index c51db8d..6dfb14d 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -522,6 +522,15 @@ void ContentViewCoreImpl::ShowDisambiguationPopup(
java_bitmap.obj());
}
+gfx::Rect ContentViewCoreImpl::GetBounds() const {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env);
+ if (j_obj.is_null())
+ return gfx::Rect();
+ return gfx::Rect(Java_ContentViewCore_getWidth(env, j_obj.obj()),
+ Java_ContentViewCore_getHeight(env, j_obj.obj()));
+}
+
void ContentViewCoreImpl::LoadUrl(
NavigationController::LoadURLParams& params) {
GetWebContents()->GetController().LoadURLWithParams(params);
@@ -965,6 +974,17 @@ jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env,
return view->PopulateBitmapWithContents(jbitmap);
}
+void ContentViewCoreImpl::SetSize(JNIEnv* env,
+ jobject obj,
+ jint width,
+ jint height) {
+ RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
+ if (!view)
+ return;
+
+ view->SetSize(gfx::Size(width, height));
+}
+
void ContentViewCoreImpl::ScrollFocusedEditableNodeIntoView(JNIEnv* env,
jobject obj) {
RenderViewHost* host = web_contents_->GetRenderViewHost();
diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h
index 5a9dd71..070d542 100644
--- a/content/browser/android/content_view_core_impl.h
+++ b/content/browser/android/content_view_core_impl.h
@@ -181,6 +181,7 @@ class ContentViewCoreImpl : public ContentViewCore,
jboolean PopulateBitmapFromCompositor(JNIEnv* env,
jobject obj,
jobject jbitmap);
+ void SetSize(JNIEnv* env, jobject obj, jint width, jint height);
// --------------------------------------------------------------------------
// Public methods that call to Java via JNI
diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
index 9e60ae7..18f1155 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.cc
+++ b/content/browser/renderer_host/render_widget_host_view_android.cc
@@ -11,7 +11,6 @@
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "content/browser/android/content_view_core_impl.h"
-#include "content/browser/android/draw_delegate_impl.h"
#include "content/browser/gpu/gpu_surface_tracker.h"
#include "content/browser/renderer_host/compositor_impl_android.h"
#include "content/browser/renderer_host/image_transport_factory_android.h"
@@ -116,12 +115,7 @@ void RenderWidgetHostViewAndroid::WasHidden() {
}
void RenderWidgetHostViewAndroid::SetSize(const gfx::Size& size) {
- // Update the size of the RWH.
- if (requested_size_.width() != size.width() ||
- requested_size_.height() != size.height()) {
- requested_size_ = gfx::Size(size.width(), size.height());
- host_->WasResized();
- }
+ host_->WasResized();
}
void RenderWidgetHostViewAndroid::SetBounds(const gfx::Rect& rect) {
@@ -243,11 +237,10 @@ bool RenderWidgetHostViewAndroid::IsShowing() {
}
gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const {
- gfx::Size bounds = DrawDelegateImpl::GetInstance()->GetBounds();
- if (!bounds.IsEmpty())
- return gfx::Rect(bounds);
+ if (!content_view_core_)
+ return gfx::Rect();
- return gfx::Rect(requested_size_);
+ return content_view_core_->GetBounds();
}
void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) {
diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h
index 000eab6..fcaffe0 100644
--- a/content/browser/renderer_host/render_widget_host_view_android.h
+++ b/content/browser/renderer_host/render_widget_host_view_android.h
@@ -153,10 +153,6 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase {
// ContentViewCoreImpl is our interface to the view system.
ContentViewCoreImpl* content_view_core_;
- // The size that we want the renderer to be. We keep this in a separate
- // variable because resizing is async.
- gfx::Size requested_size_;
-
ImeAdapterAndroid ime_adapter_android_;
// Body background color of the underlying document.
diff --git a/content/common/gpu/image_transport_surface.cc b/content/common/gpu/image_transport_surface.cc
index fe90913..e0f1e2f 100644
--- a/content/common/gpu/image_transport_surface.cc
+++ b/content/common/gpu/image_transport_surface.cc
@@ -123,10 +123,9 @@ void ImageTransportHelper::SendAcceleratedSurfaceBuffersSwapped(
// TRACE_EVENT for gpu tests:
TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffers",
"GLImpl", static_cast<int>(gfx::GetGLImplementation()),
- "width", surface_->GetSize().width());
+ "width", params.size.width());
params.surface_id = stub_->surface_id();
params.route_id = route_id_;
- params.size = surface_->GetSize();
#if defined(OS_MACOSX)
params.window = handle_;
#endif
@@ -137,7 +136,6 @@ void ImageTransportHelper::SendAcceleratedSurfacePostSubBuffer(
GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params) {
params.surface_id = stub_->surface_id();
params.route_id = route_id_;
- params.surface_size = surface_->GetSize();
#if defined(OS_MACOSX)
params.window = handle_;
#endif
@@ -285,6 +283,7 @@ bool PassThroughImageTransportSurface::SwapBuffers() {
// SwapBuffers message.
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_handle = 0;
+ params.size = surface()->GetSize();
helper_->SendAcceleratedSurfaceBuffersSwapped(params);
helper_->SetScheduled(false);
@@ -302,6 +301,7 @@ bool PassThroughImageTransportSurface::PostSubBuffer(
// PostSubBuffer message.
GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params;
params.surface_handle = 0;
+ params.surface_size = surface()->GetSize();
params.x = x;
params.y = y;
params.width = width;
diff --git a/content/common/gpu/image_transport_surface_mac.cc b/content/common/gpu/image_transport_surface_mac.cc
index 0070c0e..45c1a17 100644
--- a/content/common/gpu/image_transport_surface_mac.cc
+++ b/content/common/gpu/image_transport_surface_mac.cc
@@ -235,6 +235,7 @@ bool IOSurfaceImageTransportSurface::SwapBuffers() {
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_handle = io_surface_handle_;
+ params.size = GetSize();
helper_->SendAcceleratedSurfaceBuffersSwapped(params);
DCHECK(!is_swap_buffers_pending_);
@@ -255,6 +256,7 @@ bool IOSurfaceImageTransportSurface::PostSubBuffer(
params.y = y;
params.width = width;
params.height = height;
+ params.surface_size = GetSize();
helper_->SendAcceleratedSurfacePostSubBuffer(params);
DCHECK(!is_swap_buffers_pending_);
diff --git a/content/common/gpu/image_transport_surface_win.cc b/content/common/gpu/image_transport_surface_win.cc
index 930c888..54d9e06 100644
--- a/content/common/gpu/image_transport_surface_win.cc
+++ b/content/common/gpu/image_transport_surface_win.cc
@@ -198,6 +198,7 @@ void PbufferImageTransportSurface::SendBuffersSwapped() {
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_handle = reinterpret_cast<int64>(GetShareHandle());
CHECK(params.surface_handle);
+ params.size = GetSize();
helper_->SendAcceleratedSurfaceBuffersSwapped(params);
diff --git a/content/common/gpu/texture_image_transport_surface.cc b/content/common/gpu/texture_image_transport_surface.cc
index ec9aeb4..4ad192e 100644
--- a/content/common/gpu/texture_image_transport_surface.cc
+++ b/content/common/gpu/texture_image_transport_surface.cc
@@ -268,6 +268,7 @@ bool TextureImageTransportSurface::SwapBuffers() {
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_handle = textures_[front()].client_id;
+ params.size = textures_[front()].size;
params.protection_state_id = protection_state_id_;
params.skip_ack = false;
helper_->SendAcceleratedSurfaceBuffersSwapped(params);
@@ -336,6 +337,7 @@ bool TextureImageTransportSurface::PostSubBuffer(
GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params;
params.surface_handle = textures_[front()].client_id;
+ params.surface_size = textures_[front()].size;
params.x = x;
params.y = y;
params.width = width;
@@ -386,6 +388,7 @@ void TextureImageTransportSurface::OnSetFrontSurfaceIsProtected(
textures_[front()].sent_to_client) {
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
params.surface_handle = textures_[front()].client_id;
+ params.size = textures_[front()].size;
params.protection_state_id = protection_state_id_;
params.skip_ack = true;
helper_->SendAcceleratedSurfaceBuffersSwapped(params);
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 6bf6147..97a72d5 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -168,6 +168,10 @@ public class ContentViewCore implements MotionEventDelegate {
private int mContentWidth;
private int mContentHeight;
+ // Cached size of the viewport
+ private int mViewportWidth;
+ private int mViewportHeight;
+
// Cached page scale factor from native
private float mNativePageScaleFactor = 1.0f;
private float mNativeMinimumScale = 1.0f;
@@ -711,12 +715,14 @@ public class ContentViewCore implements MotionEventDelegate {
return null;
}
+ @CalledByNative
public int getWidth() {
- return mContainerView.getWidth();
+ return mViewportWidth;
}
+ @CalledByNative
public int getHeight() {
- return mContainerView.getHeight();
+ return mViewportHeight;
}
/**
@@ -1152,6 +1158,14 @@ public class ContentViewCore implements MotionEventDelegate {
// Update the content size to make sure it is at least the View size
if (mContentWidth < w) mContentWidth = w;
if (mContentHeight < h) mContentHeight = h;
+
+ if (mViewportWidth != w || mViewportHeight != h) {
+ mViewportWidth = w;
+ mViewportHeight = h;
+ if (mNativeContentViewCore != 0) {
+ nativeSetSize(mNativeContentViewCore, mViewportWidth, mViewportHeight);
+ }
+ }
}
public void updateAfterSizeChanged() {
@@ -2326,4 +2340,6 @@ public class ContentViewCore implements MotionEventDelegate {
private native boolean nativePopulateBitmapFromCompositor(int nativeContentViewCoreImpl,
Bitmap bitmap);
+
+ private native void nativeSetSize(int nativeContentViewCoreImpl, int width, int height);
}