OLD | NEW |
---|---|
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 <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "cc/base/latency_info_swap_promise.h" | 17 #include "cc/base/latency_info_swap_promise.h" |
18 #include "cc/base/latency_info_swap_promise_monitor.h" | 18 #include "cc/base/latency_info_swap_promise_monitor.h" |
19 #include "cc/base/switches.h" | 19 #include "cc/base/switches.h" |
20 #include "cc/debug/layer_tree_debug_state.h" | 20 #include "cc/debug/layer_tree_debug_state.h" |
21 #include "cc/debug/micro_benchmark.h" | 21 #include "cc/debug/micro_benchmark.h" |
22 #include "cc/input/layer_selection_bound.h" | |
22 #include "cc/layers/layer.h" | 23 #include "cc/layers/layer.h" |
23 #include "cc/output/copy_output_request.h" | 24 #include "cc/output/copy_output_request.h" |
24 #include "cc/output/copy_output_result.h" | 25 #include "cc/output/copy_output_result.h" |
25 #include "cc/resources/single_release_callback.h" | 26 #include "cc/resources/single_release_callback.h" |
26 #include "cc/trees/layer_tree_host.h" | 27 #include "cc/trees/layer_tree_host.h" |
27 #include "content/child/child_shared_bitmap_manager.h" | 28 #include "content/child/child_shared_bitmap_manager.h" |
28 #include "content/common/content_switches_internal.h" | 29 #include "content/common/content_switches_internal.h" |
29 #include "content/common/gpu/client/context_provider_command_buffer.h" | 30 #include "content/common/gpu/client/context_provider_command_buffer.h" |
30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
31 #include "content/renderer/compositor_bindings/web_layer_impl.h" | 32 #include "content/renderer/compositor_bindings/web_layer_impl.h" |
32 #include "content/renderer/input/input_handler_manager.h" | 33 #include "content/renderer/input/input_handler_manager.h" |
33 #include "content/renderer/render_thread_impl.h" | 34 #include "content/renderer/render_thread_impl.h" |
34 #include "gpu/command_buffer/client/gles2_interface.h" | 35 #include "gpu/command_buffer/client/gles2_interface.h" |
35 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac k.h" | 36 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac k.h" |
37 #include "third_party/WebKit/public/platform/WebSelectionBound.h" | |
36 #include "third_party/WebKit/public/platform/WebSize.h" | 38 #include "third_party/WebKit/public/platform/WebSize.h" |
37 #include "third_party/WebKit/public/web/WebWidget.h" | 39 #include "third_party/WebKit/public/web/WebWidget.h" |
38 #include "ui/gfx/frame_time.h" | 40 #include "ui/gfx/frame_time.h" |
39 #include "ui/gl/gl_switches.h" | 41 #include "ui/gl/gl_switches.h" |
40 #include "ui/native_theme/native_theme_switches.h" | 42 #include "ui/native_theme/native_theme_switches.h" |
41 | 43 |
42 namespace base { | 44 namespace base { |
43 class Value; | 45 class Value; |
44 } | 46 } |
45 | 47 |
46 namespace cc { | 48 namespace cc { |
47 class Layer; | 49 class Layer; |
48 } | 50 } |
49 | 51 |
50 using blink::WebFloatPoint; | 52 using blink::WebFloatPoint; |
53 using blink::WebSelectionBound; | |
51 using blink::WebSize; | 54 using blink::WebSize; |
52 using blink::WebRect; | 55 using blink::WebRect; |
53 | 56 |
54 namespace content { | 57 namespace content { |
55 namespace { | 58 namespace { |
56 | 59 |
57 bool GetSwitchValueAsInt( | 60 bool GetSwitchValueAsInt( |
58 const CommandLine& command_line, | 61 const CommandLine& command_line, |
59 const std::string& switch_string, | 62 const std::string& switch_string, |
60 int min_value, | 63 int min_value, |
61 int max_value, | 64 int max_value, |
62 int* result) { | 65 int* result) { |
63 std::string string_value = command_line.GetSwitchValueASCII(switch_string); | 66 std::string string_value = command_line.GetSwitchValueASCII(switch_string); |
64 int int_value; | 67 int int_value; |
65 if (base::StringToInt(string_value, &int_value) && | 68 if (base::StringToInt(string_value, &int_value) && |
66 int_value >= min_value && int_value <= max_value) { | 69 int_value >= min_value && int_value <= max_value) { |
67 *result = int_value; | 70 *result = int_value; |
68 return true; | 71 return true; |
69 } else { | 72 } else { |
70 LOG(WARNING) << "Failed to parse switch " << switch_string << ": " << | 73 LOG(WARNING) << "Failed to parse switch " << switch_string << ": " << |
71 string_value; | 74 string_value; |
72 return false; | 75 return false; |
73 } | 76 } |
74 } | 77 } |
75 | 78 |
79 bool ConvertWebSelectionBound(const WebSelectionBound& web_bound, | |
80 cc::LayerSelectionBound* cc_bound) { | |
81 DCHECK(cc_bound); | |
82 if (!web_bound.layerId) | |
83 return false; | |
aelias_OOO_until_Jul13
2014/06/28 00:02:17
Can we just DCHECK this instead? The Blink API is
jdduke (slow)
2014/06/28 00:29:10
Done, and I've already got ASSERT's in place on th
| |
84 | |
85 switch (web_bound.type) { | |
86 case blink::WebSelectionBound::Caret: | |
87 cc_bound->type = cc::SELECTION_BOUND_CENTER; | |
88 break; | |
89 case blink::WebSelectionBound::SelectionLeft: | |
90 cc_bound->type = cc::SELECTION_BOUND_LEFT; | |
91 break; | |
92 case blink::WebSelectionBound::SelectionRight: | |
93 cc_bound->type = cc::SELECTION_BOUND_RIGHT; | |
94 break; | |
95 } | |
96 | |
97 cc_bound->layer_id = web_bound.layerId; | |
98 cc_bound->layer_rect = gfx::Rect(web_bound.edgeRectInLayer); | |
99 return true; | |
100 } | |
101 | |
76 } // namespace | 102 } // namespace |
77 | 103 |
78 // static | 104 // static |
79 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( | 105 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( |
80 RenderWidget* widget, | 106 RenderWidget* widget, |
81 bool threaded) { | 107 bool threaded) { |
82 scoped_ptr<RenderWidgetCompositor> compositor( | 108 scoped_ptr<RenderWidgetCompositor> compositor( |
83 new RenderWidgetCompositor(widget, threaded)); | 109 new RenderWidgetCompositor(widget, threaded)); |
84 | 110 |
85 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 111 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 ? static_cast<const WebLayerImpl*>(outerViewportScrollLayer)->layer() | 586 ? static_cast<const WebLayerImpl*>(outerViewportScrollLayer)->layer() |
561 : NULL); | 587 : NULL); |
562 } | 588 } |
563 | 589 |
564 void RenderWidgetCompositor::clearViewportLayers() { | 590 void RenderWidgetCompositor::clearViewportLayers() { |
565 layer_tree_host_->RegisterViewportLayers(scoped_refptr<cc::Layer>(), | 591 layer_tree_host_->RegisterViewportLayers(scoped_refptr<cc::Layer>(), |
566 scoped_refptr<cc::Layer>(), | 592 scoped_refptr<cc::Layer>(), |
567 scoped_refptr<cc::Layer>()); | 593 scoped_refptr<cc::Layer>()); |
568 } | 594 } |
569 | 595 |
596 void RenderWidgetCompositor::registerSelection( | |
597 const blink::WebSelectionBound& anchor, | |
598 const blink::WebSelectionBound& focus) { | |
599 cc::LayerSelectionBound cc_anchor; | |
600 cc::LayerSelectionBound cc_focus; | |
601 if (!ConvertWebSelectionBound(anchor, &cc_anchor) || | |
602 !ConvertWebSelectionBound(focus, &cc_focus)) { | |
603 clearSelection(); | |
604 return; | |
605 } | |
606 | |
607 layer_tree_host_->RegisterSelection(cc_anchor, cc_focus); | |
608 } | |
609 | |
610 void RenderWidgetCompositor::clearSelection() { | |
611 cc::LayerSelectionBound empty_selection; | |
612 layer_tree_host_->RegisterSelection(empty_selection, empty_selection); | |
613 } | |
614 | |
570 void CompositeAndReadbackAsyncCallback( | 615 void CompositeAndReadbackAsyncCallback( |
571 blink::WebCompositeAndReadbackAsyncCallback* callback, | 616 blink::WebCompositeAndReadbackAsyncCallback* callback, |
572 scoped_ptr<cc::CopyOutputResult> result) { | 617 scoped_ptr<cc::CopyOutputResult> result) { |
573 if (result->HasBitmap()) { | 618 if (result->HasBitmap()) { |
574 scoped_ptr<SkBitmap> result_bitmap = result->TakeBitmap(); | 619 scoped_ptr<SkBitmap> result_bitmap = result->TakeBitmap(); |
575 callback->didCompositeAndReadback(*result_bitmap); | 620 callback->didCompositeAndReadback(*result_bitmap); |
576 } else { | 621 } else { |
577 callback->didCompositeAndReadback(SkBitmap()); | 622 callback->didCompositeAndReadback(SkBitmap()); |
578 } | 623 } |
579 } | 624 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 widget_->OnSwapBuffersAborted(); | 745 widget_->OnSwapBuffersAborted(); |
701 } | 746 } |
702 | 747 |
703 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 748 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
704 cc::ContextProvider* provider = | 749 cc::ContextProvider* provider = |
705 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 750 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
706 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 751 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
707 } | 752 } |
708 | 753 |
709 } // namespace content | 754 } // namespace content |
OLD | NEW |