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

Side by Side Diff: cc/resource_provider.cc

Issue 11888010: Cosmetic cleanup to texture_layer mailboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments Created 7 years, 11 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 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE)); 234 GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL _CLAMP_TO_EDGE));
235 235
236 ResourceId id = m_nextId++; 236 ResourceId id = m_nextId++;
237 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); 237 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
238 resource.external = true; 238 resource.external = true;
239 resource.allocated = true; 239 resource.allocated = true;
240 m_resources[id] = resource; 240 m_resources[id] = resource;
241 return id; 241 return id;
242 } 242 }
243 243
244 ResourceProvider::ResourceId ResourceProvider::createResourceFromTextureMailbox( const std::string& mailbox, const base::Callback<void(unsigned)>& releaseCallbac k) 244 ResourceProvider::ResourceId ResourceProvider::createResourceFromTextureMailbox( const TextureMailbox& mailbox)
245 { 245 {
246 DCHECK(m_threadChecker.CalledOnValidThread()); 246 DCHECK(m_threadChecker.CalledOnValidThread());
247 // Just store the information. Mailbox will be consumed in lockForRead(). 247 // Just store the information. Mailbox will be consumed in lockForRead().
248 ResourceId id = m_nextId++; 248 ResourceId id = m_nextId++;
249 unsigned textureId = 0; 249 unsigned textureId = 0;
250 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR); 250 Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
251 resource.external = true; 251 resource.external = true;
252 resource.allocated = true; 252 resource.allocated = true;
253 resource.mailbox.setName(reinterpret_cast<const int8*>(mailbox.data())); 253 resource.mailbox.setName(mailbox.Data());
254 resource.mailboxReleaseCallback = releaseCallback; 254 resource.mailboxCallback = mailbox.callback_;
255 m_resources[id] = resource; 255 m_resources[id] = resource;
256 return id; 256 return id;
257 } 257 }
258 258
259 void ResourceProvider::deleteResource(ResourceId id) 259 void ResourceProvider::deleteResource(ResourceId id)
260 { 260 {
261 DCHECK(m_threadChecker.CalledOnValidThread()); 261 DCHECK(m_threadChecker.CalledOnValidThread());
262 ResourceMap::iterator it = m_resources.find(id); 262 ResourceMap::iterator it = m_resources.find(id);
263 CHECK(it != m_resources.end()); 263 CHECK(it != m_resources.end());
264 Resource* resource = &it->second; 264 Resource* resource = &it->second;
(...skipping 29 matching lines...) Expand all
294 if (!resource->mailbox.isZero() && resource->external) { 294 if (!resource->mailbox.isZero() && resource->external) {
295 WebGraphicsContext3D* context3d = m_outputSurface->Context3D(); 295 WebGraphicsContext3D* context3d = m_outputSurface->Context3D();
296 DCHECK(context3d); 296 DCHECK(context3d);
297 unsigned syncPoint = 0; 297 unsigned syncPoint = 0;
298 if (resource->glId) { 298 if (resource->glId) {
299 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId) ); 299 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId) );
300 GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, reso urce->mailbox.name)); 300 GLC(context3d, context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, reso urce->mailbox.name));
301 GLC(context3d, context3d->deleteTexture(resource->glId)); 301 GLC(context3d, context3d->deleteTexture(resource->glId));
302 syncPoint = context3d->insertSyncPoint(); 302 syncPoint = context3d->insertSyncPoint();
303 } 303 }
304 if (!resource->mailboxReleaseCallback.is_null()) 304 if (!resource->mailboxCallback.is_null())
305 resource->mailboxReleaseCallback.Run(syncPoint); 305 resource->mailboxCallback.Run(syncPoint);
306 } 306 }
307 if (resource->pixels) 307 if (resource->pixels)
308 delete[] resource->pixels; 308 delete[] resource->pixels;
309 if (resource->pixelBuffer) 309 if (resource->pixelBuffer)
310 delete[] resource->pixelBuffer; 310 delete[] resource->pixelBuffer;
311 311
312 m_resources.erase(it); 312 m_resources.erase(it);
313 } 313 }
314 314
315 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id) 315 ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id)
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId)); 1045 GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, resource->glId));
1046 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) { 1046 if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) {
1047 GLenum storageFormat = textureToStorageFormat(format); 1047 GLenum storageFormat = textureToStorageFormat(format);
1048 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma t, size.width(), size.height())); 1048 GLC(context3d, context3d->texStorage2DEXT(GL_TEXTURE_2D, 1, storageForma t, size.width(), size.height()));
1049 } else 1049 } else
1050 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0)); 1050 GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.widt h(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0));
1051 } 1051 }
1052 1052
1053 1053
1054 } // namespace cc 1054 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource_provider.h ('k') | cc/texture_layer.h » ('j') | cc/texture_mailbox.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698