| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CC_RESOURCES_UI_RESOURCE_BITMAP_H_ | 5 #ifndef CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
| 6 #define CC_RESOURCES_UI_RESOURCE_BITMAP_H_ | 6 #define CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
| 11 #include "third_party/skia/include/core/SkTypes.h" | 11 #include "third_party/skia/include/core/SkTypes.h" |
| 12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
| 13 | 13 |
| 14 class SkBitmap; |
| 15 |
| 14 namespace cc { | 16 namespace cc { |
| 15 | 17 |
| 16 // Ref-counted bitmap class (can’t use SkBitmap because of ETC1). Thread-safety | 18 // Ref-counted bitmap class (can’t use SkBitmap because of ETC1). Thread-safety |
| 17 // ensures that both main and impl threads can hold references to the bitmap and | 19 // ensures that both main and impl threads can hold references to the bitmap and |
| 18 // that asynchronous uploads are allowed. | 20 // that asynchronous uploads are allowed. |
| 19 class CC_EXPORT UIResourceBitmap | 21 class CC_EXPORT UIResourceBitmap |
| 20 : public base::RefCountedThreadSafe<UIResourceBitmap> { | 22 : public base::RefCountedThreadSafe<UIResourceBitmap> { |
| 21 public: | 23 public: |
| 22 enum UIResourceFormat { | 24 enum UIResourceFormat { |
| 23 RGBA8 | 25 RGBA8 |
| 24 }; | 26 }; |
| 25 | 27 |
| 26 // Takes ownership of “pixels”. | 28 // Takes ownership of “pixels”. |
| 27 static scoped_refptr<UIResourceBitmap> Create(uint8_t* pixels, | 29 static scoped_refptr<UIResourceBitmap> Create(uint8_t* pixels, |
| 28 UIResourceFormat format, | 30 UIResourceFormat format, |
| 29 gfx::Size size); | 31 gfx::Size size); |
| 30 | 32 |
| 31 gfx::Size GetSize() const { return size_; } | 33 gfx::Size GetSize() const { return size_; } |
| 32 UIResourceFormat GetFormat() const { return format_; } | 34 UIResourceFormat GetFormat() const { return format_; } |
| 33 uint8_t* GetPixels() { return pixels_.get(); } | 35 uint8_t* GetPixels() { return pixels_.get(); } |
| 34 | 36 |
| 37 static scoped_refptr<UIResourceBitmap> CreateFromSkBitmap( |
| 38 const SkBitmap& skbitmap); |
| 39 |
| 35 private: | 40 private: |
| 36 friend class base::RefCountedThreadSafe<UIResourceBitmap>; | 41 friend class base::RefCountedThreadSafe<UIResourceBitmap>; |
| 37 | 42 |
| 38 UIResourceBitmap(); | 43 UIResourceBitmap(); |
| 39 ~UIResourceBitmap(); | 44 ~UIResourceBitmap(); |
| 40 | 45 |
| 41 scoped_ptr<uint8_t[]> pixels_; | 46 scoped_ptr<uint8_t[]> pixels_; |
| 42 UIResourceFormat format_; | 47 UIResourceFormat format_; |
| 43 gfx::Size size_; | 48 gfx::Size size_; |
| 44 | 49 |
| 45 DISALLOW_COPY_AND_ASSIGN(UIResourceBitmap); | 50 DISALLOW_COPY_AND_ASSIGN(UIResourceBitmap); |
| 46 }; | 51 }; |
| 47 | 52 |
| 48 } // namespace cc | 53 } // namespace cc |
| 49 | 54 |
| 50 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ | 55 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
| OLD | NEW |