| 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 24 matching lines...) Expand all Loading... |
| 35 // When coming here, the resulting image will be empty. | 35 // When coming here, the resulting image will be empty. |
| 36 DCHECK(false) << "Cannot start bitmap encode task."; | 36 DCHECK(false) << "Cannot start bitmap encode task."; |
| 37 callback.Run(); | 37 callback.Run(); |
| 38 } | 38 } |
| 39 } | 39 } |
| 40 | 40 |
| 41 scoped_refptr<base::RefCountedBytes> data() const { return data_; } | 41 scoped_refptr<base::RefCountedBytes> data() const { return data_; } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 friend class base::RefCountedThreadSafe<ProxyImageData>; | 44 friend class base::RefCountedThreadSafe<ProxyImageData>; |
| 45 virtual ~ProxyImageData() { | 45 ~ProxyImageData() {} |
| 46 } | |
| 47 | 46 |
| 48 void EncodeOnWorker(const SkBitmap& bitmap) { | 47 void EncodeOnWorker(const SkBitmap& bitmap) { |
| 49 DCHECK_EQ(bitmap.colorType(), kAlpha_8_SkColorType); | 48 DCHECK_EQ(bitmap.colorType(), kAlpha_8_SkColorType); |
| 50 // Encode the A8 bitmap to grayscale PNG treating alpha as color intensity. | 49 // Encode the A8 bitmap to grayscale PNG treating alpha as color intensity. |
| 51 std::vector<unsigned char> data; | 50 std::vector<unsigned char> data; |
| 52 if (gfx::PNGCodec::EncodeA8SkBitmap(bitmap, &data)) | 51 if (gfx::PNGCodec::EncodeA8SkBitmap(bitmap, &data)) |
| 53 data_ = new base::RefCountedBytes(data); | 52 data_ = new base::RefCountedBytes(data); |
| 54 } | 53 } |
| 55 | 54 |
| 56 scoped_refptr<base::RefCountedBytes> data_; | 55 scoped_refptr<base::RefCountedBytes> data_; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 180 |
| 182 void ContentProxy::OnContentImageEncodeComplete( | 181 void ContentProxy::OnContentImageEncodeComplete( |
| 183 scoped_refptr<ProxyImageData> image) { | 182 scoped_refptr<ProxyImageData> image) { |
| 184 png_data_ = image->data(); | 183 png_data_ = image->data(); |
| 185 | 184 |
| 186 // From now on we decode the image as needed to save memory. | 185 // From now on we decode the image as needed to save memory. |
| 187 raw_image_ = gfx::ImageSkia(); | 186 raw_image_ = gfx::ImageSkia(); |
| 188 } | 187 } |
| 189 | 188 |
| 190 } // namespace athena | 189 } // namespace athena |
| OLD | NEW |