| 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/public/browser/draw_gl.h" | 9 #include "android_webview/public/browser/draw_gl.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 shared_renderer_state_(shared_renderer_state), | 97 shared_renderer_state_(shared_renderer_state), |
| 98 web_contents_(web_contents), | 98 web_contents_(web_contents), |
| 99 ui_task_runner_(ui_task_runner), | 99 ui_task_runner_(ui_task_runner), |
| 100 compositor_(NULL), | 100 compositor_(NULL), |
| 101 is_paused_(false), | 101 is_paused_(false), |
| 102 view_visible_(false), | 102 view_visible_(false), |
| 103 window_visible_(false), | 103 window_visible_(false), |
| 104 attached_to_window_(false), | 104 attached_to_window_(false), |
| 105 hardware_enabled_(false), | 105 hardware_enabled_(false), |
| 106 dip_scale_(0.0), | 106 dip_scale_(0.0), |
| 107 has_transparent_background_(false), | |
| 108 page_scale_factor_(1.0), | 107 page_scale_factor_(1.0), |
| 109 on_new_picture_enable_(false), | 108 on_new_picture_enable_(false), |
| 110 clear_view_(false), | 109 clear_view_(false), |
| 111 compositor_needs_continuous_invalidate_(false), | 110 compositor_needs_continuous_invalidate_(false), |
| 112 block_invalidates_(false), | 111 block_invalidates_(false), |
| 113 width_(0), | 112 width_(0), |
| 114 height_(0), | 113 height_(0), |
| 115 num_tiles_(0u), | 114 num_tiles_(0u), |
| 116 num_bytes_(0u) { | 115 num_bytes_(0u) { |
| 117 CHECK(web_contents_); | 116 CHECK(web_contents_); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 247 |
| 249 ReturnResourceFromParent(); | 248 ReturnResourceFromParent(); |
| 250 SynchronousCompositorMemoryPolicy new_policy = CalculateDesiredMemoryPolicy(); | 249 SynchronousCompositorMemoryPolicy new_policy = CalculateDesiredMemoryPolicy(); |
| 251 RequestMemoryPolicy(new_policy); | 250 RequestMemoryPolicy(new_policy); |
| 252 compositor_->SetMemoryPolicy(memory_policy_); | 251 compositor_->SetMemoryPolicy(memory_policy_); |
| 253 | 252 |
| 254 scoped_ptr<DrawGLInput> draw_gl_input(new DrawGLInput); | 253 scoped_ptr<DrawGLInput> draw_gl_input(new DrawGLInput); |
| 255 draw_gl_input->scroll_offset = last_on_draw_scroll_offset_; | 254 draw_gl_input->scroll_offset = last_on_draw_scroll_offset_; |
| 256 draw_gl_input->width = width_; | 255 draw_gl_input->width = width_; |
| 257 draw_gl_input->height = height_; | 256 draw_gl_input->height = height_; |
| 258 draw_gl_input->has_transparent_background = has_transparent_background_; | |
| 259 | 257 |
| 260 gfx::Transform transform; | 258 gfx::Transform transform; |
| 261 gfx::Size surface_size(width_, height_); | 259 gfx::Size surface_size(width_, height_); |
| 262 gfx::Rect viewport(surface_size); | 260 gfx::Rect viewport(surface_size); |
| 263 // TODO(boliu): Should really be |last_on_draw_global_visible_rect_|. | 261 // TODO(boliu): Should really be |last_on_draw_global_visible_rect_|. |
| 264 // See crbug.com/372073. | 262 // See crbug.com/372073. |
| 265 gfx::Rect clip = viewport; | 263 gfx::Rect clip = viewport; |
| 266 scoped_ptr<cc::CompositorFrame> frame = compositor_->DemandDrawHw( | 264 scoped_ptr<cc::CompositorFrame> frame = compositor_->DemandDrawHw( |
| 267 surface_size, transform, viewport, clip); | 265 surface_size, transform, viewport, clip); |
| 268 if (!frame.get()) | 266 if (!frame.get()) |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 compositor_needs_continuous_invalidate_ = invalidate; | 468 compositor_needs_continuous_invalidate_ = invalidate; |
| 471 | 469 |
| 472 EnsureContinuousInvalidation(false); | 470 EnsureContinuousInvalidation(false); |
| 473 } | 471 } |
| 474 | 472 |
| 475 void BrowserViewRenderer::SetDipScale(float dip_scale) { | 473 void BrowserViewRenderer::SetDipScale(float dip_scale) { |
| 476 dip_scale_ = dip_scale; | 474 dip_scale_ = dip_scale; |
| 477 CHECK(dip_scale_ > 0); | 475 CHECK(dip_scale_ > 0); |
| 478 } | 476 } |
| 479 | 477 |
| 480 void BrowserViewRenderer::SetHasTransparentBackground(bool transparent) { | |
| 481 has_transparent_background_ = transparent; | |
| 482 } | |
| 483 | |
| 484 gfx::Vector2d BrowserViewRenderer::max_scroll_offset() const { | 478 gfx::Vector2d BrowserViewRenderer::max_scroll_offset() const { |
| 485 DCHECK_GT(dip_scale_, 0); | 479 DCHECK_GT(dip_scale_, 0); |
| 486 return gfx::ToCeiledVector2d(gfx::ScaleVector2d( | 480 return gfx::ToCeiledVector2d(gfx::ScaleVector2d( |
| 487 max_scroll_offset_dip_, dip_scale_ * page_scale_factor_)); | 481 max_scroll_offset_dip_, dip_scale_ * page_scale_factor_)); |
| 488 } | 482 } |
| 489 | 483 |
| 490 void BrowserViewRenderer::ScrollTo(gfx::Vector2d scroll_offset) { | 484 void BrowserViewRenderer::ScrollTo(gfx::Vector2d scroll_offset) { |
| 491 gfx::Vector2d max_offset = max_scroll_offset(); | 485 gfx::Vector2d max_offset = max_scroll_offset(); |
| 492 gfx::Vector2dF scroll_offset_dip; | 486 gfx::Vector2dF scroll_offset_dip; |
| 493 // To preserve the invariant that scrolling to the maximum physical pixel | 487 // To preserve the invariant that scrolling to the maximum physical pixel |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 fallback_tick_fired_.Cancel(); | 718 fallback_tick_fired_.Cancel(); |
| 725 EnsureContinuousInvalidation(false); | 719 EnsureContinuousInvalidation(false); |
| 726 } | 720 } |
| 727 | 721 |
| 728 std::string BrowserViewRenderer::ToString(AwDrawGLInfo* draw_info) const { | 722 std::string BrowserViewRenderer::ToString(AwDrawGLInfo* draw_info) const { |
| 729 std::string str; | 723 std::string str; |
| 730 base::StringAppendF(&str, "is_paused: %d ", is_paused_); | 724 base::StringAppendF(&str, "is_paused: %d ", is_paused_); |
| 731 base::StringAppendF(&str, "view_visible: %d ", view_visible_); | 725 base::StringAppendF(&str, "view_visible: %d ", view_visible_); |
| 732 base::StringAppendF(&str, "window_visible: %d ", window_visible_); | 726 base::StringAppendF(&str, "window_visible: %d ", window_visible_); |
| 733 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); | 727 base::StringAppendF(&str, "dip_scale: %f ", dip_scale_); |
| 734 base::StringAppendF(&str, "has_transparent_background_: %d", | |
| 735 has_transparent_background_); | |
| 736 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); | 728 base::StringAppendF(&str, "page_scale_factor: %f ", page_scale_factor_); |
| 737 base::StringAppendF(&str, | 729 base::StringAppendF(&str, |
| 738 "compositor_needs_continuous_invalidate: %d ", | 730 "compositor_needs_continuous_invalidate: %d ", |
| 739 compositor_needs_continuous_invalidate_); | 731 compositor_needs_continuous_invalidate_); |
| 740 base::StringAppendF(&str, "block_invalidates: %d ", block_invalidates_); | 732 base::StringAppendF(&str, "block_invalidates: %d ", block_invalidates_); |
| 741 base::StringAppendF(&str, "view width height: [%d %d] ", width_, height_); | 733 base::StringAppendF(&str, "view width height: [%d %d] ", width_, height_); |
| 742 base::StringAppendF(&str, "attached_to_window: %d ", attached_to_window_); | 734 base::StringAppendF(&str, "attached_to_window: %d ", attached_to_window_); |
| 743 base::StringAppendF(&str, | 735 base::StringAppendF(&str, |
| 744 "global visible rect: %s ", | 736 "global visible rect: %s ", |
| 745 last_on_draw_global_visible_rect_.ToString().c_str()); | 737 last_on_draw_global_visible_rect_.ToString().c_str()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 761 base::StringAppendF(&str, | 753 base::StringAppendF(&str, |
| 762 "surface width height: [%d %d] ", | 754 "surface width height: [%d %d] ", |
| 763 draw_info->width, | 755 draw_info->width, |
| 764 draw_info->height); | 756 draw_info->height); |
| 765 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); | 757 base::StringAppendF(&str, "is_layer: %d ", draw_info->is_layer); |
| 766 } | 758 } |
| 767 return str; | 759 return str; |
| 768 } | 760 } |
| 769 | 761 |
| 770 } // namespace android_webview | 762 } // namespace android_webview |
| OLD | NEW |