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

Side by Side Diff: content/renderer/gpu/render_widget_compositor.cc

Issue 2034393003: testRunner.layoutAndPaintAsyncThen ==> testRunner.compositeAsyncThen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/renderer/gpu/render_widget_compositor.h" 5 #include "content/renderer/gpu/render_widget_compositor.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/common/content_switches_internal.h" 45 #include "content/common/content_switches_internal.h"
46 #include "content/common/gpu/client/context_provider_command_buffer.h" 46 #include "content/common/gpu/client/context_provider_command_buffer.h"
47 #include "content/common/input/input_event_utils.h" 47 #include "content/common/input/input_event_utils.h"
48 #include "content/public/common/content_client.h" 48 #include "content/public/common/content_client.h"
49 #include "content/public/common/content_switches.h" 49 #include "content/public/common/content_switches.h"
50 #include "content/renderer/gpu/render_widget_compositor_delegate.h" 50 #include "content/renderer/gpu/render_widget_compositor_delegate.h"
51 #include "content/renderer/input/input_handler_manager.h" 51 #include "content/renderer/input/input_handler_manager.h"
52 #include "gpu/command_buffer/client/gles2_interface.h" 52 #include "gpu/command_buffer/client/gles2_interface.h"
53 #include "gpu/command_buffer/service/gpu_switches.h" 53 #include "gpu/command_buffer/service/gpu_switches.h"
54 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac k.h" 54 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac k.h"
55 #include "third_party/WebKit/public/platform/WebCompositeCallback.h"
55 #include "third_party/WebKit/public/platform/WebCompositorMutatorClient.h" 56 #include "third_party/WebKit/public/platform/WebCompositorMutatorClient.h"
56 #include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h"
57 #include "third_party/WebKit/public/platform/WebSize.h" 57 #include "third_party/WebKit/public/platform/WebSize.h"
58 #include "third_party/WebKit/public/web/WebKit.h" 58 #include "third_party/WebKit/public/web/WebKit.h"
59 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 59 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
60 #include "third_party/WebKit/public/web/WebSelection.h" 60 #include "third_party/WebKit/public/web/WebSelection.h"
61 #include "ui/gl/gl_switches.h" 61 #include "ui/gl/gl_switches.h"
62 #include "ui/native_theme/native_theme_switches.h" 62 #include "ui/native_theme/native_theme_switches.h"
63 63
64 #if defined(OS_ANDROID) 64 #if defined(OS_ANDROID)
65 #include "base/android/build_info.h" 65 #include "base/android/build_info.h"
66 #include "ui/gfx/android/device_display_info.h" 66 #include "ui/gfx/android/device_display_info.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return compositor; 216 return compositor;
217 } 217 }
218 218
219 RenderWidgetCompositor::RenderWidgetCompositor( 219 RenderWidgetCompositor::RenderWidgetCompositor(
220 RenderWidgetCompositorDelegate* delegate, 220 RenderWidgetCompositorDelegate* delegate,
221 CompositorDependencies* compositor_deps) 221 CompositorDependencies* compositor_deps)
222 : num_failed_recreate_attempts_(0), 222 : num_failed_recreate_attempts_(0),
223 delegate_(delegate), 223 delegate_(delegate),
224 compositor_deps_(compositor_deps), 224 compositor_deps_(compositor_deps),
225 never_visible_(false), 225 never_visible_(false),
226 layout_and_paint_async_callback_(nullptr),
227 remote_proto_channel_receiver_(nullptr), 226 remote_proto_channel_receiver_(nullptr),
228 weak_factory_(this) {} 227 weak_factory_(this) {}
229 228
230 void RenderWidgetCompositor::Initialize(float device_scale_factor) { 229 void RenderWidgetCompositor::Initialize(float device_scale_factor) {
231 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 230 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
232 231
233 cc::LayerTreeSettings settings; 232 cc::LayerTreeSettings settings;
234 233
235 // For web contents, layer transforms should scale up the contents of layers 234 // For web contents, layer transforms should scale up the contents of layers
236 // to keep content always crisp when possible. 235 // to keep content always crisp when possible.
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 layer_tree_host_->SetHaveScrollEventHandlers(has_handlers); 797 layer_tree_host_->SetHaveScrollEventHandlers(has_handlers);
799 } 798 }
800 799
801 bool RenderWidgetCompositor::haveScrollEventHandlers() const { 800 bool RenderWidgetCompositor::haveScrollEventHandlers() const {
802 return layer_tree_host_->have_scroll_event_handlers(); 801 return layer_tree_host_->have_scroll_event_handlers();
803 } 802 }
804 803
805 void CompositeAndReadbackAsyncCallback( 804 void CompositeAndReadbackAsyncCallback(
806 blink::WebCompositeAndReadbackAsyncCallback* callback, 805 blink::WebCompositeAndReadbackAsyncCallback* callback,
807 std::unique_ptr<cc::CopyOutputResult> result) { 806 std::unique_ptr<cc::CopyOutputResult> result) {
808 if (result->HasBitmap()) { 807 if (callback->needsBitmap() && result->HasBitmap()) {
809 std::unique_ptr<SkBitmap> result_bitmap = result->TakeBitmap(); 808 std::unique_ptr<SkBitmap> result_bitmap = result->TakeBitmap();
810 callback->didCompositeAndReadback(*result_bitmap); 809 callback->didCompositeAndReadback(*result_bitmap);
811 } else { 810 } else {
812 callback->didCompositeAndReadback(SkBitmap()); 811 callback->didCompositeAndReadback(SkBitmap());
813 } 812 }
814 } 813 }
815 814
816 bool RenderWidgetCompositor::CompositeIsSynchronous() const { 815 bool RenderWidgetCompositor::CompositeIsSynchronous() const {
817 return !compositor_deps_->GetCompositorImplThreadTaskRunner().get() && 816 return !compositor_deps_->GetCompositorImplThreadTaskRunner().get() &&
818 !layer_tree_host_->settings().single_thread_proxy_scheduler; 817 !layer_tree_host_->settings().single_thread_proxy_scheduler;
819 } 818 }
820 819
821 void RenderWidgetCompositor::layoutAndPaintAsync(
822 blink::WebLayoutAndPaintAsyncCallback* callback) {
823 DCHECK(!temporary_copy_output_request_ && !layout_and_paint_async_callback_);
824 layout_and_paint_async_callback_ = callback;
825
826 if (CompositeIsSynchronous()) {
827 base::ThreadTaskRunnerHandle::Get()->PostTask(
828 FROM_HERE, base::Bind(&RenderWidgetCompositor::LayoutAndUpdateLayers,
829 weak_factory_.GetWeakPtr()));
830 } else {
831 layer_tree_host_->SetNeedsCommit();
832 }
833 }
834
835 void RenderWidgetCompositor::LayoutAndUpdateLayers() {
836 DCHECK(CompositeIsSynchronous());
837 layer_tree_host_->LayoutAndUpdateLayers();
838 InvokeLayoutAndPaintCallback();
839 }
840
841 void RenderWidgetCompositor::InvokeLayoutAndPaintCallback() {
842 if (!layout_and_paint_async_callback_)
843 return;
844 layout_and_paint_async_callback_->didLayoutAndPaint();
845 layout_and_paint_async_callback_ = nullptr;
846 }
847
848 void RenderWidgetCompositor::compositeAndReadbackAsync( 820 void RenderWidgetCompositor::compositeAndReadbackAsync(
849 blink::WebCompositeAndReadbackAsyncCallback* callback) { 821 blink::WebCompositeAndReadbackAsyncCallback* callback) {
850 DCHECK(!temporary_copy_output_request_ && !layout_and_paint_async_callback_); 822 DCHECK(!temporary_copy_output_request_);
851 temporary_copy_output_request_ = 823 temporary_copy_output_request_ =
852 cc::CopyOutputRequest::CreateBitmapRequest( 824 cc::CopyOutputRequest::CreateBitmapRequest(
853 base::Bind(&CompositeAndReadbackAsyncCallback, callback)); 825 base::Bind(&CompositeAndReadbackAsyncCallback, callback));
854 826
855 // Force a commit to happen. The temporary copy output request will 827 // Force a commit to happen. The temporary copy output request will
856 // be installed after layout which will happen as a part of the commit, for 828 // be installed after layout which will happen as a part of the commit, for
857 // widgets that delay the creation of their output surface. 829 // widgets that delay the creation of their output surface.
858 if (CompositeIsSynchronous()) { 830 if (CompositeIsSynchronous()) {
859 base::ThreadTaskRunnerHandle::Get()->PostTask( 831 base::ThreadTaskRunnerHandle::Get()->PostTask(
860 FROM_HERE, base::Bind(&RenderWidgetCompositor::SynchronouslyComposite, 832 FROM_HERE, base::Bind(&RenderWidgetCompositor::SynchronouslyComposite,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 // in the output-surface-lost machinery. 967 // in the output-surface-lost machinery.
996 LOG_IF(FATAL, (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES)) 968 LOG_IF(FATAL, (num_failed_recreate_attempts_ >= MAX_OUTPUT_SURFACE_RETRIES))
997 << "Failed to create a fallback OutputSurface."; 969 << "Failed to create a fallback OutputSurface.";
998 970
999 base::ThreadTaskRunnerHandle::Get()->PostTask( 971 base::ThreadTaskRunnerHandle::Get()->PostTask(
1000 FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface, 972 FROM_HERE, base::Bind(&RenderWidgetCompositor::RequestNewOutputSurface,
1001 weak_factory_.GetWeakPtr())); 973 weak_factory_.GetWeakPtr()));
1002 } 974 }
1003 975
1004 void RenderWidgetCompositor::WillCommit() { 976 void RenderWidgetCompositor::WillCommit() {
1005 InvokeLayoutAndPaintCallback();
1006 } 977 }
1007 978
1008 void RenderWidgetCompositor::DidCommit() { 979 void RenderWidgetCompositor::DidCommit() {
1009 DCHECK(!temporary_copy_output_request_); 980 DCHECK(!temporary_copy_output_request_);
1010 delegate_->DidCommitCompositorFrame(); 981 delegate_->DidCommitCompositorFrame();
1011 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor(); 982 compositor_deps_->GetRendererScheduler()->DidCommitFrameToCompositor();
1012 } 983 }
1013 984
1014 void RenderWidgetCompositor::DidCommitAndDrawFrame() { 985 void RenderWidgetCompositor::DidCommitAndDrawFrame() {
1015 delegate_->DidCommitAndDrawCompositorFrame(); 986 delegate_->DidCommitAndDrawCompositorFrame();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 #endif 1128 #endif
1158 return actual; 1129 return actual;
1159 } 1130 }
1160 1131
1161 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor( 1132 void RenderWidgetCompositor::SetPaintedDeviceScaleFactor(
1162 float device_scale) { 1133 float device_scale) {
1163 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale); 1134 layer_tree_host_->SetPaintedDeviceScaleFactor(device_scale);
1164 } 1135 }
1165 1136
1166 } // namespace content 1137 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/render_widget_compositor.h ('k') | content/shell/renderer/layout_test/blink_test_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698