summaryrefslogtreecommitdiffstats
path: root/mojo/services/native_viewport/native_viewport_impl.cc
diff options
context:
space:
mode:
authorsashab@chromium.org <sashab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-19 01:14:32 +0000
committersashab@chromium.org <sashab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-19 01:15:49 +0000
commit0527c78a980e09b22dc0fb9444f76cf42131e931 (patch)
treebf946650051c9332c37ad7b75df148301f5dd27b /mojo/services/native_viewport/native_viewport_impl.cc
parent12b43a849f8309bd8211a8210ab9513eaa190b8e (diff)
downloadchromium_src-0527c78a980e09b22dc0fb9444f76cf42131e931.zip
chromium_src-0527c78a980e09b22dc0fb9444f76cf42131e931.tar.gz
chromium_src-0527c78a980e09b22dc0fb9444f76cf42131e931.tar.bz2
Revert 290431 "Mojo multiple command buffer support and sample"
> Mojo multiple command buffer support and sample > > TBR=danakj@chromium.org for DEPS file shuffle that moves a "+ui/gfx" > > Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=290157 > > Review URL: https://codereview.chromium.org/451753003 Caused compile failure on Linux ChromeOS: http://build.chromium.org/p/chromium/builders/Linux/builds/52407/steps/compile/logs/stdio TBR=jamesr@chromium.org Review URL: https://codereview.chromium.org/486053002 Cr-Commit-Position: refs/heads/master@{#290442} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290442 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/services/native_viewport/native_viewport_impl.cc')
-rw-r--r--mojo/services/native_viewport/native_viewport_impl.cc37
1 files changed, 34 insertions, 3 deletions
diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc
index e662a6d..8755dfd 100644
--- a/mojo/services/native_viewport/native_viewport_impl.cc
+++ b/mojo/services/native_viewport/native_viewport_impl.cc
@@ -4,7 +4,6 @@
#include "mojo/services/native_viewport/native_viewport_impl.h"
-#include "base/bind.h"
#include "base/macros.h"
#include "base/message_loop/message_loop.h"
#include "base/time/time.h"
@@ -39,6 +38,7 @@ NativeViewportImpl::~NativeViewportImpl() {
void NativeViewportImpl::Create(RectPtr bounds) {
platform_viewport_ = PlatformViewport::Create(this);
platform_viewport_->Init(bounds.To<gfx::Rect>());
+ client()->OnCreated();
OnBoundsChanged(bounds.To<gfx::Rect>());
}
@@ -51,6 +51,7 @@ void NativeViewportImpl::Hide() {
}
void NativeViewportImpl::Close() {
+ command_buffer_.reset();
DCHECK(platform_viewport_);
platform_viewport_->Close();
}
@@ -59,14 +60,25 @@ void NativeViewportImpl::SetBounds(RectPtr bounds) {
platform_viewport_->SetBounds(bounds.To<gfx::Rect>());
}
+void NativeViewportImpl::CreateGLES2Context(
+ InterfaceRequest<CommandBuffer> command_buffer_request) {
+ if (command_buffer_ || command_buffer_request_.is_pending()) {
+ LOG(ERROR) << "Can't create multiple contexts on a NativeViewport";
+ return;
+ }
+ command_buffer_request_ = command_buffer_request.Pass();
+ CreateCommandBufferIfNeeded();
+}
+
void NativeViewportImpl::OnBoundsChanged(const gfx::Rect& bounds) {
+ CreateCommandBufferIfNeeded();
client()->OnBoundsChanged(Rect::From(bounds));
}
void NativeViewportImpl::OnAcceleratedWidgetAvailable(
gfx::AcceleratedWidget widget) {
widget_ = widget;
- client()->OnCreated(reinterpret_cast<uint64_t>(widget));
+ CreateCommandBufferIfNeeded();
}
bool NativeViewportImpl::OnEvent(ui::Event* ui_event) {
@@ -96,12 +108,31 @@ bool NativeViewportImpl::OnEvent(ui::Event* ui_event) {
}
void NativeViewportImpl::OnDestroyed() {
- client()->OnDestroyed();
+ client()->OnDestroyed(base::Bind(&NativeViewportImpl::AckDestroyed,
+ base::Unretained(this)));
}
void NativeViewportImpl::AckEvent() {
waiting_for_event_ack_ = false;
}
+void NativeViewportImpl::CreateCommandBufferIfNeeded() {
+ if (!command_buffer_request_.is_pending())
+ return;
+ DCHECK(!command_buffer_.get());
+ if (widget_ == gfx::kNullAcceleratedWidget)
+ return;
+ gfx::Size size = platform_viewport_->GetSize();
+ if (size.IsEmpty())
+ return;
+ command_buffer_.reset(
+ new CommandBufferImpl(widget_, platform_viewport_->GetSize()));
+ WeakBindToRequest(command_buffer_.get(), &command_buffer_request_);
+}
+
+void NativeViewportImpl::AckDestroyed() {
+ command_buffer_.reset();
+}
+
} // namespace mojo