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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 LayerTitleCache* layer_title_cache, | 81 LayerTitleCache* layer_title_cache, |
82 TabContentManager* tab_content_manager) | 82 TabContentManager* tab_content_manager) |
83 : layer_title_cache_(layer_title_cache), | 83 : layer_title_cache_(layer_title_cache), |
84 tab_content_manager_(tab_content_manager), | 84 tab_content_manager_(tab_content_manager), |
85 root_layer_( | 85 root_layer_( |
86 cc::SolidColorLayer::Create(content::Compositor::LayerSettings())), | 86 cc::SolidColorLayer::Create(content::Compositor::LayerSettings())), |
87 scene_layer_(nullptr), | 87 scene_layer_(nullptr), |
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 overdraw_bottom_height_(0), | |
92 overlay_video_mode_(false), | 91 overlay_video_mode_(false), |
93 empty_background_color_(empty_background_color), | 92 empty_background_color_(empty_background_color), |
94 weak_factory_(this) { | 93 weak_factory_(this) { |
95 content::BrowserChildProcessObserver::Add(this); | 94 content::BrowserChildProcessObserver::Add(this); |
96 obj_.Reset(env, obj); | 95 obj_.Reset(env, obj); |
97 compositor_.reset(content::Compositor::Create(this, window_android)); | 96 compositor_.reset(content::Compositor::Create(this, window_android)); |
98 | 97 |
99 toolbar_layer_ = ToolbarLayer::Create(&(compositor_->GetResourceManager())); | 98 toolbar_layer_ = ToolbarLayer::Create(&(compositor_->GetResourceManager())); |
100 | 99 |
101 root_layer_->SetIsDrawable(true); | 100 root_layer_->SetIsDrawable(true); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 179 } |
181 | 180 |
182 void CompositorView::SetLayoutViewport(JNIEnv* env, | 181 void CompositorView::SetLayoutViewport(JNIEnv* env, |
183 const JavaParamRef<jobject>& object, | 182 const JavaParamRef<jobject>& object, |
184 jfloat x, | 183 jfloat x, |
185 jfloat y, | 184 jfloat y, |
186 jfloat width, | 185 jfloat width, |
187 jfloat height, | 186 jfloat height, |
188 jfloat visible_x_offset, | 187 jfloat visible_x_offset, |
189 jfloat visible_y_offset, | 188 jfloat visible_y_offset, |
190 jfloat overdraw_bottom_height, | |
191 jfloat dp_to_pixel) { | 189 jfloat dp_to_pixel) { |
192 overdraw_bottom_height_ = overdraw_bottom_height; | |
193 compositor_->setDeviceScaleFactor(dp_to_pixel); | 190 compositor_->setDeviceScaleFactor(dp_to_pixel); |
194 root_layer_->SetBounds(gfx::Size(content_width_, content_height_)); | 191 root_layer_->SetBounds(gfx::Size(content_width_, content_height_)); |
195 } | 192 } |
196 | 193 |
197 void CompositorView::SetBackground(bool visible, SkColor color) { | 194 void CompositorView::SetBackground(bool visible, SkColor color) { |
198 if (overlay_video_mode_) | 195 if (overlay_video_mode_) |
199 visible = false; | 196 visible = false; |
200 root_layer_->SetBackgroundColor(color); | 197 root_layer_->SetBackgroundColor(color); |
201 root_layer_->SetIsDrawable(visible); | 198 root_layer_->SetIsDrawable(visible); |
202 } | 199 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } else { | 235 } else { |
239 #ifndef NDEBUG | 236 #ifndef NDEBUG |
240 // This should not happen. Setting red background just for debugging. | 237 // This should not happen. Setting red background just for debugging. |
241 SetBackground(true, SK_ColorRED); | 238 SetBackground(true, SK_ColorRED); |
242 #else | 239 #else |
243 SetBackground(true, SK_ColorBLACK); | 240 SetBackground(true, SK_ColorBLACK); |
244 #endif | 241 #endif |
245 } | 242 } |
246 } | 243 } |
247 | 244 |
248 int CompositorView::GetUsableContentHeight() { | |
249 return std::max(content_height_ - overdraw_bottom_height_, 0); | |
250 } | |
251 | |
252 void CompositorView::UpdateToolbarLayer(JNIEnv* env, | 245 void CompositorView::UpdateToolbarLayer(JNIEnv* env, |
253 const JavaParamRef<jobject>& object, | 246 const JavaParamRef<jobject>& object, |
254 jint toolbar_resource_id, | 247 jint toolbar_resource_id, |
255 jint toolbar_background_color, | 248 jint toolbar_background_color, |
256 jint url_bar_resource_id, | 249 jint url_bar_resource_id, |
257 jfloat url_bar_alpha, | 250 jfloat url_bar_alpha, |
258 jfloat top_offset, | 251 jfloat top_offset, |
259 jfloat brightness, | 252 jfloat brightness, |
260 bool visible, | 253 bool visible, |
261 bool show_shadow) { | 254 bool show_shadow) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 // through here but through BrowserChildProcessHostDisconnected() instead. | 318 // through here but through BrowserChildProcessHostDisconnected() instead. |
326 } | 319 } |
327 | 320 |
328 // Register native methods | 321 // Register native methods |
329 bool RegisterCompositorView(JNIEnv* env) { | 322 bool RegisterCompositorView(JNIEnv* env) { |
330 return RegisterNativesImpl(env); | 323 return RegisterNativesImpl(env); |
331 } | 324 } |
332 | 325 |
333 } // namespace android | 326 } // namespace android |
334 } // namespace chrome | 327 } // namespace chrome |
OLD | NEW |