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 "content/renderer/child_frame_compositing_helper.h" | 5 #include "content/renderer/child_frame_compositing_helper.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "cc/blink/web_layer_impl.h" | 9 #include "cc/blink/web_layer_impl.h" |
10 #include "cc/layers/layer_settings.h" | 10 #include "cc/layers/layer_settings.h" |
| 11 #include "cc/layers/picture_image_layer.h" |
11 #include "cc/layers/solid_color_layer.h" | 12 #include "cc/layers/solid_color_layer.h" |
12 #include "cc/layers/surface_layer.h" | 13 #include "cc/layers/surface_layer.h" |
13 #include "cc/output/context_provider.h" | 14 #include "cc/output/context_provider.h" |
14 #include "cc/output/copy_output_request.h" | 15 #include "cc/output/copy_output_request.h" |
15 #include "cc/output/copy_output_result.h" | 16 #include "cc/output/copy_output_result.h" |
16 #include "cc/resources/single_release_callback.h" | 17 #include "cc/resources/single_release_callback.h" |
17 #include "content/child/thread_safe_sender.h" | 18 #include "content/child/thread_safe_sender.h" |
18 #include "content/common/browser_plugin/browser_plugin_messages.h" | 19 #include "content/common/browser_plugin/browser_plugin_messages.h" |
19 #include "content/common/content_switches_internal.h" | 20 #include "content/common/content_switches_internal.h" |
20 #include "content/common/frame_messages.h" | 21 #include "content/common/frame_messages.h" |
21 #include "content/common/gpu/client/context_provider_command_buffer.h" | 22 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 23 #include "content/public/common/content_client.h" |
| 24 #include "content/public/renderer/content_renderer_client.h" |
22 #include "content/renderer/browser_plugin/browser_plugin.h" | 25 #include "content/renderer/browser_plugin/browser_plugin.h" |
23 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 26 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
24 #include "content/renderer/render_frame_impl.h" | 27 #include "content/renderer/render_frame_impl.h" |
25 #include "content/renderer/render_frame_proxy.h" | 28 #include "content/renderer/render_frame_proxy.h" |
26 #include "content/renderer/render_thread_impl.h" | 29 #include "content/renderer/render_thread_impl.h" |
27 #include "skia/ext/image_operations.h" | 30 #include "skia/ext/image_operations.h" |
28 #include "third_party/WebKit/public/web/WebFrame.h" | 31 #include "third_party/WebKit/public/web/WebFrame.h" |
29 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 32 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
30 #include "third_party/khronos/GLES2/gl2.h" | 33 #include "third_party/khronos/GLES2/gl2.h" |
| 34 #include "third_party/skia/include/core/SkBitmap.h" |
| 35 #include "third_party/skia/include/core/SkImage.h" |
| 36 #include "ui/gfx/geometry/point_f.h" |
31 #include "ui/gfx/geometry/size_conversions.h" | 37 #include "ui/gfx/geometry/size_conversions.h" |
32 #include "ui/gfx/skia_util.h" | 38 #include "ui/gfx/skia_util.h" |
33 | 39 |
34 namespace content { | 40 namespace content { |
35 | 41 |
36 ChildFrameCompositingHelper* | 42 ChildFrameCompositingHelper* |
37 ChildFrameCompositingHelper::CreateForBrowserPlugin( | 43 ChildFrameCompositingHelper::CreateForBrowserPlugin( |
38 const base::WeakPtr<BrowserPlugin>& browser_plugin) { | 44 const base::WeakPtr<BrowserPlugin>& browser_plugin) { |
39 return new ChildFrameCompositingHelper( | 45 return new ChildFrameCompositingHelper( |
40 browser_plugin, nullptr, nullptr, | 46 browser_plugin, nullptr, nullptr, |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 } | 114 } |
109 | 115 |
110 void ChildFrameCompositingHelper::OnContainerDestroy() { | 116 void ChildFrameCompositingHelper::OnContainerDestroy() { |
111 UpdateWebLayer(nullptr); | 117 UpdateWebLayer(nullptr); |
112 } | 118 } |
113 | 119 |
114 void ChildFrameCompositingHelper::ChildFrameGone() { | 120 void ChildFrameCompositingHelper::ChildFrameGone() { |
115 scoped_refptr<cc::SolidColorLayer> crashed_layer = | 121 scoped_refptr<cc::SolidColorLayer> crashed_layer = |
116 cc::SolidColorLayer::Create(cc::LayerSettings()); | 122 cc::SolidColorLayer::Create(cc::LayerSettings()); |
117 crashed_layer->SetMasksToBounds(true); | 123 crashed_layer->SetMasksToBounds(true); |
118 crashed_layer->SetBackgroundColor(SkColorSetARGBInline(255, 0, 128, 0)); | 124 crashed_layer->SetBackgroundColor(SK_ColorBLACK); |
| 125 |
| 126 if (web_layer_) { |
| 127 SkBitmap* sad_bitmap = |
| 128 GetContentClient()->renderer()->GetSadWebViewBitmap(); |
| 129 if (sad_bitmap && web_layer_->bounds().width > sad_bitmap->width() && |
| 130 web_layer_->bounds().height > sad_bitmap->height()) { |
| 131 scoped_refptr<cc::PictureImageLayer> sad_layer = |
| 132 cc::PictureImageLayer::Create(cc::LayerSettings()); |
| 133 skia::RefPtr<SkImage> image = |
| 134 skia::AdoptRef(SkImage::NewFromBitmap(*sad_bitmap)); |
| 135 sad_layer->SetImage(image); |
| 136 sad_layer->SetBounds( |
| 137 gfx::Size(sad_bitmap->width(), sad_bitmap->height())); |
| 138 sad_layer->SetPosition(gfx::PointF( |
| 139 (web_layer_->bounds().width - sad_bitmap->width()) / 2, |
| 140 (web_layer_->bounds().height - sad_bitmap->height()) / 2)); |
| 141 sad_layer->SetIsDrawable(true); |
| 142 |
| 143 crashed_layer->AddChild(sad_layer); |
| 144 } |
| 145 } |
| 146 |
119 blink::WebLayer* layer = new cc_blink::WebLayerImpl(crashed_layer); | 147 blink::WebLayer* layer = new cc_blink::WebLayerImpl(crashed_layer); |
120 UpdateWebLayer(layer); | 148 UpdateWebLayer(layer); |
121 } | 149 } |
122 | 150 |
123 // static | 151 // static |
124 void ChildFrameCompositingHelper::SatisfyCallback( | 152 void ChildFrameCompositingHelper::SatisfyCallback( |
125 scoped_refptr<ThreadSafeSender> sender, | 153 scoped_refptr<ThreadSafeSender> sender, |
126 int host_routing_id, | 154 int host_routing_id, |
127 cc::SurfaceSequence sequence) { | 155 cc::SurfaceSequence sequence) { |
128 // This may be called on either the main or impl thread. | 156 // This may be called on either the main or impl thread. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 frame_size, scale_factor, | 243 frame_size, scale_factor, |
216 static_cast<cc_blink::WebLayerImpl*>(web_layer_.get())->layer()); | 244 static_cast<cc_blink::WebLayerImpl*>(web_layer_.get())->layer()); |
217 } | 245 } |
218 | 246 |
219 void ChildFrameCompositingHelper::UpdateVisibility(bool visible) { | 247 void ChildFrameCompositingHelper::UpdateVisibility(bool visible) { |
220 if (web_layer_) | 248 if (web_layer_) |
221 web_layer_->setDrawsContent(visible); | 249 web_layer_->setDrawsContent(visible); |
222 } | 250 } |
223 | 251 |
224 } // namespace content | 252 } // namespace content |
OLD | NEW |