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

Side by Side Diff: chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.cc

Issue 1988023010: Toolbar is a root layer for the UI compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comments Created 4 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 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/scene_layer/static_tab_scene_layer.h " 5 #include "chrome/browser/android/compositor/scene_layer/static_tab_scene_layer.h "
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "chrome/browser/android/compositor/layer/content_layer.h" 8 #include "chrome/browser/android/compositor/layer/content_layer.h"
9 #include "chrome/browser/android/compositor/layer/toolbar_layer.h"
10 #include "chrome/browser/android/compositor/layer_title_cache.h" 9 #include "chrome/browser/android/compositor/layer_title_cache.h"
11 #include "chrome/browser/android/compositor/tab_content_manager.h" 10 #include "chrome/browser/android/compositor/tab_content_manager.h"
12 #include "content/public/browser/android/compositor.h" 11 #include "content/public/browser/android/compositor.h"
13 #include "jni/StaticTabSceneLayer_jni.h" 12 #include "jni/StaticTabSceneLayer_jni.h"
14 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/android/resources/resource_manager_impl.h" 14 #include "ui/android/resources/resource_manager_impl.h"
16 15
17 namespace chrome { 16 namespace chrome {
18 namespace android { 17 namespace android {
19 18
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // than 1. 115 // than 1.
117 if (brightness != brightness_) { 116 if (brightness != brightness_) {
118 brightness_ = brightness; 117 brightness_ = brightness;
119 cc::FilterOperations filters; 118 cc::FilterOperations filters;
120 if (brightness_ < 1.f) 119 if (brightness_ < 1.f)
121 filters.Append(cc::FilterOperation::CreateBrightnessFilter(brightness_)); 120 filters.Append(cc::FilterOperation::CreateBrightnessFilter(brightness_));
122 layer_->SetFilters(filters); 121 layer_->SetFilters(filters);
123 } 122 }
124 } 123 }
125 124
126 void StaticTabSceneLayer::UpdateToolbarLayer(
127 JNIEnv* env,
128 const JavaParamRef<jobject>& object,
129 const JavaParamRef<jobject>& jresource_manager,
130 jint toolbar_resource_id,
131 jint toolbar_background_color,
132 jint url_bar_resource_id,
133 jfloat url_bar_alpha,
134 jfloat top_offset,
135 bool visible,
136 bool show_shadow) {
137 // If the toolbar layer has not been created yet, create it.
138 if (!toolbar_layer_) {
139 ui::ResourceManager* resource_manager =
140 ui::ResourceManagerImpl::FromJavaObject(jresource_manager);
141 toolbar_layer_ = ToolbarLayer::Create(resource_manager);
142 toolbar_layer_->layer()->SetHideLayerAndSubtree(true);
143 layer_->AddChild(toolbar_layer_->layer());
144 }
145
146 toolbar_layer_->layer()->SetHideLayerAndSubtree(!visible);
147 if (visible) {
148 toolbar_layer_->layer()->SetPosition(gfx::PointF(0, top_offset));
149 // If we're at rest, hide the shadow. The Android view should be drawing.
150 bool clip_shadow = top_offset >= 0.f && !show_shadow;
151 toolbar_layer_->PushResource(toolbar_resource_id, toolbar_background_color,
152 false, SK_ColorWHITE, url_bar_resource_id,
153 url_bar_alpha, false, clip_shadow);
154 }
155 }
156
157 void StaticTabSceneLayer::UpdateProgressBar(JNIEnv* env,
158 const JavaParamRef<jobject>& object,
159 jint progress_bar_x,
160 jint progress_bar_y,
161 jint progress_bar_width,
162 jint progress_bar_height,
163 jint progress_bar_color,
164 jint progress_bar_background_x,
165 jint progress_bar_background_y,
166 jint progress_bar_background_width,
167 jint progress_bar_background_height,
168 jint progress_bar_background_color) {
169 if (!toolbar_layer_) return;
170 toolbar_layer_->UpdateProgressBar(progress_bar_x,
171 progress_bar_y,
172 progress_bar_width,
173 progress_bar_height,
174 progress_bar_color,
175 progress_bar_background_x,
176 progress_bar_background_y,
177 progress_bar_background_width,
178 progress_bar_background_height,
179 progress_bar_background_color);
180 }
181
182 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { 125 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) {
183 // This will automatically bind to the Java object and pass ownership there. 126 // This will automatically bind to the Java object and pass ownership there.
184 StaticTabSceneLayer* scene_layer = new StaticTabSceneLayer(env, jobj); 127 StaticTabSceneLayer* scene_layer = new StaticTabSceneLayer(env, jobj);
185 return reinterpret_cast<intptr_t>(scene_layer); 128 return reinterpret_cast<intptr_t>(scene_layer);
186 } 129 }
187 130
188 bool RegisterStaticTabSceneLayer(JNIEnv* env) { 131 bool RegisterStaticTabSceneLayer(JNIEnv* env) {
189 return RegisterNativesImpl(env); 132 return RegisterNativesImpl(env);
190 } 133 }
191 134
192 } // namespace android 135 } // namespace android
193 } // namespace chrome 136 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698