Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: cc/resources/ui_resource_bitmap.h

Issue 27973002: cc: Adding ETC1 support to UIResourceBitmap and ResourceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "skia/ext/refptr.h" 11 #include "skia/ext/refptr.h"
12 #include "third_party/skia/include/core/SkPixelRef.h" 12 #include "third_party/skia/include/core/SkPixelRef.h"
13 #include "third_party/skia/include/core/SkTypes.h" 13 #include "third_party/skia/include/core/SkTypes.h"
14 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
15 15
16 class SkBitmap; 16 class SkBitmap;
17 17
18 namespace cc { 18 namespace cc {
19 19
20 // A bitmap class that contains a ref-counted reference to a SkPixelRef* that 20 // A bitmap class that contains a ref-counted reference to a SkPixelRef* that
21 // holds the content of the bitmap (cannot use SkBitmap because of ETC1). 21 // holds the content of the bitmap (cannot use SkBitmap because of ETC1).
22 // Thread-safety (by ways of SkPixelRef) ensures that both main and impl threads 22 // Thread-safety (by ways of SkPixelRef) ensures that both main and impl threads
23 // can hold references to the bitmap and that asynchronous uploads are allowed. 23 // can hold references to the bitmap and that asynchronous uploads are allowed.
24 class CC_EXPORT UIResourceBitmap { 24 class CC_EXPORT UIResourceBitmap {
25 public: 25 public:
26 enum UIResourceFormat { 26 enum UIResourceFormat {
27 RGBA8 27 RGBA8,
28 ETC1
28 }; 29 };
29 enum UIResourceWrapMode { 30 enum UIResourceWrapMode {
30 CLAMP_TO_EDGE, 31 CLAMP_TO_EDGE,
31 REPEAT 32 REPEAT
32 }; 33 };
33 34
34 gfx::Size GetSize() const { return size_; } 35 gfx::Size GetSize() const { return size_; }
35 UIResourceFormat GetFormat() const { return format_; } 36 UIResourceFormat GetFormat() const { return format_; }
36 UIResourceWrapMode GetWrapMode() const { return wrap_mode_; } 37 UIResourceWrapMode GetWrapMode() const { return wrap_mode_; }
37 38
38 // The constructor for the UIResourceBitmap. User must ensure that |skbitmap| 39 // The constructor for the UIResourceBitmap. User must ensure that |skbitmap|
39 // is immutable. The SkBitmap format should be in 32-bit RGBA. Wrap mode is 40 // is immutable. The SkBitmap format should be in 32-bit RGBA. Wrap mode is
40 // unnecessary for most UI resources and is defaulted to CLAMP_TO_EDGE. 41 // unnecessary for most UI resources and is defaulted to CLAMP_TO_EDGE.
41 UIResourceBitmap(const SkBitmap& skbitmap, 42 UIResourceBitmap(const SkBitmap& skbitmap,
42 UIResourceWrapMode wrap_mode = CLAMP_TO_EDGE); 43 UIResourceWrapMode wrap_mode = CLAMP_TO_EDGE);
43 44
45 UIResourceBitmap(const skia::RefPtr<SkPixelRef>& pixel_ref,
46 UIResourceFormat format,
47 UIResourceWrapMode wrap_mode,
aelias_OOO_until_Jul13 2013/10/18 01:59:24 Could you move wrap_mode out of the constructors a
powei 2013/10/23 05:36:15 Done.
48 gfx::Size size);
49
44 ~UIResourceBitmap(); 50 ~UIResourceBitmap();
45 51
46 private: 52 private:
47 friend class AutoLockUIResourceBitmap; 53 friend class AutoLockUIResourceBitmap;
48 void Create(const skia::RefPtr<SkPixelRef>& pixel_ref, 54 void Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
49 UIResourceFormat format, 55 UIResourceFormat format,
50 UIResourceWrapMode wrap_mode, 56 UIResourceWrapMode wrap_mode,
51 gfx::Size size); 57 gfx::Size size);
52 58
53 skia::RefPtr<SkPixelRef> pixel_ref_; 59 skia::RefPtr<SkPixelRef> pixel_ref_;
54 UIResourceFormat format_; 60 UIResourceFormat format_;
55 UIResourceWrapMode wrap_mode_; 61 UIResourceWrapMode wrap_mode_;
56 gfx::Size size_; 62 gfx::Size size_;
57 }; 63 };
58 64
59 class CC_EXPORT AutoLockUIResourceBitmap { 65 class CC_EXPORT AutoLockUIResourceBitmap {
60 public: 66 public:
61 explicit AutoLockUIResourceBitmap(const UIResourceBitmap& bitmap); 67 explicit AutoLockUIResourceBitmap(const UIResourceBitmap& bitmap);
62 ~AutoLockUIResourceBitmap(); 68 ~AutoLockUIResourceBitmap();
63 const uint8_t* GetPixels() const; 69 const uint8_t* GetPixels() const;
64 70
65 private: 71 private:
66 const UIResourceBitmap& bitmap_; 72 const UIResourceBitmap& bitmap_;
67 }; 73 };
68 74
69 } // namespace cc 75 } // namespace cc
70 76
71 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ 77 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698