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

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 26753005: Adding compositor callbacks to RenderWidgetHostViewAndroid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Plumb compositor provider through instead of compositor Created 7 years, 1 month 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "content/browser/android/content_view_core_impl.h" 5 #include "content/browser/android/content_view_core_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.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"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 return ContentViewCoreImpl::FromWebContents(web_contents); 148 return ContentViewCoreImpl::FromWebContents(web_contents);
149 } 149 }
150 150
151 // static 151 // static
152 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env, 152 ContentViewCore* ContentViewCore::GetNativeContentViewCore(JNIEnv* env,
153 jobject obj) { 153 jobject obj) {
154 return reinterpret_cast<ContentViewCore*>( 154 return reinterpret_cast<ContentViewCore*>(
155 Java_ContentViewCore_getNativeContentViewCore(env, obj)); 155 Java_ContentViewCore_getNativeContentViewCore(env, obj));
156 } 156 }
157 157
158 ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, 158 ContentViewCoreImpl::ContentViewCoreImpl(
159 bool hardware_accelerated, 159 JNIEnv* env,
160 WebContents* web_contents, 160 jobject obj,
161 ui::ViewAndroid* view_android, 161 bool hardware_accelerated,
162 ui::WindowAndroid* window_android) 162 WebContents* web_contents,
163 ui::ViewAndroid* view_android,
164 ui::WindowAndroid* window_android,
165 CompositorProvider* compositor_provider)
163 : WebContentsObserver(web_contents), 166 : WebContentsObserver(web_contents),
164 java_ref_(env, obj), 167 java_ref_(env, obj),
165 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 168 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
166 root_layer_(cc::Layer::Create()), 169 root_layer_(cc::Layer::Create()),
167 vsync_interval_(base::TimeDelta::FromMicroseconds( 170 vsync_interval_(base::TimeDelta::FromMicroseconds(
168 kDefaultVSyncIntervalMicros)), 171 kDefaultVSyncIntervalMicros)),
169 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( 172 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds(
170 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), 173 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)),
171 view_android_(view_android), 174 view_android_(view_android),
172 window_android_(window_android), 175 window_android_(window_android),
173 device_orientation_(0) { 176 device_orientation_(0),
177 compositor_provider_(compositor_provider) {
174 CHECK(web_contents) << 178 CHECK(web_contents) <<
175 "A ContentViewCoreImpl should be created with a valid WebContents."; 179 "A ContentViewCoreImpl should be created with a valid WebContents.";
176 180
177 // TODO(leandrogracia): make use of the hardware_accelerated argument. 181 // TODO(leandrogracia): make use of the hardware_accelerated argument.
178 182
179 const gfx::Display& display = 183 const gfx::Display& display =
180 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); 184 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
181 dpi_scale_ = display.device_scale_factor(); 185 dpi_scale_ = display.device_scale_factor();
182 186
183 // Currently, the only use case we have for overriding a user agent involves 187 // Currently, the only use case we have for overriding a user agent involves
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 Source<WebContents>(web_contents_)); 223 Source<WebContents>(web_contents_));
220 notification_registrar_.Add( 224 notification_registrar_.Add(
221 this, NOTIFICATION_RENDERER_PROCESS_CREATED, 225 this, NOTIFICATION_RENDERER_PROCESS_CREATED,
222 content::NotificationService::AllBrowserContextsAndSources()); 226 content::NotificationService::AllBrowserContextsAndSources());
223 notification_registrar_.Add( 227 notification_registrar_.Add(
224 this, NOTIFICATION_WEB_CONTENTS_CONNECTED, 228 this, NOTIFICATION_WEB_CONTENTS_CONNECTED,
225 Source<WebContents>(web_contents_)); 229 Source<WebContents>(web_contents_));
226 230
227 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())-> 231 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())->
228 SetContentViewCore(this); 232 SetContentViewCore(this);
233
234 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())->
235 SetCompositorProvider(compositor_provider_);
236
229 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); 237 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey));
230 web_contents_->SetUserData(kContentViewUserDataKey, 238 web_contents_->SetUserData(kContentViewUserDataKey,
231 new ContentViewUserData(this)); 239 new ContentViewUserData(this));
232 } 240 }
233 241
234 void ContentViewCoreImpl::Observe(int type, 242 void ContentViewCoreImpl::Observe(int type,
235 const NotificationSource& source, 243 const NotificationSource& source,
236 const NotificationDetails& details) { 244 const NotificationDetails& details) {
237 switch (type) { 245 switch (type) {
238 case NOTIFICATION_RENDER_VIEW_HOST_CHANGED: { 246 case NOTIFICATION_RENDER_VIEW_HOST_CHANGED: {
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( 1634 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
1627 web_contents_->GetRenderViewHost()); 1635 web_contents_->GetRenderViewHost());
1628 rvhi->SendOrientationChangeEvent(device_orientation_); 1636 rvhi->SendOrientationChangeEvent(device_orientation_);
1629 } 1637 }
1630 1638
1631 // This is called for each ContentView. 1639 // This is called for each ContentView.
1632 jint Init(JNIEnv* env, jobject obj, 1640 jint Init(JNIEnv* env, jobject obj,
1633 jboolean hardware_accelerated, 1641 jboolean hardware_accelerated,
1634 jint native_web_contents, 1642 jint native_web_contents,
1635 jint view_android, 1643 jint view_android,
1636 jint window_android) { 1644 jint window_android,
1645 jint compositor_provider) {
1637 ContentViewCoreImpl* view = new ContentViewCoreImpl( 1646 ContentViewCoreImpl* view = new ContentViewCoreImpl(
1638 env, obj, hardware_accelerated, 1647 env, obj, hardware_accelerated,
1639 reinterpret_cast<WebContents*>(native_web_contents), 1648 reinterpret_cast<WebContents*>(native_web_contents),
1640 reinterpret_cast<ui::ViewAndroid*>(view_android), 1649 reinterpret_cast<ui::ViewAndroid*>(view_android),
1641 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1650 reinterpret_cast<ui::WindowAndroid*>(window_android),
1651 reinterpret_cast<CompositorProvider*>(compositor_provider));
1642 return reinterpret_cast<jint>(view); 1652 return reinterpret_cast<jint>(view);
1643 } 1653 }
1644 1654
1645 bool RegisterContentViewCore(JNIEnv* env) { 1655 bool RegisterContentViewCore(JNIEnv* env) {
1646 return RegisterNativesImpl(env); 1656 return RegisterNativesImpl(env);
1647 } 1657 }
1648 1658
1649 } // namespace content 1659 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698