Chromium Code Reviews| 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/SkPixelRef.h" | |
| 11 #include "third_party/skia/include/core/SkTypes.h" | 12 #include "third_party/skia/include/core/SkTypes.h" |
| 12 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
| 13 | 14 |
| 15 class SkBitmap; | |
| 16 | |
| 14 namespace cc { | 17 namespace cc { |
| 15 | 18 |
| 16 // Ref-counted bitmap class (can’t use SkBitmap because of ETC1). Thread-safety | 19 // 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 | 20 // ensures that both main and impl threads can hold references to the bitmap and |
| 18 // that asynchronous uploads are allowed. | 21 // that asynchronous uploads are allowed. |
| 19 class CC_EXPORT UIResourceBitmap | 22 class CC_EXPORT UIResourceBitmap { |
| 20 : public base::RefCountedThreadSafe<UIResourceBitmap> { | |
| 21 public: | 23 public: |
| 22 enum UIResourceFormat { | 24 enum UIResourceFormat { |
| 23 RGBA8 | 25 RGBA8, |
| 26 INVALID_FORMAT | |
| 24 }; | 27 }; |
| 25 | 28 |
| 26 // Takes ownership of “pixels”. | |
| 27 static scoped_refptr<UIResourceBitmap> Create(uint8_t* pixels, | |
| 28 UIResourceFormat format, | |
| 29 gfx::Size size); | |
| 30 | |
| 31 gfx::Size GetSize() const { return size_; } | 29 gfx::Size GetSize() const { return size_; } |
| 32 UIResourceFormat GetFormat() const { return format_; } | 30 UIResourceFormat GetFormat() const { return format_; } |
| 33 uint8_t* GetPixels() { return pixels_.get(); } | 31 uint8_t* GetPixels() const; |
| 32 | |
| 33 UIResourceBitmap(SkPixelRef* pixel_ref, | |
|
danakj
2013/09/05 19:23:38
Is this passing ownership with a raw pointer? If s
powei
2013/09/05 20:37:35
SkPixelRef is ref-counted, so this is not taking o
danakj
2013/09/05 20:38:57
Please use skia::RefPtr, and skia::AdoptRef() a re
powei
2013/09/05 21:34:08
Done. Thanks for letting me know. This is much b
| |
| 34 UIResourceFormat format, | |
| 35 gfx::Size size); | |
| 36 | |
| 37 explicit UIResourceBitmap(const SkBitmap& skbitmap); | |
| 38 | |
| 39 UIResourceBitmap(const UIResourceBitmap& src); | |
| 40 | |
| 41 UIResourceBitmap& operator=(const UIResourceBitmap& src); | |
| 42 | |
| 43 explicit UIResourceBitmap(); | |
| 44 | |
| 45 ~UIResourceBitmap(); | |
| 34 | 46 |
| 35 private: | 47 private: |
| 36 friend class base::RefCountedThreadSafe<UIResourceBitmap>; | 48 void Create(SkPixelRef* pixel_ref, UIResourceFormat format, gfx::Size size); |
| 37 | 49 |
| 38 UIResourceBitmap(); | 50 SkPixelRef* pixel_ref_; |
|
jdduke (slow)
2013/09/05 18:39:53
Hmm, if we're going to use an SkPixelRef backing,
aelias_OOO_until_Jul13
2013/09/05 18:42:32
No, because we intend to support ETC1 compressed b
jdduke (slow)
2013/09/05 18:51:05
I see, though I wasn't proposing we expose the SkB
powei
2013/09/05 20:37:35
I'm a little worried that might cause some confusi
aelias_OOO_until_Jul13
2013/09/06 04:17:37
I think SkPixelRef is the right level of abstracti
| |
| 39 ~UIResourceBitmap(); | |
| 40 | |
| 41 scoped_ptr<uint8_t[]> pixels_; | |
| 42 UIResourceFormat format_; | 51 UIResourceFormat format_; |
| 43 gfx::Size size_; | 52 gfx::Size size_; |
| 44 | |
| 45 DISALLOW_COPY_AND_ASSIGN(UIResourceBitmap); | |
| 46 }; | 53 }; |
| 47 | 54 |
| 48 } // namespace cc | 55 } // namespace cc |
| 49 | 56 |
| 50 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ | 57 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
| OLD | NEW |