| 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/compositor_view.h" | 5 #include "chrome/browser/android/compositor/compositor_view.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include <android/bitmap.h> | 9 #include <android/bitmap.h> |
| 10 #include <android/native_window_jni.h> | 10 #include <android/native_window_jni.h> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 current_surface_format_(0), | 88 current_surface_format_(0), |
| 89 content_width_(0), | 89 content_width_(0), |
| 90 content_height_(0), | 90 content_height_(0), |
| 91 overlay_video_mode_(false), | 91 overlay_video_mode_(false), |
| 92 empty_background_color_(empty_background_color), | 92 empty_background_color_(empty_background_color), |
| 93 weak_factory_(this) { | 93 weak_factory_(this) { |
| 94 content::BrowserChildProcessObserver::Add(this); | 94 content::BrowserChildProcessObserver::Add(this); |
| 95 obj_.Reset(env, obj); | 95 obj_.Reset(env, obj); |
| 96 compositor_.reset(content::Compositor::Create(this, window_android)); | 96 compositor_.reset(content::Compositor::Create(this, window_android)); |
| 97 | 97 |
| 98 toolbar_layer_ = ToolbarLayer::Create(&(compositor_->GetResourceManager())); | |
| 99 | |
| 100 root_layer_->SetIsDrawable(true); | 98 root_layer_->SetIsDrawable(true); |
| 101 root_layer_->SetBackgroundColor(SK_ColorWHITE); | 99 root_layer_->SetBackgroundColor(SK_ColorWHITE); |
| 102 | |
| 103 toolbar_layer_->layer()->SetHideLayerAndSubtree(true); | |
| 104 root_layer_->AddChild(toolbar_layer_->layer()); | |
| 105 } | 100 } |
| 106 | 101 |
| 107 CompositorView::~CompositorView() { | 102 CompositorView::~CompositorView() { |
| 108 content::BrowserChildProcessObserver::Remove(this); | 103 content::BrowserChildProcessObserver::Remove(this); |
| 109 tab_content_manager_->OnUIResourcesWereEvicted(); | 104 tab_content_manager_->OnUIResourcesWereEvicted(); |
| 110 | 105 |
| 111 // Explicitly reset these scoped_ptrs here because otherwise we callbacks will | 106 // Explicitly reset these scoped_ptrs here because otherwise we callbacks will |
| 112 // try to access member variables during destruction. | 107 // try to access member variables during destruction. |
| 113 compositor_.reset(NULL); | 108 compositor_.reset(NULL); |
| 114 } | 109 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } else { | 230 } else { |
| 236 #ifndef NDEBUG | 231 #ifndef NDEBUG |
| 237 // This should not happen. Setting red background just for debugging. | 232 // This should not happen. Setting red background just for debugging. |
| 238 SetBackground(true, SK_ColorRED); | 233 SetBackground(true, SK_ColorRED); |
| 239 #else | 234 #else |
| 240 SetBackground(true, SK_ColorBLACK); | 235 SetBackground(true, SK_ColorBLACK); |
| 241 #endif | 236 #endif |
| 242 } | 237 } |
| 243 } | 238 } |
| 244 | 239 |
| 245 void CompositorView::UpdateToolbarLayer(JNIEnv* env, | |
| 246 const JavaParamRef<jobject>& object, | |
| 247 jint toolbar_resource_id, | |
| 248 jint toolbar_background_color, | |
| 249 jint url_bar_resource_id, | |
| 250 jfloat url_bar_alpha, | |
| 251 jfloat top_offset, | |
| 252 jfloat brightness, | |
| 253 bool visible, | |
| 254 bool show_shadow) { | |
| 255 toolbar_layer_->layer()->SetHideLayerAndSubtree(!visible); | |
| 256 if (visible) { | |
| 257 toolbar_layer_->layer()->SetPosition(gfx::PointF(0, top_offset)); | |
| 258 // If we're at rest, hide the shadow. The Android view should be drawing. | |
| 259 bool clip_shadow = top_offset >= 0.f && !show_shadow; | |
| 260 toolbar_layer_->PushResource(toolbar_resource_id, toolbar_background_color, | |
| 261 false, SK_ColorWHITE, url_bar_resource_id, | |
| 262 url_bar_alpha, false, brightness, clip_shadow); | |
| 263 } | |
| 264 } | |
| 265 | |
| 266 void CompositorView::UpdateProgressBar(JNIEnv* env, | |
| 267 const JavaParamRef<jobject>& object, | |
| 268 jint progress_bar_x, | |
| 269 jint progress_bar_y, | |
| 270 jint progress_bar_width, | |
| 271 jint progress_bar_height, | |
| 272 jint progress_bar_color, | |
| 273 jint progress_bar_background_x, | |
| 274 jint progress_bar_background_y, | |
| 275 jint progress_bar_background_width, | |
| 276 jint progress_bar_background_height, | |
| 277 jint progress_bar_background_color) { | |
| 278 toolbar_layer_->UpdateProgressBar(progress_bar_x, | |
| 279 progress_bar_y, | |
| 280 progress_bar_width, | |
| 281 progress_bar_height, | |
| 282 progress_bar_color, | |
| 283 progress_bar_background_x, | |
| 284 progress_bar_background_y, | |
| 285 progress_bar_background_width, | |
| 286 progress_bar_background_height, | |
| 287 progress_bar_background_color); | |
| 288 } | |
| 289 | |
| 290 void CompositorView::FinalizeLayers(JNIEnv* env, | 240 void CompositorView::FinalizeLayers(JNIEnv* env, |
| 291 const JavaParamRef<jobject>& jobj) { | 241 const JavaParamRef<jobject>& jobj) { |
| 292 UNSHIPPED_TRACE_EVENT0("compositor", "CompositorView::FinalizeLayers"); | 242 UNSHIPPED_TRACE_EVENT0("compositor", "CompositorView::FinalizeLayers"); |
| 293 } | 243 } |
| 294 | 244 |
| 295 void CompositorView::SetNeedsComposite(JNIEnv* env, | 245 void CompositorView::SetNeedsComposite(JNIEnv* env, |
| 296 const JavaParamRef<jobject>& object) { | 246 const JavaParamRef<jobject>& object) { |
| 297 compositor_->SetNeedsComposite(); | 247 compositor_->SetNeedsComposite(); |
| 298 } | 248 } |
| 299 | 249 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 318 // through here but through BrowserChildProcessHostDisconnected() instead. | 268 // through here but through BrowserChildProcessHostDisconnected() instead. |
| 319 } | 269 } |
| 320 | 270 |
| 321 // Register native methods | 271 // Register native methods |
| 322 bool RegisterCompositorView(JNIEnv* env) { | 272 bool RegisterCompositorView(JNIEnv* env) { |
| 323 return RegisterNativesImpl(env); | 273 return RegisterNativesImpl(env); |
| 324 } | 274 } |
| 325 | 275 |
| 326 } // namespace android | 276 } // namespace android |
| 327 } // namespace chrome | 277 } // namespace chrome |
| OLD | NEW |