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

Unified Diff: mojo/examples/sample_app/gles2_client_impl.cc

Issue 131153007: Send size to NativeViewportClient::OnCreated instead of GLES2Client::DidCreateContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix TODO Created 6 years, 11 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
Index: mojo/examples/sample_app/gles2_client_impl.cc
diff --git a/mojo/examples/sample_app/gles2_client_impl.cc b/mojo/examples/sample_app/gles2_client_impl.cc
index b3f2003aac81498c26044a27cf04d86541b4173a..2d5283bf0c1d2520051a84bb92ed65658592187c 100644
--- a/mojo/examples/sample_app/gles2_client_impl.cc
+++ b/mojo/examples/sample_app/gles2_client_impl.cc
@@ -22,7 +22,8 @@ float CalculateDragDistance(const gfx::PointF& start, const Point& end) {
}
GLES2ClientImpl::GLES2ClientImpl(ScopedMessagePipeHandle pipe)
- : getting_animation_frames_(false) {
+ : getting_animation_frames_(false),
+ context_created_(false) {
context_ = MojoGLES2CreateContext(
pipe.release().value(),
&DidCreateContextThunk,
@@ -35,6 +36,11 @@ GLES2ClientImpl::~GLES2ClientImpl() {
MojoGLES2DestroyContext(context_);
}
+void GLES2ClientImpl::SetSize(gfx::Size size) {
+ size_ = size;
+ MaybeInitializeCube();
+}
+
void GLES2ClientImpl::HandleInputEvent(const Event& event) {
switch (event.action()) {
case ui::ET_MOUSE_PRESSED:
@@ -75,19 +81,21 @@ void GLES2ClientImpl::HandleInputEvent(const Event& event) {
}
}
-void GLES2ClientImpl::DidCreateContext(uint32_t width,
- uint32_t height) {
+void GLES2ClientImpl::DidCreateContext() {
MojoGLES2MakeCurrent(context_);
+ context_created_ = true;
+ MaybeInitializeCube();
+}
- cube_.Init(width, height);
+void GLES2ClientImpl::MaybeInitializeCube() {
+ if (size_.IsEmpty() || !context_created_)
+ return;
+ cube_.Init(size_.width(), size_.height());
RequestAnimationFrames();
}
-void GLES2ClientImpl::DidCreateContextThunk(
- void* closure,
- uint32_t width,
- uint32_t height) {
- static_cast<GLES2ClientImpl*>(closure)->DidCreateContext(width, height);
+void GLES2ClientImpl::DidCreateContextThunk(void* closure) {
+ static_cast<GLES2ClientImpl*>(closure)->DidCreateContext();
}
void GLES2ClientImpl::ContextLost() {

Powered by Google App Engine
This is Rietveld 408576698