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

Side by Side Diff: chrome/browser/android/compositor/compositor_view.cc

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

Powered by Google App Engine
This is Rietveld 408576698