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" |
11 #include "content/browser/gpu/gpu_surface_tracker.h" | 12 #include "content/browser/gpu/gpu_surface_tracker.h" |
12 #include "content/browser/renderer_host/render_widget_host_impl.h" | 13 #include "content/browser/renderer_host/render_widget_host_impl.h" |
13 #include "content/common/android/device_info.h" | 14 #include "content/common/android/device_info.h" |
| 15 #include "content/common/gpu/gpu_messages.h" |
14 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 17 #include "content/public/browser/android/draw_delegate.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 |
24 // View system yet, so we treat it as hidden. | 27 // View system yet, so we treat it as hidden. |
(...skipping 118 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 { |
153 if (content_view_core_) { | 156 return gfx::Rect(requested_size_); |
154 return content_view_core_->GetBounds(); | |
155 } else { | |
156 // The ContentViewCore has not been created yet. This only happens when | |
157 // renderer asks for creating new window, for example, | |
158 // javascript window.open(). | |
159 return gfx::Rect(0, 0, 0, 0); | |
160 } | |
161 } | 157 } |
162 | 158 |
163 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { | 159 void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) { |
164 // There are no cursors on Android. | 160 // There are no cursors on Android. |
165 } | 161 } |
166 | 162 |
167 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { | 163 void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { |
168 // Do nothing. The UI notification is handled through ContentViewClient which | 164 // Do nothing. The UI notification is handled through ContentViewClient which |
169 // is TabContentsDelegate. | 165 // is TabContentsDelegate. |
170 } | 166 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { | 246 void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { |
251 const bool activated = host_->is_accelerated_compositing_active(); | 247 const bool activated = host_->is_accelerated_compositing_active(); |
252 if (content_view_core_) | 248 if (content_view_core_) |
253 content_view_core_->OnAcceleratedCompositingStateChange( | 249 content_view_core_->OnAcceleratedCompositingStateChange( |
254 this, activated, false); | 250 this, activated, false); |
255 } | 251 } |
256 | 252 |
257 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( | 253 void RenderWidgetHostViewAndroid::AcceleratedSurfaceBuffersSwapped( |
258 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | 254 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
259 int gpu_host_id) { | 255 int gpu_host_id) { |
260 NOTREACHED(); | 256 DrawDelegate::GetInstance()->OnSurfaceUpdated( |
| 257 params.surface_handle, |
| 258 this, |
| 259 base::Bind(&RenderWidgetHostImpl::AcknowledgeBufferPresent, |
| 260 params.route_id, gpu_host_id)); |
261 } | 261 } |
262 | 262 |
263 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( | 263 void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( |
264 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, | 264 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
265 int gpu_host_id) { | 265 int gpu_host_id) { |
266 NOTREACHED(); | 266 NOTREACHED(); |
267 } | 267 } |
268 | 268 |
269 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() { | 269 void RenderWidgetHostViewAndroid::AcceleratedSurfaceSuspend() { |
270 NOTREACHED(); | 270 NOTREACHED(); |
271 } | 271 } |
272 | 272 |
273 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( | 273 bool RenderWidgetHostViewAndroid::HasAcceleratedSurface( |
274 const gfx::Size& desired_size) { | 274 const gfx::Size& desired_size) { |
275 NOTREACHED(); | 275 NOTREACHED(); |
276 return false; | 276 return false; |
277 } | 277 } |
278 | 278 |
279 void RenderWidgetHostViewAndroid::StartContentIntent( | 279 void RenderWidgetHostViewAndroid::StartContentIntent( |
280 const GURL& content_url) { | 280 const GURL& content_url) { |
281 if (content_view_core_) | 281 if (content_view_core_) |
282 content_view_core_->StartContentIntent(content_url); | 282 content_view_core_->StartContentIntent(content_url); |
283 } | 283 } |
284 | 284 |
285 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() { | 285 gfx::GLSurfaceHandle RenderWidgetHostViewAndroid::GetCompositingSurface() { |
| 286 gfx::GLSurfaceHandle handle = DrawDelegate::GetInstance()->GetDrawSurface(); |
| 287 if (!handle.is_null()) |
| 288 return handle; |
| 289 |
286 // On Android, we cannot generate a window handle that can be passed to the | 290 // On Android, we cannot generate a window handle that can be passed to the |
287 // GPU process through the native side. Instead, we send the surface handle | 291 // GPU process through the native side. Instead, we send the surface handle |
288 // through Binder after the compositing context has been created. | 292 // through Binder after the compositing context has been created. |
289 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true); | 293 return gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true); |
290 } | 294 } |
291 | 295 |
292 void RenderWidgetHostViewAndroid::GetScreenInfo(WebKit::WebScreenInfo* result) { | 296 void RenderWidgetHostViewAndroid::GetScreenInfo(WebKit::WebScreenInfo* result) { |
293 // ScreenInfo isn't tied to the widget on Android. Always return the default. | 297 // ScreenInfo isn't tied to the widget on Android. Always return the default. |
294 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); | 298 RenderWidgetHostViewBase::GetDefaultScreenInfo(result); |
295 } | 299 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // RenderWidgetHostView, public: | 363 // RenderWidgetHostView, public: |
360 | 364 |
361 // static | 365 // static |
362 RenderWidgetHostView* | 366 RenderWidgetHostView* |
363 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 367 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
364 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 368 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
365 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 369 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
366 } | 370 } |
367 | 371 |
368 } // namespace content | 372 } // namespace content |
OLD | NEW |