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

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

Issue 18191020: UI Resource Manager (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_RESOURCES_UI_RESOURCE_MANAGER_H_
6 #define CC_RESOURCES_UI_RESOURCE_MANAGER_H_
7
8
9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "skia/ext/refptr.h"
13 #include "ui/gfx/size.h"
14
15 namespace cc {
16
17 typedef int UIResourceId;
18
19 class UIResourceManagerClient {
20 public:
21 enum UIResourceStatus {
22 NOT_READY,
23 READY,
24 LOST
25 };
26
27 virtual ~UIResourceManagerClient() {}
28
29 // This is called on the main thread when a recently created resource
30 // has been fully uploaded to a texture. Users of large resources may
31 // wish to wait for this callback before using the resource ID on a layer,
32 // to avoid jank until the upload completes.
33 virtual void UIResourceReady(UIResourceId id) = 0;
34
35 // This id is now invalid. The client is expected to keep track of all
36 // layers that were using it, and change them to stop using it (for
37 // example by calling CreateUIResource and assigning the new id to the
38 // layer).
39 virtual void UIResourceLost(UIResourceId id) = 0;
40 };
41
42 // Ref-counted bitmap class (can’t use SkBitmap because of ETC1)
43 class UIResourceBitmap : public base::RefCountedThreadSafe<UIResourceBitmap> {
44 public:
45 enum UIResourceFormat {
46 RGBA8,
47 ETC1
48 };
49
50 ~UIResourceBitmap();
51
52 // Takes ownership of “pixels”.
53 static scoped_refptr<UIResourceBitmap> Create(void* pixels,
54 UIResourceFormat format,
55 gfx::Size size);
56
57 gfx::Size GetSize() const { return size_; }
58 UIResourceFormat GetFormat() const { return format_; }
59 void* GetPixels() { return pixels_; }
60
61 private:
62 void* pixels_;
63 UIResourceFormat format_;
64 gfx::Size size_;
65 };
66
67 } // namespace cc
68
69 #endif // CC_RESOURCES_UI_RESOURCE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698