| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "third_party/skia/include/core/SkCanvas.h" |
| 14 #include "third_party/skia/include/core/SkPixelRef.h" | 16 #include "third_party/skia/include/core/SkPixelRef.h" |
| 15 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 16 | 18 |
| 17 class SkBitmap; | 19 class SkBitmap; |
| 18 | 20 |
| 19 namespace cc { | 21 namespace cc { |
| 20 | 22 |
| 21 class ETC1PixelRef; | 23 class ETC1PixelRef; |
| 22 | 24 |
| 23 // A bitmap class that contains a ref-counted reference to a SkPixelRef that | 25 // A bitmap class that contains a ref-counted reference to a SkPixelRef that |
| 24 // holds the content of the bitmap (cannot use SkBitmap because of ETC1). | 26 // holds the content of the bitmap (cannot use SkBitmap because of ETC1). |
| 25 // Thread-safety (by ways of SkPixelRef) ensures that both main and impl threads | 27 // Thread-safety (by ways of SkPixelRef) ensures that both main and impl threads |
| 26 // can hold references to the bitmap and that asynchronous uploads are allowed. | 28 // can hold references to the bitmap and that asynchronous uploads are allowed. |
| 27 class CC_EXPORT UIResourceBitmap { | 29 class CC_EXPORT UIResourceBitmap { |
| 28 public: | 30 public: |
| 29 enum UIResourceFormat { | 31 enum UIResourceFormat { |
| 30 RGBA8, | 32 RGBA8, |
| 31 ALPHA_8, | 33 ALPHA_8, |
| 32 ETC1 | 34 ETC1 |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 gfx::Size GetSize() const { return size_; } | 37 gfx::Size GetSize() const { return size_; } |
| 36 UIResourceFormat GetFormat() const { return format_; } | 38 UIResourceFormat GetFormat() const { return format_; } |
| 37 bool GetOpaque() const { return opaque_; } | 39 bool GetOpaque() const { return opaque_; } |
| 38 void SetOpaque(bool opaque) { opaque_ = opaque; } | 40 void SetOpaque(bool opaque) { opaque_ = opaque; } |
| 39 | 41 |
| 42 // Draw the UIResourceBitmap onto the provided |canvas| using the style |
| 43 // information specified by |paint|. |
| 44 void DrawToCanvas(SkCanvas* canvas, SkPaint* paint); |
| 45 |
| 40 // User must ensure that |skbitmap| is immutable. The SkBitmap Format should | 46 // User must ensure that |skbitmap| is immutable. The SkBitmap Format should |
| 41 // be 32-bit RGBA or 8-bit ALPHA. | 47 // be 32-bit RGBA or 8-bit ALPHA. |
| 42 explicit UIResourceBitmap(const SkBitmap& skbitmap); | 48 explicit UIResourceBitmap(const SkBitmap& skbitmap); |
| 43 UIResourceBitmap(const gfx::Size& size, bool is_opaque); | 49 UIResourceBitmap(const gfx::Size& size, bool is_opaque); |
| 44 UIResourceBitmap(sk_sp<SkPixelRef> pixel_ref, const gfx::Size& size); | 50 UIResourceBitmap(sk_sp<SkPixelRef> pixel_ref, const gfx::Size& size); |
| 45 UIResourceBitmap(const UIResourceBitmap& other); | 51 UIResourceBitmap(const UIResourceBitmap& other); |
| 46 ~UIResourceBitmap(); | 52 ~UIResourceBitmap(); |
| 47 | 53 |
| 48 private: | 54 private: |
| 49 friend class AutoLockUIResourceBitmap; | 55 friend class AutoLockUIResourceBitmap; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 64 ~AutoLockUIResourceBitmap(); | 70 ~AutoLockUIResourceBitmap(); |
| 65 const uint8_t* GetPixels() const; | 71 const uint8_t* GetPixels() const; |
| 66 | 72 |
| 67 private: | 73 private: |
| 68 const UIResourceBitmap& bitmap_; | 74 const UIResourceBitmap& bitmap_; |
| 69 }; | 75 }; |
| 70 | 76 |
| 71 } // namespace cc | 77 } // namespace cc |
| 72 | 78 |
| 73 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ | 79 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ |
| OLD | NEW |