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

Side by Side Diff: cc/resources/prioritized_resource.cc

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed a signed vs. unsigned comparison in video_resource_updater.cc 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/prioritized_resource.h ('k') | cc/resources/prioritized_resource_manager.h » ('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 #include "cc/resources/prioritized_resource.h" 5 #include "cc/resources/prioritized_resource.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "cc/resources/platform_color.h" 9 #include "cc/resources/platform_color.h"
10 #include "cc/resources/prioritized_resource_manager.h" 10 #include "cc/resources/prioritized_resource_manager.h"
11 #include "cc/resources/priority_calculator.h" 11 #include "cc/resources/priority_calculator.h"
12 #include "cc/trees/proxy.h" 12 #include "cc/trees/proxy.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 PrioritizedResource::PrioritizedResource(PrioritizedResourceManager* manager, 16 PrioritizedResource::PrioritizedResource(PrioritizedResourceManager* manager,
17 gfx::Size size, 17 gfx::Size size,
18 GLenum format) 18 ResourceFormat format)
19 : size_(size), 19 : size_(size),
20 format_(format), 20 format_(format),
21 bytes_(0), 21 bytes_(0),
22 contents_swizzled_(false), 22 contents_swizzled_(false),
23 priority_(PriorityCalculator::LowestPriority()), 23 priority_(PriorityCalculator::LowestPriority()),
24 is_above_priority_cutoff_(false), 24 is_above_priority_cutoff_(false),
25 is_self_managed_(false), 25 is_self_managed_(false),
26 backing_(NULL), 26 backing_(NULL),
27 manager_(NULL) { 27 manager_(NULL) {
28 // manager_ is set in RegisterTexture() so validity can be checked. 28 bytes_ = Resource::MemorySizeBytes(size, format);
29 DCHECK(format || size.IsEmpty());
30 if (format)
31 bytes_ = Resource::MemorySizeBytes(size, format);
32 if (manager) 29 if (manager)
33 manager->RegisterTexture(this); 30 manager->RegisterTexture(this);
34 } 31 }
35 32
36 PrioritizedResource::~PrioritizedResource() { 33 PrioritizedResource::~PrioritizedResource() {
37 if (manager_) 34 if (manager_)
38 manager_->UnregisterTexture(this); 35 manager_->UnregisterTexture(this);
39 } 36 }
40 37
41 void PrioritizedResource::SetTextureManager( 38 void PrioritizedResource::SetTextureManager(
42 PrioritizedResourceManager* manager) { 39 PrioritizedResourceManager* manager) {
43 if (manager_ == manager) 40 if (manager_ == manager)
44 return; 41 return;
45 if (manager_) 42 if (manager_)
46 manager_->UnregisterTexture(this); 43 manager_->UnregisterTexture(this);
47 if (manager) 44 if (manager)
48 manager->RegisterTexture(this); 45 manager->RegisterTexture(this);
49 } 46 }
50 47
51 void PrioritizedResource::SetDimensions(gfx::Size size, GLenum format) { 48 void PrioritizedResource::SetDimensions(gfx::Size size, ResourceFormat format) {
52 if (format_ != format || size_ != size) { 49 if (format_ != format || size_ != size) {
53 is_above_priority_cutoff_ = false; 50 is_above_priority_cutoff_ = false;
54 format_ = format; 51 format_ = format;
55 size_ = size; 52 size_ = size;
56 bytes_ = Resource::MemorySizeBytes(size, format); 53 bytes_ = Resource::MemorySizeBytes(size, format);
57 DCHECK(manager_ || !backing_); 54 DCHECK(manager_ || !backing_);
58 if (manager_) 55 if (manager_)
59 manager_->ReturnBackingTexture(this); 56 manager_->ReturnBackingTexture(this);
60 } 57 }
61 } 58 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 103
107 void PrioritizedResource::Unlink() { 104 void PrioritizedResource::Unlink() {
108 DCHECK(backing_); 105 DCHECK(backing_);
109 DCHECK(backing_->owner_ == this); 106 DCHECK(backing_->owner_ == this);
110 107
111 backing_->owner_ = NULL; 108 backing_->owner_ = NULL;
112 backing_ = NULL; 109 backing_ = NULL;
113 } 110 }
114 111
115 void PrioritizedResource::SetToSelfManagedMemoryPlaceholder(size_t bytes) { 112 void PrioritizedResource::SetToSelfManagedMemoryPlaceholder(size_t bytes) {
116 SetDimensions(gfx::Size(), GL_RGBA); 113 SetDimensions(gfx::Size(), RGBA_8888);
117 set_is_self_managed(true); 114 set_is_self_managed(true);
118 bytes_ = bytes; 115 bytes_ = bytes;
119 } 116 }
120 117
121 PrioritizedResource::Backing::Backing(unsigned id, 118 PrioritizedResource::Backing::Backing(unsigned id,
122 ResourceProvider* resource_provider, 119 ResourceProvider* resource_provider,
123 gfx::Size size, 120 gfx::Size size,
124 GLenum format) 121 ResourceFormat format)
125 : Resource(id, size, format), 122 : Resource(id, size, format),
126 owner_(NULL), 123 owner_(NULL),
127 priority_at_last_priority_update_(PriorityCalculator::LowestPriority()), 124 priority_at_last_priority_update_(PriorityCalculator::LowestPriority()),
128 was_above_priority_cutoff_at_last_priority_update_(false), 125 was_above_priority_cutoff_at_last_priority_update_(false),
129 in_drawing_impl_tree_(false), 126 in_drawing_impl_tree_(false),
130 #ifdef NDEBUG 127 #ifdef NDEBUG
131 resource_has_been_deleted_(false) {} 128 resource_has_been_deleted_(false) {}
132 #else 129 #else
133 resource_has_been_deleted_(false), 130 resource_has_been_deleted_(false),
134 resource_provider_(resource_provider) {} 131 resource_provider_(resource_provider) {}
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 manager_->ReturnBackingTexture(this); 189 manager_->ReturnBackingTexture(this);
193 } 190 }
194 191
195 const Proxy* PrioritizedResource::Backing::proxy() const { 192 const Proxy* PrioritizedResource::Backing::proxy() const {
196 if (!owner_ || !owner_->resource_manager()) 193 if (!owner_ || !owner_->resource_manager())
197 return NULL; 194 return NULL;
198 return owner_->resource_manager()->ProxyForDebug(); 195 return owner_->resource_manager()->ProxyForDebug();
199 } 196 }
200 197
201 } // namespace cc 198 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/prioritized_resource.h ('k') | cc/resources/prioritized_resource_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698