summaryrefslogtreecommitdiffstats
path: root/mojo/services/native_viewport
diff options
context:
space:
mode:
authorsky <sky@chromium.org>2014-09-30 12:06:28 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-30 19:06:39 +0000
commit5b19be3a063c7dd7ab0d414030750c733e6d9c56 (patch)
tree654081b00c8924989709e92ea5816f8b9eb8900f /mojo/services/native_viewport
parente650b32b0453a45e0bdcb248f93092f1bd1f817f (diff)
downloadchromium_src-5b19be3a063c7dd7ab0d414030750c733e6d9c56.zip
chromium_src-5b19be3a063c7dd7ab0d414030750c733e6d9c56.tar.gz
chromium_src-5b19be3a063c7dd7ab0d414030750c733e6d9c56.tar.bz2
Makes NativeViewport send OnBoundsChanged() after widget available
It was possible for us to send it before. BUG=none TEST=none R=ben@chromium.org, darin@chromium.org Review URL: https://codereview.chromium.org/617513003 Cr-Commit-Position: refs/heads/master@{#297472}
Diffstat (limited to 'mojo/services/native_viewport')
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.cc26
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.h2
2 files changed, 22 insertions, 6 deletions
diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc
index 6aba9ab..3006612 100644
--- a/mojo/services/native_viewport/native_viewport_impl.cc
+++ b/mojo/services/native_viewport/native_viewport_impl.cc
@@ -4,6 +4,7 @@
#include "mojo/services/native_viewport/native_viewport_impl.h"
+#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
@@ -48,13 +49,12 @@ NativeViewportImpl::~NativeViewportImpl() {
void NativeViewportImpl::Create(SizePtr size,
const Callback<void(uint64_t)>& callback) {
create_callback_ = callback;
+ size_ = size.To<gfx::Size>();
if (is_headless_)
platform_viewport_ = PlatformViewportHeadless::Create(this);
else
platform_viewport_ = PlatformViewport::Create(this);
- const gfx::Rect bounds(gfx::Rect(size.To<gfx::Size>()));
- platform_viewport_->Init(bounds);
- OnBoundsChanged(bounds);
+ platform_viewport_->Init(gfx::Rect(size.To<gfx::Size>()));
}
void NativeViewportImpl::Show() {
@@ -94,10 +94,14 @@ void NativeViewportImpl::SubmittedFrame(SurfaceIdPtr child_surface_id) {
}
void NativeViewportImpl::OnBoundsChanged(const gfx::Rect& bounds) {
+ if (size_ == bounds.size())
+ return;
+
size_ = bounds.size();
- client()->OnSizeChanged(Size::From(size_));
- if (viewport_surface_)
- viewport_surface_->SetSize(size_);
+
+ // Wait for the accelerated widget before telling the client of the bounds.
+ if (create_callback_.is_null())
+ ProcessOnBoundsChanged();
}
void NativeViewportImpl::OnAcceleratedWidgetAvailable(
@@ -105,6 +109,10 @@ void NativeViewportImpl::OnAcceleratedWidgetAvailable(
widget_id_ = static_cast<uint64_t>(bit_cast<uintptr_t>(widget));
// TODO(jamesr): Remove once everything is converted to surfaces.
create_callback_.Run(widget_id_);
+ create_callback_.reset();
+ // Immediately tell the client of the size. The size may be wrong, if so we'll
+ // get the right one in the next OnBoundsChanged() call.
+ ProcessOnBoundsChanged();
if (viewport_surface_)
viewport_surface_->SetWidgetId(widget_id_);
}
@@ -142,5 +150,11 @@ void NativeViewportImpl::AckEvent() {
waiting_for_event_ack_ = false;
}
+void NativeViewportImpl::ProcessOnBoundsChanged() {
+ client()->OnSizeChanged(Size::From(size_));
+ if (viewport_surface_)
+ viewport_surface_->SetSize(size_);
+}
+
} // namespace mojo
diff --git a/mojo/services/native_viewport/native_viewport_impl.h b/mojo/services/native_viewport/native_viewport_impl.h
index 82f38a9..ad8e5c4 100644
--- a/mojo/services/native_viewport/native_viewport_impl.h
+++ b/mojo/services/native_viewport/native_viewport_impl.h
@@ -46,6 +46,8 @@ class NativeViewportImpl : public InterfaceImpl<NativeViewport>,
void AckEvent();
private:
+ void ProcessOnBoundsChanged();
+
bool is_headless_;
scoped_ptr<PlatformViewport> platform_viewport_;
scoped_ptr<ViewportSurface> viewport_surface_;