OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SIMPLE_PNG_ENCODER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SIMPLE_PNG_ENCODER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted_memory.h" |
| 11 #include "base/synchronization/cancellation_flag.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 |
| 14 namespace chromeos { |
| 15 |
| 16 typedef base::Callback<void( |
| 17 scoped_refptr<base::RefCountedBytes>)> EncoderCallback; |
| 18 |
| 19 // Operation class that encodes existing in-memory image as PNG. |
| 20 // It uses NO-COMPRESSION to save time. |
| 21 class SimplePngEncoder |
| 22 : public base::RefCountedThreadSafe<SimplePngEncoder> { |
| 23 public: |
| 24 SimplePngEncoder(scoped_refptr<base::RefCountedBytes> data, |
| 25 SkBitmap image, |
| 26 base::Closure cancel_callback); |
| 27 |
| 28 void Run(EncoderCallback callback); |
| 29 |
| 30 void EncodeWallpaper(); |
| 31 void Cancel(); |
| 32 |
| 33 private: |
| 34 friend class base::RefCountedThreadSafe<SimplePngEncoder>; |
| 35 |
| 36 ~SimplePngEncoder(); |
| 37 |
| 38 base::CancellationFlag cancel_flag_; |
| 39 |
| 40 // Buffer to store encoded image. |
| 41 scoped_refptr<base::RefCountedBytes> data_; |
| 42 // Original image to encode. |
| 43 SkBitmap image_; |
| 44 base::Closure cancel_callback_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(SimplePngEncoder); |
| 47 }; |
| 48 |
| 49 } // namespace chromeos |
| 50 |
| 51 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_SIMPLE_PNG_ENCODER_H_ |
OLD | NEW |