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

Unified Diff: mojo/services/native_viewport/native_viewport_impl.cc

Issue 478103002: Revert of Mojo multiple command buffer support and sample (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | « mojo/services/native_viewport/native_viewport_impl.h ('k') | mojo/services/public/interfaces/gpu/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/native_viewport/native_viewport_impl.cc
diff --git a/mojo/services/native_viewport/native_viewport_impl.cc b/mojo/services/native_viewport/native_viewport_impl.cc
index e662a6d38a045d6c6b8adcccc1d79da60f26543c..8755dfd1c74b8f2dc5274e50698b51d89dfff11b 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 @@
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::Close() {
+ command_buffer_.reset();
DCHECK(platform_viewport_);
platform_viewport_->Close();
}
@@ -59,14 +60,25 @@
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 @@
}
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
« no previous file with comments | « mojo/services/native_viewport/native_viewport_impl.h ('k') | mojo/services/public/interfaces/gpu/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698