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

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: changed from raw SkPixelRef pointers to skia::RefPtr<SkPixelRef> 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
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 // 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 21 // ensures that both main and impl threads can hold references to the bitmap and
18 // that asynchronous uploads are allowed. 22 // that asynchronous uploads are allowed.
19 class CC_EXPORT UIResourceBitmap 23 class CC_EXPORT UIResourceBitmap {
20 : public base::RefCountedThreadSafe<UIResourceBitmap> {
21 public: 24 public:
22 enum UIResourceFormat { 25 enum UIResourceFormat {
23 RGBA8 26 RGBA8,
27 INVALID_FORMAT
24 }; 28 };
25 29
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_; } 30 gfx::Size GetSize() const { return size_; }
32 UIResourceFormat GetFormat() const { return format_; } 31 UIResourceFormat GetFormat() const { return format_; }
33 uint8_t* GetPixels() { return pixels_.get(); } 32 uint8_t* GetPixels() const;
33
34 explicit UIResourceBitmap(const SkBitmap& skbitmap);
35
36 UIResourceBitmap(const UIResourceBitmap& src);
37
38 UIResourceBitmap& operator=(const UIResourceBitmap& src);
39
40 explicit UIResourceBitmap();
aelias_OOO_until_Jul13 2013/09/06 04:17:38 Can we get rid of this default constructor and the
powei 2013/09/09 17:57:18 Done.
41
42 ~UIResourceBitmap();
34 43
35 private: 44 private:
36 friend class base::RefCountedThreadSafe<UIResourceBitmap>; 45 void Create(const skia::RefPtr<SkPixelRef>& pixel_ref,
46 UIResourceFormat format,
47 gfx::Size size);
37 48
38 UIResourceBitmap(); 49 skia::RefPtr<SkPixelRef> pixel_ref_;
39 ~UIResourceBitmap();
40
41 scoped_ptr<uint8_t[]> pixels_;
42 UIResourceFormat format_; 50 UIResourceFormat format_;
43 gfx::Size size_; 51 gfx::Size size_;
44
45 DISALLOW_COPY_AND_ASSIGN(UIResourceBitmap);
46 }; 52 };
47 53
48 } // namespace cc 54 } // namespace cc
49 55
50 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ 56 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698