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

Side by Side Diff: cc/prioritized_texture.h

Issue 11266030: Use gfx:: Geometry types for the resource provider and layer updater classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: uint8 Created 8 years, 1 month 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/layer_updater.h ('k') | cc/prioritized_texture.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 CCPrioritizedTexture_h 5 #ifndef CCPrioritizedTexture_h
6 #define CCPrioritizedTexture_h 6 #define CCPrioritizedTexture_h
7 7
8 #include "IntRect.h"
9 #include "IntSize.h"
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
11 #include "base/logging.h" 9 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
13 #include "cc/priority_calculator.h" 11 #include "cc/priority_calculator.h"
14 #include "cc/resource_provider.h" 12 #include "cc/resource_provider.h"
15 #include "cc/texture.h" 13 #include "cc/texture.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/size.h"
16 #include "ui/gfx/vector2d.h"
16 #include "third_party/khronos/GLES2/gl2.h" 17 #include "third_party/khronos/GLES2/gl2.h"
17 18
18 namespace cc { 19 namespace cc {
19 20
20 class PrioritizedTextureManager; 21 class PrioritizedTextureManager;
21 22
22 class PrioritizedTexture { 23 class PrioritizedTexture {
23 public: 24 public:
24 static scoped_ptr<PrioritizedTexture> create(PrioritizedTextureManager* mana ger, IntSize size, GLenum format) 25 static scoped_ptr<PrioritizedTexture> create(PrioritizedTextureManager* mana ger, gfx::Size size, GLenum format)
25 { 26 {
26 return make_scoped_ptr(new PrioritizedTexture(manager, size, format)); 27 return make_scoped_ptr(new PrioritizedTexture(manager, size, format));
27 } 28 }
28 static scoped_ptr<PrioritizedTexture> create(PrioritizedTextureManager* mana ger) 29 static scoped_ptr<PrioritizedTexture> create(PrioritizedTextureManager* mana ger)
29 { 30 {
30 return make_scoped_ptr(new PrioritizedTexture(manager, IntSize(), 0)); 31 return make_scoped_ptr(new PrioritizedTexture(manager, gfx::Size(), 0));
31 } 32 }
32 ~PrioritizedTexture(); 33 ~PrioritizedTexture();
33 34
34 // Texture properties. Changing these causes the backing texture to be lost. 35 // Texture properties. Changing these causes the backing texture to be lost.
35 // Setting these to the same value is a no-op. 36 // Setting these to the same value is a no-op.
36 void setTextureManager(PrioritizedTextureManager*); 37 void setTextureManager(PrioritizedTextureManager*);
37 PrioritizedTextureManager* textureManager() { return m_manager; } 38 PrioritizedTextureManager* textureManager() { return m_manager; }
38 void setDimensions(IntSize, GLenum format); 39 void setDimensions(gfx::Size, GLenum format);
39 GLenum format() const { return m_format; } 40 GLenum format() const { return m_format; }
40 IntSize size() const { return m_size; } 41 gfx::Size size() const { return m_size; }
41 size_t bytes() const { return m_bytes; } 42 size_t bytes() const { return m_bytes; }
42 bool contentsSwizzled() const { return m_contentsSwizzled; } 43 bool contentsSwizzled() const { return m_contentsSwizzled; }
43 44
44 // Set priority for the requested texture. 45 // Set priority for the requested texture.
45 void setRequestPriority(int priority) { m_priority = priority; } 46 void setRequestPriority(int priority) { m_priority = priority; }
46 int requestPriority() const { return m_priority; } 47 int requestPriority() const { return m_priority; }
47 48
48 // After PrioritizedTexture::prioritizeTextures() is called, this returns 49 // After PrioritizedTexture::prioritizeTextures() is called, this returns
49 // if the the request succeeded and this texture can be acquired for use. 50 // if the the request succeeded and this texture can be acquired for use.
50 bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; } 51 bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; }
(...skipping 13 matching lines...) Expand all
64 // FIXME: Request late is really a hack for when we are totally out of memor y 65 // FIXME: Request late is really a hack for when we are totally out of memor y
65 // (all textures are visible) but we can still squeeze into the limit 66 // (all textures are visible) but we can still squeeze into the limit
66 // by not painting occluded textures. In this case the manager 67 // by not painting occluded textures. In this case the manager
67 // refuses all visible textures and requestLate() will enable 68 // refuses all visible textures and requestLate() will enable
68 // canAcquireBackingTexture() on a call-order basis. We might want to 69 // canAcquireBackingTexture() on a call-order basis. We might want to
69 // just remove this in the future (carefully) and just make sure we d on't 70 // just remove this in the future (carefully) and just make sure we d on't
70 // regress OOMs situations. 71 // regress OOMs situations.
71 bool requestLate(); 72 bool requestLate();
72 73
73 // Uploads pixels into the backing resource. This functions will aquire the backing if needed. 74 // Uploads pixels into the backing resource. This functions will aquire the backing if needed.
74 void upload(ResourceProvider*, const uint8_t* image, const IntRect& imageRec t, const IntRect& sourceRect, const IntSize& destOffset); 75 void upload(ResourceProvider*, const uint8_t* image, const gfx::Rect& imageR ect, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset);
75 76
76 ResourceProvider::ResourceId resourceId() const; 77 ResourceProvider::ResourceId resourceId() const;
77 78
78 // Self-managed textures are accounted for when prioritizing other textures, 79 // Self-managed textures are accounted for when prioritizing other textures,
79 // but they are not allocated/recycled/deleted, so this needs to be done 80 // but they are not allocated/recycled/deleted, so this needs to be done
80 // externally. canAcquireBackingTexture() indicates if the texture would hav e 81 // externally. canAcquireBackingTexture() indicates if the texture would hav e
81 // been allowed given its priority. 82 // been allowed given its priority.
82 void setIsSelfManaged(bool isSelfManaged) { m_isSelfManaged = isSelfManaged; } 83 void setIsSelfManaged(bool isSelfManaged) { m_isSelfManaged = isSelfManaged; }
83 bool isSelfManaged() { return m_isSelfManaged; } 84 bool isSelfManaged() { return m_isSelfManaged; }
84 void setToSelfManagedMemoryPlaceholder(size_t bytes); 85 void setToSelfManagedMemoryPlaceholder(size_t bytes);
85 86
86 void returnBackingTexture(); 87 void returnBackingTexture();
87 88
88 private: 89 private:
89 friend class PrioritizedTextureManager; 90 friend class PrioritizedTextureManager;
90 friend class PrioritizedTextureTest; 91 friend class PrioritizedTextureTest;
91 92
92 class Backing : public Texture { 93 class Backing : public Texture {
93 public: 94 public:
94 Backing(unsigned id, ResourceProvider*, IntSize, GLenum format); 95 Backing(unsigned id, ResourceProvider*, gfx::Size, GLenum format);
95 ~Backing(); 96 ~Backing();
96 void updatePriority(); 97 void updatePriority();
97 void updateInDrawingImplTree(); 98 void updateInDrawingImplTree();
98 99
99 PrioritizedTexture* owner() { return m_owner; } 100 PrioritizedTexture* owner() { return m_owner; }
100 bool canBeRecycled() const; 101 bool canBeRecycled() const;
101 int requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLas tPriorityUpdate; } 102 int requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLas tPriorityUpdate; }
102 bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAb ovePriorityCutoffAtLastPriorityUpdate; } 103 bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAb ovePriorityCutoffAtLastPriorityUpdate; }
103 bool inDrawingImplTree() const { return m_inDrawingImplTree; } 104 bool inDrawingImplTree() const { return m_inDrawingImplTree; }
104 105
(...skipping 10 matching lines...) Expand all
115 bool m_inDrawingImplTree; 116 bool m_inDrawingImplTree;
116 117
117 bool m_resourceHasBeenDeleted; 118 bool m_resourceHasBeenDeleted;
118 #ifndef NDEBUG 119 #ifndef NDEBUG
119 ResourceProvider* m_resourceProvider; 120 ResourceProvider* m_resourceProvider;
120 #endif 121 #endif
121 122
122 DISALLOW_COPY_AND_ASSIGN(Backing); 123 DISALLOW_COPY_AND_ASSIGN(Backing);
123 }; 124 };
124 125
125 PrioritizedTexture(PrioritizedTextureManager*, IntSize, GLenum format); 126 PrioritizedTexture(PrioritizedTextureManager*, gfx::Size, GLenum format);
126 127
127 bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; } 128 bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; }
128 void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityC utoff = isAbovePriorityCutoff; } 129 void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityC utoff = isAbovePriorityCutoff; }
129 void setManagerInternal(PrioritizedTextureManager* manager) { m_manager = ma nager; } 130 void setManagerInternal(PrioritizedTextureManager* manager) { m_manager = ma nager; }
130 131
131 Backing* backing() const { return m_backing; } 132 Backing* backing() const { return m_backing; }
132 void link(Backing*); 133 void link(Backing*);
133 void unlink(); 134 void unlink();
134 135
135 IntSize m_size; 136 gfx::Size m_size;
136 GLenum m_format; 137 GLenum m_format;
137 size_t m_bytes; 138 size_t m_bytes;
138 bool m_contentsSwizzled; 139 bool m_contentsSwizzled;
139 140
140 int m_priority; 141 int m_priority;
141 bool m_isAbovePriorityCutoff; 142 bool m_isAbovePriorityCutoff;
142 bool m_isSelfManaged; 143 bool m_isSelfManaged;
143 144
144 Backing* m_backing; 145 Backing* m_backing;
145 PrioritizedTextureManager* m_manager; 146 PrioritizedTextureManager* m_manager;
146 147
147 DISALLOW_COPY_AND_ASSIGN(PrioritizedTexture); 148 DISALLOW_COPY_AND_ASSIGN(PrioritizedTexture);
148 }; 149 };
149 150
150 } // namespace cc 151 } // namespace cc
151 152
152 #endif 153 #endif
OLDNEW
« no previous file with comments | « cc/layer_updater.h ('k') | cc/prioritized_texture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698