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

Side by Side Diff: chrome/browser/android/compositor/compositor_view.cc

Issue 2595263002: Introduce ViewRoot forwarding input/view events to native (Closed)
Patch Set: unittest Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser/android/compositor/compositor_view.h" 5 #include "chrome/browser/android/compositor/compositor_view.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 26 matching lines...) Expand all
37 #include "ui/android/window_android.h" 37 #include "ui/android/window_android.h"
38 #include "ui/gfx/android/java_bitmap.h" 38 #include "ui/gfx/android/java_bitmap.h"
39 39
40 using base::android::JavaParamRef; 40 using base::android::JavaParamRef;
41 41
42 namespace android { 42 namespace android {
43 43
44 jlong Init(JNIEnv* env, 44 jlong Init(JNIEnv* env,
45 const JavaParamRef<jobject>& obj, 45 const JavaParamRef<jobject>& obj,
46 jboolean low_mem_device, 46 jboolean low_mem_device,
47 jlong native_window_android, 47 jlong native_view_root,
48 const JavaParamRef<jobject>& jlayer_title_cache, 48 const JavaParamRef<jobject>& jlayer_title_cache,
49 const JavaParamRef<jobject>& jtab_content_manager) { 49 const JavaParamRef<jobject>& jtab_content_manager) {
50 CompositorView* view; 50 CompositorView* view;
51 ui::WindowAndroid* window_android = 51 ui::ViewRoot* view_root =
52 reinterpret_cast<ui::WindowAndroid*>(native_window_android); 52 reinterpret_cast<ui::ViewRoot*>(native_view_root);
53 LayerTitleCache* layer_title_cache = 53 LayerTitleCache* layer_title_cache =
54 LayerTitleCache::FromJavaObject(jlayer_title_cache); 54 LayerTitleCache::FromJavaObject(jlayer_title_cache);
55 TabContentManager* tab_content_manager = 55 TabContentManager* tab_content_manager =
56 TabContentManager::FromJavaObject(jtab_content_manager); 56 TabContentManager::FromJavaObject(jtab_content_manager);
57 57
58 DCHECK(tab_content_manager); 58 DCHECK(tab_content_manager);
59 59
60 // TODO(clholgat): Remove the compositor tabstrip flag. 60 // TODO(clholgat): Remove the compositor tabstrip flag.
61 view = new CompositorView(env, obj, low_mem_device, window_android, 61 view = new CompositorView(env, obj, low_mem_device, view_root,
62 tab_content_manager); 62 tab_content_manager);
63 63
64 ui::UIResourceProvider* ui_resource_provider = view->GetUIResourceProvider(); 64 ui::UIResourceProvider* ui_resource_provider = view->GetUIResourceProvider();
65 // TODO(dtrainor): Pass the ResourceManager on the Java side to the tree 65 // TODO(dtrainor): Pass the ResourceManager on the Java side to the tree
66 // builders instead. 66 // builders instead.
67 if (layer_title_cache) 67 if (layer_title_cache)
68 layer_title_cache->SetResourceManager(view->GetResourceManager()); 68 layer_title_cache->SetResourceManager(view->GetResourceManager());
69 if (tab_content_manager) 69 if (tab_content_manager)
70 tab_content_manager->SetUIResourceProvider(ui_resource_provider); 70 tab_content_manager->SetUIResourceProvider(ui_resource_provider);
71 71
72 return reinterpret_cast<intptr_t>(view); 72 return reinterpret_cast<intptr_t>(view);
73 } 73 }
74 74
75 CompositorView::CompositorView(JNIEnv* env, 75 CompositorView::CompositorView(JNIEnv* env,
76 jobject obj, 76 jobject obj,
77 jboolean low_mem_device, 77 jboolean low_mem_device,
78 ui::WindowAndroid* window_android, 78 ui::ViewRoot* view_root,
79 TabContentManager* tab_content_manager) 79 TabContentManager* tab_content_manager)
80 : tab_content_manager_(tab_content_manager), 80 : tab_content_manager_(tab_content_manager),
81 root_layer_(cc::SolidColorLayer::Create()), 81 root_layer_(cc::SolidColorLayer::Create()),
82 scene_layer_(nullptr), 82 scene_layer_(nullptr),
83 current_surface_format_(0), 83 current_surface_format_(0),
84 content_width_(0), 84 content_width_(0),
85 content_height_(0), 85 content_height_(0),
86 overlay_video_mode_(false), 86 overlay_video_mode_(false),
87 weak_factory_(this) { 87 weak_factory_(this) {
88 content::BrowserChildProcessObserver::Add(this); 88 content::BrowserChildProcessObserver::Add(this);
89 obj_.Reset(env, obj); 89 obj_.Reset(env, obj);
90 compositor_.reset(content::Compositor::Create(this, window_android)); 90 compositor_.reset(content::Compositor::Create(this, view_root));
91 91
92 root_layer_->SetIsDrawable(true); 92 root_layer_->SetIsDrawable(true);
93 root_layer_->SetBackgroundColor(SK_ColorWHITE); 93 root_layer_->SetBackgroundColor(SK_ColorWHITE);
94 } 94 }
95 95
96 CompositorView::~CompositorView() { 96 CompositorView::~CompositorView() {
97 content::BrowserChildProcessObserver::Remove(this); 97 content::BrowserChildProcessObserver::Remove(this);
98 tab_content_manager_->OnUIResourcesWereEvicted(); 98 tab_content_manager_->OnUIResourcesWereEvicted();
99 99
100 // Explicitly reset these scoped_ptrs here because otherwise we callbacks will 100 // Explicitly reset these scoped_ptrs here because otherwise we callbacks will
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 // The Android TERMINATION_STATUS_OOM_PROTECTED hack causes us to never go 253 // The Android TERMINATION_STATUS_OOM_PROTECTED hack causes us to never go
254 // through here but through BrowserChildProcessHostDisconnected() instead. 254 // through here but through BrowserChildProcessHostDisconnected() instead.
255 } 255 }
256 256
257 // Register native methods 257 // Register native methods
258 bool RegisterCompositorView(JNIEnv* env) { 258 bool RegisterCompositorView(JNIEnv* env) {
259 return RegisterNativesImpl(env); 259 return RegisterNativesImpl(env);
260 } 260 }
261 261
262 } // namespace android 262 } // namespace android
OLDNEW
« no previous file with comments | « chrome/browser/android/compositor/compositor_view.h ('k') | chrome/browser/android/vr_shell/vr_compositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698