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

Side by Side Diff: cc/resource_provider.cc

Issue 11548052: Identify evictable textures by GL texture parameter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve against head again Created 8 years 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/resource_provider.h ('k') | cc/resource_provider_unittest.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 #include "cc/resource_provider.h" 5 #include "cc/resource_provider.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 ResourceMap::iterator it = m_resources.find(id); 142 ResourceMap::iterator it = m_resources.find(id);
143 CHECK(it != m_resources.end()); 143 CHECK(it != m_resources.end());
144 Resource* resource = &it->second; 144 Resource* resource = &it->second;
145 return !!resource->lockForReadCount || resource->exported; 145 return !!resource->lockForReadCount || resource->exported;
146 } 146 }
147 147
148 ResourceProvider::ResourceId ResourceProvider::createResource(const gfx::Size& s ize, GLenum format, TextureUsageHint hint) 148 ResourceProvider::ResourceId ResourceProvider::createResource(const gfx::Size& s ize, GLenum format, TextureUsageHint hint)
149 { 149 {
150 switch (m_defaultResourceType) { 150 switch (m_defaultResourceType) {
151 case GLTexture: 151 case GLTexture:
152 return createGLTexture(size, format, hint); 152 return createGLTexture(size, format, GL_TEXTURE_POOL_UNMANAGED_CHROMIUM, hint);
153 case Bitmap: 153 case Bitmap:
154 DCHECK(format == GL_RGBA); 154 DCHECK(format == GL_RGBA);
155 return createBitmap(size); 155 return createBitmap(size);
156 } 156 }
157 157
158 LOG(FATAL) << "Invalid default resource type."; 158 LOG(FATAL) << "Invalid default resource type.";
159 return 0; 159 return 0;
160 } 160 }
161 161
162 ResourceProvider::ResourceId ResourceProvider::createGLTexture(const gfx::Size& size, GLenum format, TextureUsageHint hint) 162 ResourceProvider::ResourceId ResourceProvider::createManagedResource(const gfx:: Size& size, GLenum format, TextureUsageHint hint)
163 {
164 switch (m_defaultResourceType) {
165 case GLTexture:
166 return createGLTexture(size, format, GL_TEXTURE_POOL_MANAGED_CHROMIUM, h int);
167 case Bitmap:
168 DCHECK(format == GL_RGBA);
169 return createBitmap(size);
170 }
171
172 LOG(FATAL) << "Invalid default resource type.";
173 return 0;
174 }
175
176 ResourceProvider::ResourceId ResourceProvider::createGLTexture(const gfx::Size& size, GLenum format, GLenum texturePool, TextureUsageHint hint)
163 { 177 {
164 DCHECK_LE(size.width(), m_maxTextureSize); 178 DCHECK_LE(size.width(), m_maxTextureSize);
165 DCHECK_LE(size.height(), m_maxTextureSize); 179 DCHECK_LE(size.height(), m_maxTextureSize);
166 180
167 DCHECK(m_threadChecker.CalledOnValidThread()); 181 DCHECK(m_threadChecker.CalledOnValidThread());
168 unsigned textureId = 0; 182 unsigned textureId = 0;
169 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 183 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
170 DCHECK(context3d); 184 DCHECK(context3d);
171 GLC(context3d, textureId = context3d->createTexture()); 185 GLC(context3d, textureId = context3d->createTexture());
172 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId)); 186 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
173 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR)); 187 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER , GL_LINEAR));
174 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR)); 188 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER , GL_LINEAR));
175 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE)); 189 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL _CLAMP_TO_EDGE));
176 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); 190 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE));
191 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_POOL_CHROM IUM, texturePool));
177 192
178 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer) 193 if (m_useTextureUsageHint && hint == TextureUsageFramebuffer)
179 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE)); 194 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
180 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { 195 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) {
181 GLenum storageFormat = textureToStorageFormat(format); 196 GLenum storageFormat = textureToStorageFormat(format);
182 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma t, size.width(), size.height())); 197 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma t, size.width(), size.height()));
183 } else 198 } else
184 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); 199 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0));
185 200
186 ResourceId id = m_nextId++; 201 ResourceId id = m_nextId++;
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 return false; 950 return false;
936 } 951 }
937 952
938 resource->pendingSetPixels = false; 953 resource->pendingSetPixels = false;
939 unlockForWrite(id); 954 unlockForWrite(id);
940 955
941 return true; 956 return true;
942 } 957 }
943 958
944 } // namespace cc 959 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource_provider.h ('k') | cc/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698