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

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

Issue 2293573002: Add tinted static UI resource cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up Created 4 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 <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; }
41 void Draw(SkCanvas& canvas, SkPaint& paint);
39 42
40 // User must ensure that |skbitmap| is immutable. The SkBitmap Format should 43 // User must ensure that |skbitmap| is immutable. The SkBitmap Format should
41 // be 32-bit RGBA or 8-bit ALPHA. 44 // be 32-bit RGBA or 8-bit ALPHA.
42 explicit UIResourceBitmap(const SkBitmap& skbitmap); 45 explicit UIResourceBitmap(const SkBitmap& skbitmap);
43 UIResourceBitmap(const gfx::Size& size, bool is_opaque); 46 UIResourceBitmap(const gfx::Size& size, bool is_opaque);
44 UIResourceBitmap(sk_sp<SkPixelRef> pixel_ref, const gfx::Size& size); 47 UIResourceBitmap(sk_sp<SkPixelRef> pixel_ref, const gfx::Size& size);
45 UIResourceBitmap(const UIResourceBitmap& other); 48 UIResourceBitmap(const UIResourceBitmap& other);
46 ~UIResourceBitmap(); 49 ~UIResourceBitmap();
47 50
48 private: 51 private:
(...skipping 15 matching lines...) Expand all
64 ~AutoLockUIResourceBitmap(); 67 ~AutoLockUIResourceBitmap();
65 const uint8_t* GetPixels() const; 68 const uint8_t* GetPixels() const;
66 69
67 private: 70 private:
68 const UIResourceBitmap& bitmap_; 71 const UIResourceBitmap& bitmap_;
69 }; 72 };
70 73
71 } // namespace cc 74 } // namespace cc
72 75
73 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_ 76 #endif // CC_RESOURCES_UI_RESOURCE_BITMAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698