OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "android_webview/browser/browser_view_renderer.h" | 5 #include "android_webview/browser/browser_view_renderer.h" |
6 | 6 |
7 #include "android_webview/browser/browser_view_renderer_client.h" | 7 #include "android_webview/browser/browser_view_renderer_client.h" |
8 #include "android_webview/browser/shared_renderer_state.h" | 8 #include "android_webview/browser/shared_renderer_state.h" |
9 #include "android_webview/common/aw_switches.h" | 9 #include "android_webview/common/aw_switches.h" |
10 #include "android_webview/public/browser/draw_gl.h" | 10 #include "android_webview/public/browser/draw_gl.h" |
11 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
12 #include "base/auto_reset.h" | 12 #include "base/auto_reset.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/debug/trace_event.h" | 14 #include "base/debug/trace_event.h" |
15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "cc/output/compositor_frame.h" | 19 #include "cc/output/compositor_frame.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
23 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
24 #include "third_party/skia/include/core/SkCanvas.h" | 24 #include "third_party/skia/include/core/SkCanvas.h" |
25 #include "third_party/skia/include/core/SkPicture.h" | 25 #include "third_party/skia/include/core/SkPicture.h" |
26 #include "third_party/skia/include/core/SkPictureRecorder.h" | 26 #include "third_party/skia/include/core/SkPictureRecorder.h" |
27 #include "ui/gfx/vector2d_conversions.h" | 27 #include "ui/gfx/vector2d_conversions.h" |
| 28 #include "cc/quads/draw_quad.h" |
28 | 29 |
29 using base::android::AttachCurrentThread; | 30 using base::android::AttachCurrentThread; |
30 using base::android::JavaRef; | 31 using base::android::JavaRef; |
31 using base::android::ScopedJavaLocalRef; | 32 using base::android::ScopedJavaLocalRef; |
32 using content::BrowserThread; | 33 using content::BrowserThread; |
33 using content::SynchronousCompositorMemoryPolicy; | 34 using content::SynchronousCompositorMemoryPolicy; |
34 | 35 |
35 namespace android_webview { | 36 namespace android_webview { |
36 | 37 |
37 namespace { | 38 namespace { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 return memory_policy_.num_resources_limit; | 215 return memory_policy_.num_resources_limit; |
215 } | 216 } |
216 | 217 |
217 bool BrowserViewRenderer::OnDraw(jobject java_canvas, | 218 bool BrowserViewRenderer::OnDraw(jobject java_canvas, |
218 bool is_hardware_canvas, | 219 bool is_hardware_canvas, |
219 const gfx::Vector2d& scroll, | 220 const gfx::Vector2d& scroll, |
220 const gfx::Rect& global_visible_rect) { | 221 const gfx::Rect& global_visible_rect) { |
221 last_on_draw_scroll_offset_ = scroll; | 222 last_on_draw_scroll_offset_ = scroll; |
222 last_on_draw_global_visible_rect_ = global_visible_rect; | 223 last_on_draw_global_visible_rect_ = global_visible_rect; |
223 | 224 |
| 225 LOG(INFO) << "OnDraw " << clear_view_ << " " << is_hardware_canvas |
| 226 << " " << attached_to_window_; |
224 if (clear_view_) | 227 if (clear_view_) |
225 return false; | 228 return false; |
226 | 229 |
227 if (is_hardware_canvas && attached_to_window_ && | 230 if (is_hardware_canvas && attached_to_window_ && |
228 !switches::ForceAuxiliaryBitmap()) { | 231 !switches::ForceAuxiliaryBitmap()) { |
229 return OnDrawHardware(java_canvas); | 232 return OnDrawHardware(java_canvas); |
230 } | 233 } |
231 | 234 |
232 // Perform a software draw | 235 // Perform a software draw |
233 return OnDrawSoftware(java_canvas); | 236 return OnDrawSoftware(java_canvas); |
234 } | 237 } |
235 | 238 |
236 bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { | 239 bool BrowserViewRenderer::OnDrawHardware(jobject java_canvas) { |
237 if (!compositor_) | 240 if (!compositor_) |
238 return false; | 241 return false; |
239 | 242 |
240 if (!hardware_enabled_) { | 243 if (!hardware_enabled_) { |
| 244 LOG(INFO) << "InitHwDraw"; |
241 hardware_enabled_ = compositor_->InitializeHwDraw(); | 245 hardware_enabled_ = compositor_->InitializeHwDraw(); |
| 246 LOG(INFO) << "DidInitHwDraw"; |
242 if (hardware_enabled_) { | 247 if (hardware_enabled_) { |
243 tile_manager_key_ = GlobalTileManager::GetInstance()->PushBack(this); | 248 tile_manager_key_ = GlobalTileManager::GetInstance()->PushBack(this); |
244 gpu::GLInProcessContext* share_context = compositor_->GetShareContext(); | 249 gpu::GLInProcessContext* share_context = compositor_->GetShareContext(); |
245 DCHECK(share_context); | 250 DCHECK(share_context); |
246 shared_renderer_state_->SetSharedContext(share_context); | 251 shared_renderer_state_->SetSharedContext(share_context); |
247 } | 252 } |
248 } | 253 } |
249 if (!hardware_enabled_) | 254 if (!hardware_enabled_) |
250 return false; | 255 return false; |
251 | 256 |
(...skipping 13 matching lines...) Expand all Loading... |
265 // TODO(boliu): Should really be |last_on_draw_global_visible_rect_|. | 270 // TODO(boliu): Should really be |last_on_draw_global_visible_rect_|. |
266 // See crbug.com/372073. | 271 // See crbug.com/372073. |
267 gfx::Rect clip = viewport; | 272 gfx::Rect clip = viewport; |
268 scoped_ptr<cc::CompositorFrame> frame = compositor_->DemandDrawHw( | 273 scoped_ptr<cc::CompositorFrame> frame = compositor_->DemandDrawHw( |
269 surface_size, transform, viewport, clip); | 274 surface_size, transform, viewport, clip); |
270 if (!frame.get()) | 275 if (!frame.get()) |
271 return false; | 276 return false; |
272 | 277 |
273 GlobalTileManager::GetInstance()->DidUse(tile_manager_key_); | 278 GlobalTileManager::GetInstance()->DidUse(tile_manager_key_); |
274 | 279 |
| 280 for (size_t i = 0; |
| 281 i < frame->delegated_frame_data->render_pass_list.size(); |
| 282 ++i) { |
| 283 const cc::QuadList& quad_list = |
| 284 frame->delegated_frame_data->render_pass_list.at(i)->quad_list; |
| 285 for (cc::QuadList::ConstBackToFrontIterator it = |
| 286 quad_list.BackToFrontBegin(); |
| 287 it != quad_list.BackToFrontEnd(); |
| 288 ++it) { |
| 289 LOG(INFO) << "draw quad " << (*it)->material; |
| 290 } |
| 291 } |
275 frame->AssignTo(&draw_gl_input->frame); | 292 frame->AssignTo(&draw_gl_input->frame); |
276 ReturnUnusedResource(shared_renderer_state_->PassDrawGLInput()); | 293 ReturnUnusedResource(shared_renderer_state_->PassDrawGLInput()); |
277 shared_renderer_state_->SetDrawGLInput(draw_gl_input.Pass()); | 294 shared_renderer_state_->SetDrawGLInput(draw_gl_input.Pass()); |
278 DidComposite(); | 295 DidComposite(); |
| 296 LOG(INFO) << "DidComposite " << width_ << "x" << height_; |
279 return client_->RequestDrawGL(java_canvas, false); | 297 return client_->RequestDrawGL(java_canvas, false); |
280 } | 298 } |
281 | 299 |
282 void BrowserViewRenderer::ReturnUnusedResource(scoped_ptr<DrawGLInput> input) { | 300 void BrowserViewRenderer::ReturnUnusedResource(scoped_ptr<DrawGLInput> input) { |
283 if (!input.get()) | 301 if (!input.get()) |
284 return; | 302 return; |
285 | 303 |
286 cc::CompositorFrameAck frame_ack; | 304 cc::CompositorFrameAck frame_ack; |
287 cc::TransferableResource::ReturnResources( | 305 cc::TransferableResource::ReturnResources( |
288 input->frame.delegated_frame_data->resource_list, | 306 input->frame.delegated_frame_data->resource_list, |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 base::StringAppendF(&str, | 770 base::StringAppendF(&str, |
753 "surface width height: [%d %d] ", | 771 "surface width height: [%d %d] ", |
754 draw_info->width, | 772 draw_info->width, |
755 draw_info->height); | 773 draw_info->height); |
756 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 774 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
757 } | 775 } |
758 return str; | 776 return str; |
759 } | 777 } |
760 | 778 |
761 } // namespace android_webview | 779 } // namespace android_webview |
OLD | NEW |