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

Unified Diff: sky/shell/sky_view.cc

Issue 880443003: Plumb resize notifications around sky/shell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: git cl format Created 5 years, 10 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: sky/shell/sky_view.cc
diff --git a/sky/shell/sky_view.cc b/sky/shell/sky_view.cc
index c7e6d2d06c74440f6a7a6bdb4e198b627bd1163e..905d1f1204f026e72944855b7d8b758281d5dea1 100644
--- a/sky/shell/sky_view.cc
+++ b/sky/shell/sky_view.cc
@@ -8,6 +8,8 @@
#include <android/native_window_jni.h>
#include "base/android/jni_android.h"
+#include "base/bind.h"
+#include "base/location.h"
#include "jni/SkyView_jni.h"
namespace sky {
@@ -18,10 +20,10 @@ bool SkyView::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
}
-SkyView::Delegate::~Delegate() {
-}
-
-SkyView::SkyView(Delegate* delegate) : delegate_(delegate), window_(NULL) {
+SkyView::SkyView(const Config& config) : config_(config), window_(nullptr) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_SkyView_createForActivity(env, base::android::GetApplicationContext(),
+ reinterpret_cast<jlong>(this));
eseidel 2015/02/05 05:57:28 Bleh. Really? Reinterpret-casting a pointer to a
abarth-chromium 2015/02/05 06:16:23 Yeah, that's how our JNI system works. It's super
eseidel 2015/02/05 07:06:44 And we don't have any helpers to hide the crazy?
}
SkyView::~SkyView() {
@@ -29,14 +31,7 @@ SkyView::~SkyView() {
ReleaseWindow();
}
-void SkyView::Init() {
- JNIEnv* env = base::android::AttachCurrentThread();
- Java_SkyView_createForActivity(env, base::android::GetApplicationContext(),
- reinterpret_cast<jlong>(this));
-}
-
void SkyView::Destroy(JNIEnv* env, jobject obj) {
- delegate_->OnDestroyed();
}
void SkyView::SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface) {
@@ -48,11 +43,15 @@ void SkyView::SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface) {
base::android::ScopedJavaLocalFrame scoped_local_reference_frame(env);
window_ = ANativeWindow_fromSurface(env, jsurface);
}
- delegate_->OnAcceleratedWidgetAvailable(window_);
+ config_.gpu_task_runner->PostTask(
+ FROM_HERE, base::Bind(&GPUDelegate::OnAcceleratedWidgetAvailable,
+ config_.gpu_delegate, window_));
}
void SkyView::SurfaceDestroyed(JNIEnv* env, jobject obj) {
DCHECK(window_);
+ config_.gpu_task_runner->PostTask(
+ FROM_HERE, base::Bind(&GPUDelegate::OnDestroyed, config_.gpu_delegate));
ReleaseWindow();
}
@@ -61,11 +60,15 @@ void SkyView::SurfaceSetSize(JNIEnv* env,
jint width,
jint height,
jfloat density) {
+ config_.ui_task_runner->PostTask(
+ FROM_HERE,
+ base::Bind(&UIDelegate::OnViewportMetricsChanged, config_.ui_delegate,
+ gfx::Size(width, height), density));
}
void SkyView::ReleaseWindow() {
ANativeWindow_release(window_);
- window_ = NULL;
+ window_ = nullptr;
}
} // namespace shell
« sky/shell/sky_view.h ('K') | « sky/shell/sky_view.h ('k') | sky/shell/ui/engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698