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

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: latest comments 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
« no previous file with comments | « cc/resources/resource_provider_unittest.cc ('k') | cc/resources/ui_resource_bitmap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_; }
38 void SetWrapMode(UIResourceWrapMode wrap_mode) { wrap_mode_ = wrap_mode; }
37 39
38 // The constructor for the UIResourceBitmap. User must ensure that |skbitmap| 40 // 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 41 // 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. 42 // unnecessary for most UI resources and is defaulted to CLAMP_TO_EDGE.
41 UIResourceBitmap(const SkBitmap& skbitmap, 43 explicit UIResourceBitmap(const SkBitmap& skbitmap);
42 UIResourceWrapMode wrap_mode = CLAMP_TO_EDGE); 44
45 UIResourceBitmap(const skia::RefPtr<SkPixelRef>& pixel_ref,
46 UIResourceFormat format,
47 gfx::Size size);
43 48
44 ~UIResourceBitmap(); 49 ~UIResourceBitmap();
45 50
46 private: 51 private:
47 friend class AutoLockUIResourceBitmap; 52 friend class AutoLockUIResourceBitmap;
48 void Create(const skia::RefPtr<SkPixelRef>& pixel_ref, 53 void Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
49 UIResourceFormat format, 54 UIResourceFormat format,
50 UIResourceWrapMode wrap_mode,
51 gfx::Size size); 55 gfx::Size size);
52 56
53 skia::RefPtr<SkPixelRef> pixel_ref_; 57 skia::RefPtr<SkPixelRef> pixel_ref_;
54 UIResourceFormat format_; 58 UIResourceFormat format_;
55 UIResourceWrapMode wrap_mode_; 59 UIResourceWrapMode wrap_mode_;
56 gfx::Size size_; 60 gfx::Size size_;
57 }; 61 };
58 62
59 class CC_EXPORT AutoLockUIResourceBitmap { 63 class CC_EXPORT AutoLockUIResourceBitmap {
60 public: 64 public:
61 explicit AutoLockUIResourceBitmap(const UIResourceBitmap& bitmap); 65 explicit AutoLockUIResourceBitmap(const UIResourceBitmap& bitmap);
62 ~AutoLockUIResourceBitmap(); 66 ~AutoLockUIResourceBitmap();
63 const uint8_t* GetPixels() const; 67 const uint8_t* GetPixels() const;
64 68
65 private: 69 private:
66 const UIResourceBitmap& bitmap_; 70 const UIResourceBitmap& bitmap_;
67 }; 71 };
68 72
69 } // namespace cc 73 } // namespace cc
70 74
71 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ 75 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_
OLDNEW
« no previous file with comments | « cc/resources/resource_provider_unittest.cc ('k') | cc/resources/ui_resource_bitmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698