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 "athena/content/content_proxy.h" | 5 #include "athena/content/content_proxy.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/threading/worker_pool.h" | 8 #include "base/threading/worker_pool.h" |
9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
10 #include "content/public/browser/render_widget_host_view.h" | 10 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 gfx::Size source = host->GetView()->GetViewBounds().size(); | 150 gfx::Size source = host->GetView()->GetViewBounds().size(); |
151 gfx::Size target = gfx::Size(source.width() / 2, source.height() / 2); | 151 gfx::Size target = gfx::Size(source.width() / 2, source.height() / 2); |
152 host->CopyFromBackingStore( | 152 host->CopyFromBackingStore( |
153 gfx::Rect(), | 153 gfx::Rect(), |
154 target, | 154 target, |
155 base::Bind(&ContentProxy::OnContentImageRead, | 155 base::Bind(&ContentProxy::OnContentImageRead, |
156 proxy_content_to_image_factory_.GetWeakPtr()), | 156 proxy_content_to_image_factory_.GetWeakPtr()), |
157 kAlpha_8_SkColorType); | 157 kAlpha_8_SkColorType); |
158 } | 158 } |
159 | 159 |
160 void ContentProxy::OnContentImageRead(bool success, const SkBitmap& bitmap) { | 160 void ContentProxy::OnContentImageRead( |
| 161 const SkBitmap& bitmap, |
| 162 const content::ReadbackResponse& response) { |
161 // Now we can hide the content. Note that after hiding we are freeing memory | 163 // Now we can hide the content. Note that after hiding we are freeing memory |
162 // and if something goes wrong we will end up with an empty page. | 164 // and if something goes wrong we will end up with an empty page. |
163 HideOriginalContent(); | 165 HideOriginalContent(); |
164 | 166 |
165 if (!success || bitmap.empty() || bitmap.isNull()) | 167 if ((response != content::READBACK_SUCCESS) || bitmap.empty() || |
| 168 bitmap.isNull()) |
166 return; | 169 return; |
167 | 170 |
168 // While we are encoding the image, we keep the current image as reference | 171 // While we are encoding the image, we keep the current image as reference |
169 // to have something for the overview mode to grab. Once we have the encoded | 172 // to have something for the overview mode to grab. Once we have the encoded |
170 // PNG, we will get rid of this. | 173 // PNG, we will get rid of this. |
171 raw_image_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 174 raw_image_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
172 | 175 |
173 scoped_refptr<ProxyImageData> png_image = new ProxyImageData(); | 176 scoped_refptr<ProxyImageData> png_image = new ProxyImageData(); |
174 png_image->EncodeImage( | 177 png_image->EncodeImage( |
175 bitmap, | 178 bitmap, |
176 base::Bind(&ContentProxy::OnContentImageEncodeComplete, | 179 base::Bind(&ContentProxy::OnContentImageEncodeComplete, |
177 proxy_content_to_image_factory_.GetWeakPtr(), | 180 proxy_content_to_image_factory_.GetWeakPtr(), |
178 png_image)); | 181 png_image)); |
179 } | 182 } |
180 | 183 |
181 void ContentProxy::OnContentImageEncodeComplete( | 184 void ContentProxy::OnContentImageEncodeComplete( |
182 scoped_refptr<ProxyImageData> image) { | 185 scoped_refptr<ProxyImageData> image) { |
183 png_data_ = image->data(); | 186 png_data_ = image->data(); |
184 | 187 |
185 // From now on we decode the image as needed to save memory. | 188 // From now on we decode the image as needed to save memory. |
186 raw_image_ = gfx::ImageSkia(); | 189 raw_image_ = gfx::ImageSkia(); |
187 } | 190 } |
188 | 191 |
189 } // namespace athena | 192 } // namespace athena |
OLD | NEW |