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

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

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 7 years, 3 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
« no previous file with comments | « cc/resources/scoped_ui_resource.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"
12 #include "third_party/skia/include/core/SkPixelRef.h"
11 #include "third_party/skia/include/core/SkTypes.h" 13 #include "third_party/skia/include/core/SkTypes.h"
12 #include "ui/gfx/size.h" 14 #include "ui/gfx/size.h"
13 15
16 class SkBitmap;
17
14 namespace cc { 18 namespace cc {
15 19
16 // Ref-counted bitmap class (can’t use SkBitmap because of ETC1). Thread-safety 20 // A bitmap class that contains a ref-counted reference to a SkPixelRef* that
17 // ensures that both main and impl threads can hold references to the bitmap and 21 // holds the content of the bitmap (cannot use SkBitmap because of ETC1).
18 // that asynchronous uploads are allowed. 22 // Thread-safety (by ways of SkPixelRef) ensures that both main and impl threads
19 class CC_EXPORT UIResourceBitmap 23 // can hold references to the bitmap and that asynchronous uploads are allowed.
20 : public base::RefCountedThreadSafe<UIResourceBitmap> { 24 class CC_EXPORT UIResourceBitmap {
21 public: 25 public:
22 enum UIResourceFormat { 26 enum UIResourceFormat {
23 RGBA8 27 RGBA8
24 }; 28 };
25 enum UIResourceWrapMode { 29 enum UIResourceWrapMode {
26 CLAMP_TO_EDGE, 30 CLAMP_TO_EDGE,
27 REPEAT 31 REPEAT
28 }; 32 };
29 33
30 // Takes ownership of “pixels”.
31 static scoped_refptr<UIResourceBitmap> Create(uint8_t* pixels,
32 UIResourceFormat format,
33 UIResourceWrapMode wrap_mode,
34 gfx::Size size);
35
36 gfx::Size GetSize() const { return size_; } 34 gfx::Size GetSize() const { return size_; }
37 UIResourceFormat GetFormat() const { return format_; } 35 UIResourceFormat GetFormat() const { return format_; }
38 UIResourceWrapMode GetWrapMode() const { return wrap_mode_; } 36 UIResourceWrapMode GetWrapMode() const { return wrap_mode_; }
39 uint8_t* GetPixels() { return pixels_.get(); } 37 uint8_t* GetPixels() const;
38
39 // The constructor for the UIResourceBitmap. User must ensure that |skbitmap|
40 // is immutable. The SkBitmap format should be in 32-bit RGBA. Wrap mode is
41 // unnecessary for most UI resources and is defaulted to CLAMP_TO_EDGE.
42 UIResourceBitmap(const SkBitmap& skbitmap,
43 UIResourceWrapMode wrap_mode = CLAMP_TO_EDGE);
44
45 ~UIResourceBitmap();
40 46
41 private: 47 private:
42 friend class base::RefCountedThreadSafe<UIResourceBitmap>; 48 void Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
49 UIResourceFormat format,
50 UIResourceWrapMode wrap_mode,
51 gfx::Size size);
43 52
44 UIResourceBitmap(); 53 skia::RefPtr<SkPixelRef> pixel_ref_;
45 ~UIResourceBitmap();
46
47 scoped_ptr<uint8_t[]> pixels_;
48 UIResourceFormat format_; 54 UIResourceFormat format_;
49 UIResourceWrapMode wrap_mode_; 55 UIResourceWrapMode wrap_mode_;
50 gfx::Size size_; 56 gfx::Size size_;
51
52 DISALLOW_COPY_AND_ASSIGN(UIResourceBitmap);
53 }; 57 };
54 58
55 } // namespace cc 59 } // namespace cc
56 60
57 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ 61 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_
OLDNEW
« no previous file with comments | « cc/resources/scoped_ui_resource.cc ('k') | cc/resources/ui_resource_bitmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698