OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/options2/chromeos/wallpaper_source.h" | 5 #include "chrome/browser/ui/webui/options2/chromeos/wallpaper_source.h" |
6 | 6 |
7 #include "ash/desktop_background/desktop_background_controller.h" | 7 #include "ash/desktop_background/desktop_background_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/synchronization/cancellation_flag.h" | 10 #include "base/synchronization/cancellation_flag.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 int request_id() { | 51 int request_id() { |
52 return request_id_; | 52 return request_id_; |
53 } | 53 } |
54 | 54 |
55 void EncodeWallpaper() { | 55 void EncodeWallpaper() { |
56 if (cancel_flag_.IsSet()) | 56 if (cancel_flag_.IsSet()) |
57 return; | 57 return; |
58 TRACE_EVENT0("LOCK_SCREEN", "imageEncoding"); | 58 TRACE_EVENT0("LOCK_SCREEN", "imageEncoding"); |
59 SkAutoLockPixels lock_input(image_); | 59 SkAutoLockPixels lock_input(image_); |
| 60 |
| 61 if (!image_.readyToDraw()) |
| 62 return; |
| 63 |
60 // Avoid compression to make things faster. | 64 // Avoid compression to make things faster. |
61 gfx::PNGCodec::EncodeWithCompressionLevel( | 65 gfx::PNGCodec::EncodeWithCompressionLevel( |
62 reinterpret_cast<unsigned char*>(image_.getAddr32(0, 0)), | 66 reinterpret_cast<unsigned char*>(image_.getAddr32(0, 0)), |
63 gfx::PNGCodec::FORMAT_SkBitmap, | 67 gfx::PNGCodec::FORMAT_SkBitmap, |
64 gfx::Size(image_.width(), image_.height()), | 68 gfx::Size(image_.width(), image_.height()), |
65 image_.width() * image_.bytesPerPixel(), | 69 image_.width() * image_.bytesPerPixel(), |
66 false, | 70 false, |
67 std::vector<gfx::PNGCodec::Comment>(), | 71 std::vector<gfx::PNGCodec::Comment>(), |
68 Z_NO_COMPRESSION, | 72 Z_NO_COMPRESSION, |
69 &data_->data()); | 73 &data_->data()); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 174 |
171 void WallpaperImageSource::SendCurrentUserWallpaper(int request_id, | 175 void WallpaperImageSource::SendCurrentUserWallpaper(int request_id, |
172 scoped_refptr<base::RefCountedBytes> data) { | 176 scoped_refptr<base::RefCountedBytes> data) { |
173 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 177 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
174 SendResponse(request_id, data); | 178 SendResponse(request_id, data); |
175 TRACE_EVENT_ASYNC_END0("SCREEN_LOCK", "GetUserWallpaper", request_id); | 179 TRACE_EVENT_ASYNC_END0("SCREEN_LOCK", "GetUserWallpaper", request_id); |
176 } | 180 } |
177 | 181 |
178 } // namespace options2 | 182 } // namespace options2 |
179 } // namespace chromeos | 183 } // namespace chromeos |
OLD | NEW |