diff options
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/android/window_android.cc | 11 | ||||
-rw-r--r-- | ui/base/android/window_android.h | 6 | ||||
-rw-r--r-- | ui/base/android/window_android_compositor.h | 26 |
3 files changed, 40 insertions, 3 deletions
diff --git a/ui/base/android/window_android.cc b/ui/base/android/window_android.cc index bacf023..916e821 100644 --- a/ui/base/android/window_android.cc +++ b/ui/base/android/window_android.cc @@ -9,6 +9,7 @@ #include "base/android/jni_helper.h" #include "base/android/scoped_java_ref.h" #include "jni/WindowAndroid_jni.h" +#include "ui/base/android/window_android_compositor.h" #include "ui/base/android/window_android_observer.h" namespace ui { @@ -17,7 +18,8 @@ using base::android::AttachCurrentThread; using base::android::ScopedJavaLocalRef; WindowAndroid::WindowAndroid(JNIEnv* env, jobject obj) - : weak_java_window_(env, obj) { + : weak_java_window_(env, obj), + compositor_(NULL) { } void WindowAndroid::Destroy(JNIEnv* env, jobject obj) { @@ -66,13 +68,18 @@ void WindowAndroid::RemoveObserver(WindowAndroidObserver* observer) { observer_list_.RemoveObserver(observer); } -void WindowAndroid::AttachCompositor() { +void WindowAndroid::AttachCompositor(WindowAndroidCompositor* compositor) { + if (compositor_ && compositor != compositor_) + DetachCompositor(); + + compositor_ = compositor; FOR_EACH_OBSERVER(WindowAndroidObserver, observer_list_, OnAttachCompositor()); } void WindowAndroid::DetachCompositor() { + compositor_ = NULL; FOR_EACH_OBSERVER(WindowAndroidObserver, observer_list_, OnDetachCompositor()); diff --git a/ui/base/android/window_android.h b/ui/base/android/window_android.h index 5e6532e..2563679 100644 --- a/ui/base/android/window_android.h +++ b/ui/base/android/window_android.h @@ -15,6 +15,7 @@ namespace ui { +class WindowAndroidCompositor; class WindowAndroidObserver; // Android implementation of the activity window. @@ -40,17 +41,20 @@ class UI_BASE_EXPORT WindowAndroid { // Compositor callback relay. void OnCompositingDidCommit(); - void AttachCompositor(); + void AttachCompositor(WindowAndroidCompositor* compositor); void DetachCompositor(); void AddObserver(WindowAndroidObserver* observer); void RemoveObserver(WindowAndroidObserver* observer); + WindowAndroidCompositor* GetCompositor() { return compositor_; } + private: ~WindowAndroid(); JavaObjectWeakGlobalRef weak_java_window_; gfx::Vector2dF content_offset_; + WindowAndroidCompositor* compositor_; ObserverList<WindowAndroidObserver> observer_list_; diff --git a/ui/base/android/window_android_compositor.h b/ui/base/android/window_android_compositor.h new file mode 100644 index 0000000..8f219fa --- /dev/null +++ b/ui/base/android/window_android_compositor.h @@ -0,0 +1,26 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_BASE_ANDROID_WINDOW_ANDROID_COMPOSITOR_H_ +#define UI_BASE_ANDROID_WINDOW_ANDROID_COMPOSITOR_H_ + +#include "ui/base/ui_base_export.h" + +namespace cc { +class Layer; +} + +namespace ui { + +// Android interface for compositor-related tasks. +class UI_BASE_EXPORT WindowAndroidCompositor { + public: + virtual ~WindowAndroidCompositor() {} + + virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) = 0; +}; + +} // namespace ui + +#endif // UI_BASE_ANDROID_WINDOW_ANDROID_COMPOSITOR_H_ |