| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 10 #include "content/browser/android/content_view_core_impl.h" | 11 #include "content/browser/android/content_view_core_impl.h" |
| 12 #include "content/browser/android/draw_delegate_impl.h" |
| 11 #include "content/browser/gpu/gpu_surface_tracker.h" | 13 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 12 #include "content/browser/renderer_host/render_widget_host_impl.h" | 14 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 13 #include "content/common/android/device_info.h" | 15 #include "content/common/android/device_info.h" |
| 16 #include "content/common/gpu/gpu_messages.h" |
| 14 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
| 15 | 18 |
| 16 namespace content { | 19 namespace content { |
| 17 | 20 |
| 18 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( | 21 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( |
| 19 RenderWidgetHostImpl* widget_host, | 22 RenderWidgetHostImpl* widget_host, |
| 20 ContentViewCoreImpl* content_view_core) | 23 ContentViewCoreImpl* content_view_core) |
| 21 : host_(widget_host), | 24 : host_(widget_host), |
| 22 // ContentViewCoreImpl represents the native side of the Java | 25 // ContentViewCoreImpl represents the native side of the Java |
| 23 // ContentViewCore. It being NULL means that it is not attached to the | 26 // ContentViewCore. It being NULL means that it is not attached to the |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 146 |
| 144 void RenderWidgetHostViewAndroid::Hide() { | 147 void RenderWidgetHostViewAndroid::Hide() { |
| 145 // nothing to do | 148 // nothing to do |
| 146 } | 149 } |
| 147 | 150 |
| 148 bool RenderWidgetHostViewAndroid::IsShowing() { | 151 bool RenderWidgetHostViewAndroid::IsShowing() { |
| 149 return !is_hidden_; | 152 return !is_hidden_; |
| 150 } | 153 } |
| 151 | 154 |
| 152 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { | 155 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { |
| 156 gfx::Size bounds = DrawDelegateImpl::GetInstance()->GetBounds(); |
| 157 if (!bounds.IsEmpty()) |
| 158 return gfx::Rect(bounds); |
| 159 |
| 153 if (content_view_core_) { | 160 if (content_view_core_) { |
| 154 return content_view_core_->GetBounds(); | 161 return content_view_core_->GetBounds(); |
| 155 } else { | 162 } else { |
| 156 // The ContentViewCore has not been created yet. This only happens when | 163 // The ContentViewCore has not been created yet. This only happens when |
| 157 // renderer asks for creating new window, for example, | 164 // renderer asks for creating new window, for example, |
| 158 // javascript window.open(). | 165 // javascript window.open(). |
| 159 return gfx::Rect(0, 0, 0, 0); | 166 return gfx::Rect(0, 0, 0, 0); |
| 160 } | 167 } |
| 161 } | 168 } |
| 162 | 169 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { | 258 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { |
| 252 const bool activated = host_->is_accelerated_compositing_active(); | 259 const bool activated = host_->is_accelerated_compositing_active(); |
| 253 if (content_view_core_) | 260 if (content_view_core_) |
| 254 content_view_core_->OnAcceleratedCompositingStateChange( | 261 content_view_core_->OnAcceleratedCompositingStateChange( |
| 255 this, activated, false); | 262 this, activated, false); |
| 256 } | 263 } |
| 257 | 264 |
| 258 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( | 265 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( |
| 259 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 266 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 260 int gpu_host_id) { | 267 int gpu_host_id) { |
| 261 NOTREACHED(); | 268 DrawDelegateImpl::GetInstance()->OnSurfaceUpdated( |
| 269 params.surface_handle, |
| 270 this, |
| 271 base::Bind(&RenderWidgetHostImpl::AcknowledgeBufferPresent, |
| 272 params.route_id, gpu_host_id)); |
| 262 } | 273 } |
| 263 | 274 |
| 264 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( | 275 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( |
| 265 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 276 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
| 266 int gpu_host_id) { | 277 int gpu_host_id) { |
| 267 NOTREACHED(); | 278 NOTREACHED(); |
| 268 } | 279 } |
| 269 | 280 |
| 270 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() { | 281 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() { |
| 271 NOTREACHED(); | 282 NOTREACHED(); |
| 272 } | 283 } |
| 273 | 284 |
| 274 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( | 285 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( |
| 275 const gfx::Size& desired_size) { | 286 const gfx::Size& desired_size) { |
| 276 NOTREACHED(); | 287 NOTREACHED(); |
| 277 return false; | 288 return false; |
| 278 } | 289 } |
| 279 | 290 |
| 280 void RenderWidgetHostViewAndroid::StartContentIntent( | 291 void RenderWidgetHostViewAndroid::StartContentIntent( |
| 281 const GURL& content_url) { | 292 const GURL& content_url) { |
| 282 if (content_view_core_) | 293 if (content_view_core_) |
| 283 content_view_core_->StartContentIntent(content_url); | 294 content_view_core_->StartContentIntent(content_url); |
| 284 } | 295 } |
| 285 | 296 |
| 286 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() { | 297 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() { |
| 298 gfx::GLSurfaceHandle handle = |
| 299 DrawDelegateImpl::GetInstance()->GetDrawSurface(); |
| 300 if (!handle.is_null()) |
| 301 return handle; |
| 302 |
| 287 // On Android, we cannot generate a window handle that can be passed to the | 303 // On Android, we cannot generate a window handle that can be passed to the |
| 288 // GPU process through the native side. Instead, we send the surface handle | 304 // GPU process through the native side. Instead, we send the surface handle |
| 289 // through Binder after the compositing context has been created. | 305 // through Binder after the compositing context has been created. |
| 290 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true); | 306 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true); |
| 291 } | 307 } |
| 292 | 308 |
| 293 void RenderWidgetHostViewAndroid::GetScreenInfo(WebKit::WebScreenInfo* result) { | 309 void RenderWidgetHostViewAndroid::GetScreenInfo(WebKit::WebScreenInfo* result) { |
| 294 // ScreenInfo isn't tied to the widget on Android. Always return the default. | 310 // ScreenInfo isn't tied to the widget on Android. Always return the default. |
| 295 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); | 311 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); |
| 296 } | 312 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // RenderWidgetHostView, public: | 394 // RenderWidgetHostView, public: |
| 379 | 395 |
| 380 // static | 396 // static |
| 381 RenderWidgetHostView* | 397 RenderWidgetHostView* |
| 382 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 398 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
| 383 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 399 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
| 384 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 400 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
| 385 } | 401 } |
| 386 | 402 |
| 387 } // namespace content | 403 } // namespace content |
| OLD | NEW |