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 "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event_argument.h" | 10 #include "base/debug/trace_event_argument.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 (bytes_limit / kMemoryAllocationStep + 1) * kMemoryAllocationStep; | 136 (bytes_limit / kMemoryAllocationStep + 1) * kMemoryAllocationStep; |
137 return bytes_limit; | 137 return bytes_limit; |
138 } | 138 } |
139 | 139 |
140 void BrowserViewRenderer::PrepareToDraw(const gfx::Vector2d& scroll, | 140 void BrowserViewRenderer::PrepareToDraw(const gfx::Vector2d& scroll, |
141 const gfx::Rect& global_visible_rect) { | 141 const gfx::Rect& global_visible_rect) { |
142 last_on_draw_scroll_offset_ = scroll; | 142 last_on_draw_scroll_offset_ = scroll; |
143 last_on_draw_global_visible_rect_ = global_visible_rect; | 143 last_on_draw_global_visible_rect_ = global_visible_rect; |
144 } | 144 } |
145 | 145 |
| 146 bool BrowserViewRenderer::CanOnDraw() { |
| 147 if (!compositor_) { |
| 148 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_NoCompositor", |
| 149 TRACE_EVENT_SCOPE_THREAD); |
| 150 return false; |
| 151 } |
| 152 if (clear_view_) { |
| 153 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_ClearView", |
| 154 TRACE_EVENT_SCOPE_THREAD); |
| 155 return false; |
| 156 } |
| 157 |
| 158 return true; |
| 159 } |
| 160 |
146 bool BrowserViewRenderer::OnDrawHardware() { | 161 bool BrowserViewRenderer::OnDrawHardware() { |
147 TRACE_EVENT0("android_webview", "BrowserViewRenderer::OnDrawHardware"); | 162 TRACE_EVENT0("android_webview", "BrowserViewRenderer::OnDrawHardware"); |
148 shared_renderer_state_.InitializeHardwareDrawIfNeededOnUI(); | 163 shared_renderer_state_.InitializeHardwareDrawIfNeededOnUI(); |
149 if (!compositor_) { | 164 |
150 TRACE_EVENT_INSTANT0("android_webview", "EarlyOut_NoCompositor", | 165 if (!CanOnDraw()) { |
151 TRACE_EVENT_SCOPE_THREAD); | |
152 return false; | 166 return false; |
153 } | 167 } |
154 | 168 |
155 shared_renderer_state_.SetScrollOffsetOnUI(last_on_draw_scroll_offset_); | 169 shared_renderer_state_.SetScrollOffsetOnUI(last_on_draw_scroll_offset_); |
156 | 170 |
157 if (!hardware_enabled_) { | 171 if (!hardware_enabled_) { |
158 TRACE_EVENT0("android_webview", "InitializeHwDraw"); | 172 TRACE_EVENT0("android_webview", "InitializeHwDraw"); |
159 hardware_enabled_ = compositor_->InitializeHwDraw(); | 173 hardware_enabled_ = compositor_->InitializeHwDraw(); |
160 } | 174 } |
161 if (!hardware_enabled_) { | 175 if (!hardware_enabled_) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 void BrowserViewRenderer::DidSkipCommitFrame() { | 277 void BrowserViewRenderer::DidSkipCommitFrame() { |
264 // Treat it the same way as skipping onDraw. | 278 // Treat it the same way as skipping onDraw. |
265 DidSkipCompositeInDraw(); | 279 DidSkipCompositeInDraw(); |
266 } | 280 } |
267 | 281 |
268 void BrowserViewRenderer::InvalidateOnFunctorDestroy() { | 282 void BrowserViewRenderer::InvalidateOnFunctorDestroy() { |
269 client_->InvalidateOnFunctorDestroy(); | 283 client_->InvalidateOnFunctorDestroy(); |
270 } | 284 } |
271 | 285 |
272 bool BrowserViewRenderer::OnDrawSoftware(SkCanvas* canvas) { | 286 bool BrowserViewRenderer::OnDrawSoftware(SkCanvas* canvas) { |
273 if (!compositor_) { | 287 return CanOnDraw() && CompositeSW(canvas); |
274 TRACE_EVENT_INSTANT0( | |
275 "android_webview", "EarlyOut_NoCompositor", TRACE_EVENT_SCOPE_THREAD); | |
276 return false; | |
277 } | |
278 | |
279 return CompositeSW(canvas); | |
280 } | 288 } |
281 | 289 |
282 skia::RefPtr<SkPicture> BrowserViewRenderer::CapturePicture(int width, | 290 skia::RefPtr<SkPicture> BrowserViewRenderer::CapturePicture(int width, |
283 int height) { | 291 int height) { |
284 TRACE_EVENT0("android_webview", "BrowserViewRenderer::CapturePicture"); | 292 TRACE_EVENT0("android_webview", "BrowserViewRenderer::CapturePicture"); |
285 | 293 |
286 // Return empty Picture objects for empty SkPictures. | 294 // Return empty Picture objects for empty SkPictures. |
287 if (width <= 0 || height <= 0) { | 295 if (width <= 0 || height <= 0) { |
288 SkPictureRecorder emptyRecorder; | 296 SkPictureRecorder emptyRecorder; |
289 emptyRecorder.beginRecording(0, 0); | 297 emptyRecorder.beginRecording(0, 0); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 base::StringAppendF(&str, | 746 base::StringAppendF(&str, |
739 "overscroll_rounding_error_: %s ", | 747 "overscroll_rounding_error_: %s ", |
740 overscroll_rounding_error_.ToString().c_str()); | 748 overscroll_rounding_error_.ToString().c_str()); |
741 base::StringAppendF( | 749 base::StringAppendF( |
742 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); | 750 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); |
743 base::StringAppendF(&str, "clear_view: %d ", clear_view_); | 751 base::StringAppendF(&str, "clear_view: %d ", clear_view_); |
744 return str; | 752 return str; |
745 } | 753 } |
746 | 754 |
747 } // namespace android_webview | 755 } // namespace android_webview |
OLD | NEW |