OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
| 6 #define CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "ui/gfx/size.h" |
| 10 |
| 11 namespace cc { |
| 12 |
| 13 // Ref-counted bitmap class (can’t use SkBitmap because of ETC1). Thread-safety |
| 14 // ensures that both main and impl threads can hold references to the bitmap and |
| 15 // that asynchronous uploads using the bitmap will not cause crashes. |
| 16 class UIResourceBitmap : public base::RefCountedThreadSafe<UIResourceBitmap> { |
| 17 public: |
| 18 enum UIResourceFormat { |
| 19 RGBA8 |
| 20 }; |
| 21 |
| 22 // Takes ownership of “pixels”. |
| 23 static scoped_refptr<UIResourceBitmap> Create(uint8_t* pixels, |
| 24 UIResourceFormat format, |
| 25 gfx::Size size); |
| 26 |
| 27 gfx::Size GetSize() const { return size_; } |
| 28 UIResourceFormat GetFormat() const { return format_; } |
| 29 uint8_t* GetPixels() { return pixels_.get(); } |
| 30 |
| 31 private: |
| 32 scoped_ptr<uint8_t[]> pixels_; |
| 33 UIResourceFormat format_; |
| 34 gfx::Size size_; |
| 35 }; |
| 36 |
| 37 } // namespace cc |
| 38 |
| 39 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
OLD | NEW |