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

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: Separate Compositor plumbing from SetContentView Created 7 years, 2 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 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 java_ref_(env, obj), 163 java_ref_(env, obj),
164 web_contents_(static_cast<WebContentsImpl*>(web_contents)), 164 web_contents_(static_cast<WebContentsImpl*>(web_contents)),
165 root_layer_(cc::Layer::Create()), 165 root_layer_(cc::Layer::Create()),
166 tab_crashed_(false), 166 tab_crashed_(false),
167 vsync_interval_(base::TimeDelta::FromMicroseconds( 167 vsync_interval_(base::TimeDelta::FromMicroseconds(
168 kDefaultVSyncIntervalMicros)), 168 kDefaultVSyncIntervalMicros)),
169 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds( 169 expected_browser_composite_time_(base::TimeDelta::FromMicroseconds(
170 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)), 170 kDefaultVSyncIntervalMicros * kDefaultBrowserCompositeVSyncFraction)),
171 view_android_(view_android), 171 view_android_(view_android),
172 window_android_(window_android), 172 window_android_(window_android),
173 device_orientation_(0) { 173 device_orientation_(0),
174 compositor_(NULL) {
174 CHECK(web_contents) << 175 CHECK(web_contents) <<
175 "A ContentViewCoreImpl should be created with a valid WebContents."; 176 "A ContentViewCoreImpl should be created with a valid WebContents.";
176 177
177 // When a tab is restored (from a saved state), it does not have a renderer 178 // When a tab is restored (from a saved state), it does not have a renderer
178 // process. We treat it like the tab is crashed. If the content is loaded 179 // process. We treat it like the tab is crashed. If the content is loaded
179 // when the tab is shown, tab_crashed_ will be reset. 180 // when the tab is shown, tab_crashed_ will be reset.
180 UpdateTabCrashedFlag(); 181 UpdateTabCrashedFlag();
181 182
182 // TODO(leandrogracia): make use of the hardware_accelerated argument. 183 // TODO(leandrogracia): make use of the hardware_accelerated argument.
183 184
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 Source<WebContents>(web_contents_)); 225 Source<WebContents>(web_contents_));
225 notification_registrar_.Add( 226 notification_registrar_.Add(
226 this, NOTIFICATION_RENDERER_PROCESS_CREATED, 227 this, NOTIFICATION_RENDERER_PROCESS_CREATED,
227 content::NotificationService::AllBrowserContextsAndSources()); 228 content::NotificationService::AllBrowserContextsAndSources());
228 notification_registrar_.Add( 229 notification_registrar_.Add(
229 this, NOTIFICATION_WEB_CONTENTS_CONNECTED, 230 this, NOTIFICATION_WEB_CONTENTS_CONNECTED,
230 Source<WebContents>(web_contents_)); 231 Source<WebContents>(web_contents_));
231 232
232 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())-> 233 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())->
233 SetContentViewCore(this); 234 SetContentViewCore(this);
235
aelias_OOO_until_Jul13 2013/10/19 03:43:27 nit: unnecessary newline
powei 2013/11/08 21:34:47 Done.
234 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey)); 236 DCHECK(!web_contents_->GetUserData(kContentViewUserDataKey));
235 web_contents_->SetUserData(kContentViewUserDataKey, 237 web_contents_->SetUserData(kContentViewUserDataKey,
236 new ContentViewUserData(this)); 238 new ContentViewUserData(this));
237 } 239 }
238 240
239 void ContentViewCoreImpl::Observe(int type, 241 void ContentViewCoreImpl::Observe(int type,
240 const NotificationSource& source, 242 const NotificationSource& source,
241 const NotificationDetails& details) { 243 const NotificationDetails& details) {
242 switch (type) { 244 switch (type) {
243 case NOTIFICATION_RENDER_VIEW_HOST_CHANGED: { 245 case NOTIFICATION_RENDER_VIEW_HOST_CHANGED: {
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 void ContentViewCoreImpl::SendOrientationChangeEventInternal() { 1601 void ContentViewCoreImpl::SendOrientationChangeEventInternal() {
1600 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid(); 1602 RenderWidgetHostViewAndroid* rwhv = GetRenderWidgetHostViewAndroid();
1601 if (rwhv) 1603 if (rwhv)
1602 rwhv->UpdateScreenInfo(rwhv->GetNativeView()); 1604 rwhv->UpdateScreenInfo(rwhv->GetNativeView());
1603 1605
1604 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>( 1606 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(
1605 web_contents_->GetRenderViewHost()); 1607 web_contents_->GetRenderViewHost());
1606 rvhi->SendOrientationChangeEvent(device_orientation_); 1608 rvhi->SendOrientationChangeEvent(device_orientation_);
1607 } 1609 }
1608 1610
1611 void ContentViewCoreImpl::SetCompositor(Compositor* compositor) {
1612 compositor_ = compositor;
1613 DCHECK(web_contents_);
1614 static_cast<WebContentsViewAndroid*>(web_contents_->GetView())->
1615 SetCompositor(compositor);
1616 }
1617
1609 // This is called for each ContentView. 1618 // This is called for each ContentView.
1610 jint Init(JNIEnv* env, jobject obj, 1619 jint Init(JNIEnv* env, jobject obj,
1611 jboolean hardware_accelerated, 1620 jboolean hardware_accelerated,
1612 jint native_web_contents, 1621 jint native_web_contents,
1613 jint view_android, 1622 jint view_android,
1614 jint window_android) { 1623 jint window_android) {
1615 ContentViewCoreImpl* view = new ContentViewCoreImpl( 1624 ContentViewCoreImpl* view = new ContentViewCoreImpl(
1616 env, obj, hardware_accelerated, 1625 env, obj, hardware_accelerated,
1617 reinterpret_cast<WebContents*>(native_web_contents), 1626 reinterpret_cast<WebContents*>(native_web_contents),
1618 reinterpret_cast<ui::ViewAndroid*>(view_android), 1627 reinterpret_cast<ui::ViewAndroid*>(view_android),
1619 reinterpret_cast<ui::WindowAndroid*>(window_android)); 1628 reinterpret_cast<ui::WindowAndroid*>(window_android));
1620 return reinterpret_cast<jint>(view); 1629 return reinterpret_cast<jint>(view);
1621 } 1630 }
1622 1631
1623 bool RegisterContentViewCore(JNIEnv* env) { 1632 bool RegisterContentViewCore(JNIEnv* env) {
1624 return RegisterNativesImpl(env); 1633 return RegisterNativesImpl(env);
1625 } 1634 }
1626 1635
1627 } // namespace content 1636 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698