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

Unified Diff: content/browser/android/content_view_core_impl.cc

Issue 264113003: Android: Make ContentViewCore's layer a SolidColorLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/content_view_core_impl.cc
diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc
index bca737d5cc773a61cbea3645b92e9857b97ed3a1..5dcbb66106436fb5239755a129bddde59d542f19 100644
--- a/content/browser/android/content_view_core_impl.cc
+++ b/content/browser/android/content_view_core_impl.cc
@@ -15,6 +15,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "cc/layers/layer.h"
+#include "cc/layers/solid_color_layer.h"
#include "cc/output/begin_frame_args.h"
#include "content/browser/android/gesture_event_type.h"
#include "content/browser/android/interstitial_page_delegate_android.h"
@@ -217,7 +218,7 @@ ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env,
: WebContentsObserver(web_contents),
java_ref_(env, obj),
web_contents_(static_cast<WebContentsImpl*>(web_contents)),
- root_layer_(cc::Layer::Create()),
+ root_layer_(cc::SolidColorLayer::Create()),
dpi_scale_(GetPrimaryDisplayDeviceScaleFactor()),
view_android_(view_android),
window_android_(window_android),
@@ -226,6 +227,13 @@ ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env,
CHECK(web_contents) <<
"A ContentViewCoreImpl should be created with a valid WebContents.";
+ root_layer_->SetBackgroundColor(GetBackgroundColor(env, obj));
+ gfx::Size physical_size(
+ Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
+ Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
+ root_layer_->SetBounds(physical_size);
+ root_layer_->SetIsDrawable(true);
+
// Currently, the only use case we have for overriding a user agent involves
// spoofing a desktop Linux user agent for "Request desktop site".
// Automatically set it for all WebContents so that it is available when a
@@ -475,6 +483,8 @@ void ContentViewCoreImpl::SetTitle(const base::string16& title) {
}
void ContentViewCoreImpl::OnBackgroundColorChanged(SkColor color) {
+ root_layer_->SetBackgroundColor(color);
+
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null())
@@ -840,10 +850,14 @@ float ContentViewCoreImpl::GetOverdrawBottomHeightDip() const {
void ContentViewCoreImpl::AttachLayer(scoped_refptr<cc::Layer> layer) {
root_layer_->AddChild(layer);
+ root_layer_->SetIsDrawable(false);
}
void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) {
layer->RemoveFromParent();
+
+ if (!root_layer_->children().size())
+ root_layer_->SetIsDrawable(true);
}
void ContentViewCoreImpl::LoadUrl(
@@ -1300,6 +1314,11 @@ void ContentViewCoreImpl::RemoveJavascriptInterface(JNIEnv* env,
void ContentViewCoreImpl::WasResized(JNIEnv* env, jobject obj) {
RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
+ gfx::Size physical_size(
+ Java_ContentViewCore_getPhysicalBackingWidthPix(env, obj),
+ Java_ContentViewCore_getPhysicalBackingHeightPix(env, obj));
+ root_layer_->SetBounds(physical_size);
+
if (view) {
RenderWidgetHostImpl* host = RenderWidgetHostImpl::From(
view->GetRenderWidgetHost());
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698