Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: android_webview/browser/browser_view_renderer.cc

Issue 653173004: Part 2: WIP Refactor Webview graphics related code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rewrite rebase, without renames Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 bool needs_force_invalidate = 299 bool needs_force_invalidate =
300 shared_renderer_state_.NeedsForceInvalidateOnNextDrawGLOnUI(); 300 shared_renderer_state_.NeedsForceInvalidateOnNextDrawGLOnUI();
301 if (needs_force_invalidate || 301 if (needs_force_invalidate ||
302 !parent_draw_constraints_.Equals( 302 !parent_draw_constraints_.Equals(
303 shared_renderer_state_.GetParentDrawConstraintsOnUI())) { 303 shared_renderer_state_.GetParentDrawConstraintsOnUI())) {
304 shared_renderer_state_.SetForceInvalidateOnNextDrawGLOnUI(false); 304 shared_renderer_state_.SetForceInvalidateOnNextDrawGLOnUI(false);
305 EnsureContinuousInvalidation(true, needs_force_invalidate); 305 EnsureContinuousInvalidation(true, needs_force_invalidate);
306 } 306 }
307 } 307 }
308 308
309 void BrowserViewRenderer::ReturnUnusedResource(
310 scoped_ptr<cc::CompositorFrame> frame) {
311 if (!frame.get())
312 return;
313
314 cc::CompositorFrameAck frame_ack;
315 cc::TransferableResource::ReturnResources(
316 frame->delegated_frame_data->resource_list, &frame_ack.resources);
317 if (compositor_ && !frame_ack.resources.empty())
318 compositor_->ReturnResources(frame_ack);
319 }
320
321 void BrowserViewRenderer::ReturnResourceFromParent() { 309 void BrowserViewRenderer::ReturnResourceFromParent() {
322 cc::CompositorFrameAck frame_ack; 310 cc::CompositorFrameAck frame_ack;
323 shared_renderer_state_.SwapReturnedResourcesOnUI(&frame_ack.resources); 311 shared_renderer_state_.SwapReturnedResourcesOnUI(&frame_ack.resources);
324 if (compositor_ && !frame_ack.resources.empty()) { 312 if (compositor_ && !frame_ack.resources.empty()) {
325 compositor_->ReturnResources(frame_ack); 313 compositor_->ReturnResources(frame_ack);
326 } 314 }
327 } 315 }
328 316
329 void BrowserViewRenderer::DidSkipCommitFrame() { 317 void BrowserViewRenderer::DidSkipCommitFrame() {
330 // Treat it the same way as skipping onDraw. 318 // Treat it the same way as skipping onDraw.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 } 434 }
447 435
448 void BrowserViewRenderer::OnDetachedFromWindow() { 436 void BrowserViewRenderer::OnDetachedFromWindow() {
449 TRACE_EVENT0("android_webview", "BrowserViewRenderer::OnDetachedFromWindow"); 437 TRACE_EVENT0("android_webview", "BrowserViewRenderer::OnDetachedFromWindow");
450 attached_to_window_ = false; 438 attached_to_window_ = false;
451 DCHECK(!hardware_enabled_); 439 DCHECK(!hardware_enabled_);
452 } 440 }
453 441
454 void BrowserViewRenderer::ReleaseHardware() { 442 void BrowserViewRenderer::ReleaseHardware() {
455 DCHECK(hardware_enabled_); 443 DCHECK(hardware_enabled_);
456 // TODO(hush): do this in somewhere else. Either in hardware render or in
457 // shared renderer state.
458 ReturnUnusedResource(shared_renderer_state_.PassCompositorFrame());
459 ReturnResourceFromParent(); 444 ReturnResourceFromParent();
460 DCHECK(shared_renderer_state_.ReturnedResourcesEmpty()); 445 DCHECK(shared_renderer_state_.ReturnedResourcesEmptyOnUI());
461 446
462 if (compositor_) { 447 if (compositor_) {
463 compositor_->ReleaseHwDraw(); 448 compositor_->ReleaseHwDraw();
464 SynchronousCompositorMemoryPolicy zero_policy; 449 SynchronousCompositorMemoryPolicy zero_policy;
465 RequestMemoryPolicy(zero_policy); 450 RequestMemoryPolicy(zero_policy);
466 } 451 }
467 452
468 hardware_enabled_ = false; 453 hardware_enabled_ = false;
469 GlobalTileManager::GetInstance()->Remove(tile_manager_key_); 454 GlobalTileManager::GetInstance()->Remove(tile_manager_key_);
470 } 455 }
471 456
457 void BrowserViewRenderer::InvalidateOnFunctorDestroy() {
458 client_->InvalidateOnFunctorDestroy();
459 }
460
472 bool BrowserViewRenderer::IsVisible() const { 461 bool BrowserViewRenderer::IsVisible() const {
473 // Ignore |window_visible_| if |attached_to_window_| is false. 462 // Ignore |window_visible_| if |attached_to_window_| is false.
474 return view_visible_ && (!attached_to_window_ || window_visible_); 463 return view_visible_ && (!attached_to_window_ || window_visible_);
475 } 464 }
476 465
477 gfx::Rect BrowserViewRenderer::GetScreenRect() const { 466 gfx::Rect BrowserViewRenderer::GetScreenRect() const {
478 return gfx::Rect(client_->GetLocationOnScreen(), gfx::Size(width_, height_)); 467 return gfx::Rect(client_->GetLocationOnScreen(), gfx::Size(width_, height_));
479 } 468 }
480 469
481 void BrowserViewRenderer::DidInitializeCompositor( 470 void BrowserViewRenderer::DidInitializeCompositor(
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 "compositor_needs_continuous_invalidate_", 736 "compositor_needs_continuous_invalidate_",
748 compositor_needs_continuous_invalidate_); 737 compositor_needs_continuous_invalidate_);
749 738
750 // This should only be called if OnDraw or DrawGL did not come in time, which 739 // This should only be called if OnDraw or DrawGL did not come in time, which
751 // means block_invalidates_ must still be true. 740 // means block_invalidates_ must still be true.
752 DCHECK(block_invalidates_); 741 DCHECK(block_invalidates_);
753 fallback_tick_pending_ = false; 742 fallback_tick_pending_ = false;
754 if (compositor_needs_continuous_invalidate_ && compositor_) { 743 if (compositor_needs_continuous_invalidate_ && compositor_) {
755 if (hardware_enabled_) { 744 if (hardware_enabled_) {
756 ReturnResourceFromParent(); 745 ReturnResourceFromParent();
757 ReturnUnusedResource(shared_renderer_state_.PassCompositorFrame());
boliu 2014/10/28 19:49:43 This isn't quite the same anymore. This used to r
hush (inactive) 2014/10/29 19:57:04 The resources in SRS::returned_resources_ will be
758 scoped_ptr<cc::CompositorFrame> frame = CompositeHw(); 746 scoped_ptr<cc::CompositorFrame> frame = CompositeHw();
759 if (frame.get()) { 747 if (frame.get()) {
748 // Unused resource will be returned in SetCompositorFrameOnUI.
760 shared_renderer_state_.SetCompositorFrameOnUI(frame.Pass(), true); 749 shared_renderer_state_.SetCompositorFrameOnUI(frame.Pass(), true);
761 } 750 }
762 } else { 751 } else {
763 ForceFakeCompositeSW(); 752 ForceFakeCompositeSW();
764 } 753 }
765 } else { 754 } else {
766 // Pretend we just composited to unblock further invalidates. 755 // Pretend we just composited to unblock further invalidates.
767 DidComposite(); 756 DidComposite();
768 } 757 }
769 } 758 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 base::StringAppendF(&str, 808 base::StringAppendF(&str,
820 "overscroll_rounding_error_: %s ", 809 "overscroll_rounding_error_: %s ",
821 overscroll_rounding_error_.ToString().c_str()); 810 overscroll_rounding_error_.ToString().c_str());
822 base::StringAppendF( 811 base::StringAppendF(
823 &str, "on_new_picture_enable: %d ", on_new_picture_enable_); 812 &str, "on_new_picture_enable: %d ", on_new_picture_enable_);
824 base::StringAppendF(&str, "clear_view: %d ", clear_view_); 813 base::StringAppendF(&str, "clear_view: %d ", clear_view_);
825 return str; 814 return str;
826 } 815 }
827 816
828 } // namespace android_webview 817 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698