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 "athena/activity/public/activity.h" | 7 #include "athena/activity/public/activity.h" |
8 #include "athena/activity/public/activity_view_model.h" | 8 #include "athena/activity/public/activity_view_model.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // again. | 75 // again. |
76 ShowOriginalContent(); | 76 ShowOriginalContent(); |
77 } | 77 } |
78 | 78 |
79 void ContentProxy::ContentWillUnload() { | 79 void ContentProxy::ContentWillUnload() { |
80 content_loaded_ = false; | 80 content_loaded_ = false; |
81 } | 81 } |
82 | 82 |
83 gfx::ImageSkia ContentProxy::GetContentImage() { | 83 gfx::ImageSkia ContentProxy::GetContentImage() { |
84 // While we compress to PNG, we use the original read back. | 84 // While we compress to PNG, we use the original read back. |
85 if (!raw_image_.isNull() || !png_data_.get()) | 85 if (!png_data_.get()) |
86 return raw_image_; | 86 return raw_image_; |
87 | 87 |
88 // Otherwise we convert the PNG. | 88 // Otherwise we convert the PNG. |
89 std::vector<gfx::ImagePNGRep> image_reps; | 89 std::vector<gfx::ImagePNGRep> image_reps; |
90 image_reps.push_back(gfx::ImagePNGRep(png_data_, 0.0f)); | 90 image_reps.push_back(gfx::ImagePNGRep(png_data_, 1.0f)); |
91 return *(gfx::Image(image_reps).ToImageSkia()); | 91 return *(gfx::Image(image_reps).ToImageSkia()); |
92 } | 92 } |
93 | 93 |
94 void ContentProxy::EvictContent() { | 94 void ContentProxy::EvictContent() { |
95 raw_image_ = gfx::ImageSkia(); | 95 raw_image_ = gfx::ImageSkia(); |
96 png_data_->Release(); | 96 png_data_->Release(); |
97 } | 97 } |
98 | 98 |
99 void ContentProxy::OnPreContentDestroyed() { | 99 void ContentProxy::OnPreContentDestroyed() { |
100 // Since we are breaking now the connection to the old content, we make the | 100 // Since we are breaking now the connection to the old content, we make the |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 | 180 |
181 void ContentProxy::OnContentImageEncodeComplete( | 181 void ContentProxy::OnContentImageEncodeComplete( |
182 scoped_refptr<ProxyImageData> image) { | 182 scoped_refptr<ProxyImageData> image) { |
183 png_data_ = image->data(); | 183 png_data_ = image->data(); |
184 | 184 |
185 // 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. |
186 raw_image_ = gfx::ImageSkia(); | 186 raw_image_ = gfx::ImageSkia(); |
187 } | 187 } |
188 | 188 |
189 } // namespace athena | 189 } // namespace athena |
OLD | NEW |