Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | |
| 9 #include "chrome/browser/android/compositor/layer_title_cache.h" | 10 #include "chrome/browser/android/compositor/layer_title_cache.h" |
| 10 #include "chrome/browser/android/compositor/tab_content_manager.h" | 11 #include "chrome/browser/android/compositor/tab_content_manager.h" |
| 11 #include "content/public/browser/android/compositor.h" | 12 #include "content/public/browser/android/compositor.h" |
| 12 #include "jni/StaticTabSceneLayer_jni.h" | 13 #include "jni/StaticTabSceneLayer_jni.h" |
| 13 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
| 15 #include "ui/android/resources/resource_manager_impl.h" | |
| 14 | 16 |
| 15 namespace chrome { | 17 namespace chrome { |
| 16 namespace android { | 18 namespace android { |
| 17 | 19 |
| 18 StaticTabSceneLayer::StaticTabSceneLayer(JNIEnv* env, jobject jobj) | 20 StaticTabSceneLayer::StaticTabSceneLayer(JNIEnv* env, jobject jobj) |
| 19 : SceneLayer(env, jobj), | 21 : SceneLayer(env, jobj), |
| 20 last_set_tab_id_(-1), | 22 last_set_tab_id_(-1), |
| 21 background_color_(SK_ColorWHITE), | 23 background_color_(SK_ColorWHITE), |
| 22 brightness_(1.f) { | 24 brightness_(1.f) { |
| 23 } | 25 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 } | 138 } |
| 137 | 139 |
| 138 // TODO(pedrosimonetti): Consider being smarter with regards to when to | 140 // TODO(pedrosimonetti): Consider being smarter with regards to when to |
| 139 // add the layer to the hierarchy. For now, we need to keep adding the | 141 // add the layer to the hierarchy. For now, we need to keep adding the |
| 140 // content_scene_layer on every frame because the content_layer is also | 142 // content_scene_layer on every frame because the content_layer is also |
| 141 // added on every frame. This means that if we only add it once, the | 143 // added on every frame. This means that if we only add it once, the |
| 142 // content_layer will be added again on the next frame and will | 144 // content_layer will be added again on the next frame and will |
| 143 // occlude the content_scene_layer. | 145 // occlude the content_scene_layer. |
| 144 if (layer) { | 146 if (layer) { |
| 145 content_scene_layer_ = layer; | 147 content_scene_layer_ = layer; |
| 146 layer_->AddChild(layer); | 148 layer_->AddChild(layer); |
|
David Trainor- moved to gerrit
2016/02/24 17:06:10
Can't we just insert this layer at the beginning s
mdjones
2016/02/25 21:38:01
Removed this whole function as it actually doesn't
| |
| 149 if (toolbar_layer_) layer_->AddChild(toolbar_layer_->layer()); | |
| 147 } | 150 } |
| 148 } | 151 } |
| 149 | 152 |
| 153 void StaticTabSceneLayer::UpdateToolbarLayer( | |
| 154 JNIEnv* env, | |
| 155 const JavaParamRef<jobject>& object, | |
| 156 const JavaParamRef<jobject>& jresource_manager, | |
| 157 jint toolbar_resource_id, | |
| 158 jint toolbar_background_color, | |
| 159 jint url_bar_resource_id, | |
| 160 jfloat url_bar_alpha, | |
| 161 jfloat top_offset, | |
| 162 jfloat brightness, | |
| 163 bool visible, | |
| 164 bool show_shadow) { | |
| 165 // If the toolbar layer has not been created yet, create it. | |
| 166 if (!toolbar_layer_) { | |
| 167 ui::ResourceManager* resource_manager = | |
| 168 ui::ResourceManagerImpl::FromJavaObject(jresource_manager); | |
| 169 toolbar_layer_ = ToolbarLayer::Create(resource_manager); | |
| 170 toolbar_layer_->layer()->SetHideLayerAndSubtree(true); | |
| 171 } | |
| 172 | |
| 173 layer_->AddChild(toolbar_layer_->layer()); | |
| 174 toolbar_layer_->layer()->SetHideLayerAndSubtree(!visible); | |
| 175 if (visible) { | |
| 176 toolbar_layer_->layer()->SetPosition(gfx::PointF(0, top_offset)); | |
| 177 // If we're at rest, hide the shadow. The Android view should be drawing. | |
| 178 bool clip_shadow = top_offset >= 0.f && !show_shadow; | |
| 179 toolbar_layer_->PushResource(toolbar_resource_id, toolbar_background_color, | |
| 180 false, SK_ColorWHITE, url_bar_resource_id, | |
| 181 url_bar_alpha, false, brightness, clip_shadow); | |
| 182 } | |
| 183 } | |
| 184 | |
| 185 void StaticTabSceneLayer::UpdateProgressBar(JNIEnv* env, | |
| 186 const JavaParamRef<jobject>& object, | |
| 187 jint progress_bar_x, | |
| 188 jint progress_bar_y, | |
| 189 jint progress_bar_width, | |
| 190 jint progress_bar_height, | |
| 191 jint progress_bar_color, | |
| 192 jint progress_bar_background_x, | |
| 193 jint progress_bar_background_y, | |
| 194 jint progress_bar_background_width, | |
| 195 jint progress_bar_background_height, | |
| 196 jint progress_bar_background_color) { | |
| 197 if (!toolbar_layer_) return; | |
| 198 toolbar_layer_->UpdateProgressBar(progress_bar_x, | |
| 199 progress_bar_y, | |
| 200 progress_bar_width, | |
| 201 progress_bar_height, | |
| 202 progress_bar_color, | |
| 203 progress_bar_background_x, | |
| 204 progress_bar_background_y, | |
| 205 progress_bar_background_width, | |
| 206 progress_bar_background_height, | |
| 207 progress_bar_background_color); | |
| 208 } | |
| 209 | |
| 150 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { | 210 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& jobj) { |
| 151 // This will automatically bind to the Java object and pass ownership there. | 211 // This will automatically bind to the Java object and pass ownership there. |
| 152 StaticTabSceneLayer* scene_layer = new StaticTabSceneLayer(env, jobj); | 212 StaticTabSceneLayer* scene_layer = new StaticTabSceneLayer(env, jobj); |
| 153 return reinterpret_cast<intptr_t>(scene_layer); | 213 return reinterpret_cast<intptr_t>(scene_layer); |
| 154 } | 214 } |
| 155 | 215 |
| 156 bool RegisterStaticTabSceneLayer(JNIEnv* env) { | 216 bool RegisterStaticTabSceneLayer(JNIEnv* env) { |
| 157 return RegisterNativesImpl(env); | 217 return RegisterNativesImpl(env); |
| 158 } | 218 } |
| 159 | 219 |
| 160 } // namespace android | 220 } // namespace android |
| 161 } // namespace chrome | 221 } // namespace chrome |
| OLD | NEW |