| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/android/testshell/tab_manager.h" | 5 #include "chrome/android/testshell/tab_manager.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "chrome/browser/android/tab_base_android_impl.h" | 14 #include "chrome/browser/android/tab_base_android_impl.h" |
| 15 #include "content/public/browser/android/compositor.h" | 15 #include "content/public/browser/android/compositor.h" |
| 16 #include "content/public/browser/android/draw_delegate.h" | 16 #include "content/public/browser/android/draw_delegate.h" |
| 17 #include "jni/TabManager_jni.h" | 17 #include "jni/TabManager_jni.h" |
| 18 #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" |
| 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorSuppor
t.h" |
| 18 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" | 20 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" |
| 19 | 21 |
| 20 #include <android/native_window_jni.h> | 22 #include <android/native_window_jni.h> |
| 21 | 23 |
| 22 using base::android::ScopedJavaLocalRef; | 24 using base::android::ScopedJavaLocalRef; |
| 23 | 25 |
| 24 namespace { | 26 namespace { |
| 25 | 27 |
| 26 class CompositorClient : public content::Compositor::Client { | 28 class CompositorClient : public content::Compositor::Client { |
| 27 public: | 29 public: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 bool RegisterTabManager(JNIEnv* env) { | 67 bool RegisterTabManager(JNIEnv* env) { |
| 66 return RegisterNativesImpl(env); | 68 return RegisterNativesImpl(env); |
| 67 } | 69 } |
| 68 | 70 |
| 69 static void Init(JNIEnv* env, jclass clazz, jobject obj) { | 71 static void Init(JNIEnv* env, jclass clazz, jobject obj) { |
| 70 if (!GetCompositor()) { | 72 if (!GetCompositor()) { |
| 71 content::Compositor::Initialize(); | 73 content::Compositor::Initialize(); |
| 72 g_global_state.Get().compositor.reset(content::Compositor::Create( | 74 g_global_state.Get().compositor.reset(content::Compositor::Create( |
| 73 &g_global_state.Get().client)); | 75 &g_global_state.Get().client)); |
| 74 DCHECK(!g_global_state.Get().root_layer.get()); | 76 DCHECK(!g_global_state.Get().root_layer.get()); |
| 75 g_global_state.Get().root_layer.reset(WebKit::WebLayer::create()); | 77 g_global_state.Get().root_layer.reset( |
| 78 WebKit::Platform::current()->compositorSupport()->createLayer()); |
| 76 } | 79 } |
| 77 } | 80 } |
| 78 | 81 |
| 79 static void SurfaceCreated(JNIEnv* env, jclass clazz, jobject jsurface) { | 82 static void SurfaceCreated(JNIEnv* env, jclass clazz, jobject jsurface) { |
| 80 ANativeWindow* native_window = ANativeWindow_fromSurface(env, jsurface); | 83 ANativeWindow* native_window = ANativeWindow_fromSurface(env, jsurface); |
| 81 if (native_window) { | 84 if (native_window) { |
| 82 GetCompositor()->SetWindowSurface(native_window); | 85 GetCompositor()->SetWindowSurface(native_window); |
| 83 ANativeWindow_release(native_window); | 86 ANativeWindow_release(native_window); |
| 84 GetCompositor()->SetRootLayer(g_global_state.Get().root_layer.get()); | 87 GetCompositor()->SetRootLayer(g_global_state.Get().root_layer.get()); |
| 85 } | 88 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 104 } | 107 } |
| 105 | 108 |
| 106 static void HideTab(JNIEnv* env, jclass clazz, jint jtab) { | 109 static void HideTab(JNIEnv* env, jclass clazz, jint jtab) { |
| 107 if (!GetCompositor()) | 110 if (!GetCompositor()) |
| 108 return; | 111 return; |
| 109 TabBaseAndroidImpl* tab = reinterpret_cast<TabBaseAndroidImpl*>(jtab); | 112 TabBaseAndroidImpl* tab = reinterpret_cast<TabBaseAndroidImpl*>(jtab); |
| 110 tab->tab_layer()->removeFromParent(); | 113 tab->tab_layer()->removeFromParent(); |
| 111 } | 114 } |
| 112 | 115 |
| 113 } // namespace chrome | 116 } // namespace chrome |
| OLD | NEW |