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

Side by Side Diff: cc/resource_provider.cc

Issue 11363207: Remove crash instrumentation, since we haven't seen a crash in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/resource_provider.h ('k') | cc/resource_update_controller.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"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_split.h" 12 #include "base/string_split.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "cc/gl_renderer.h" // For the GLC() macro. 14 #include "cc/gl_renderer.h" // For the GLC() macro.
15 #include "cc/texture_uploader.h" 15 #include "cc/texture_uploader.h"
16 #include "cc/transferable_resource.h" 16 #include "cc/transferable_resource.h"
17 #include "third_party/khronos/GLES2/gl2.h" 17 #include "third_party/khronos/GLES2/gl2.h"
18 #include "third_party/khronos/GLES2/gl2ext.h" 18 #include "third_party/khronos/GLES2/gl2ext.h"
19 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
20 #include "ui/gfx/vector2d.h" 20 #include "ui/gfx/vector2d.h"
21 21
22 #include <public/WebGraphicsContext3D.h> 22 #include <public/WebGraphicsContext3D.h>
23 23
24 using WebKit::WebGraphicsContext3D; 24 using WebKit::WebGraphicsContext3D;
25 25
26 namespace {
27 // Temporary variables for debugging crashes in issue 151428 in canary.
28 // Do not use these!
29 const int g_debugMaxResourcesTracked = 64;
30 unsigned int g_debugZone = 0;
31 int64 g_debugResDestroyedCount = 0;
32 cc::ResourceProvider::ResourceId g_debugResDestroyed[g_debugMaxResourcesTrack ed] = { 0 };
33 }
34
35 namespace cc { 26 namespace cc {
36 27
37 static GLenum textureToStorageFormat(GLenum textureFormat) 28 static GLenum textureToStorageFormat(GLenum textureFormat)
38 { 29 {
39 GLenum storageFormat = GL_RGBA8_OES; 30 GLenum storageFormat = GL_RGBA8_OES;
40 switch (textureFormat) { 31 switch (textureFormat) {
41 case GL_RGBA: 32 case GL_RGBA:
42 break; 33 break;
43 case GL_BGRA_EXT: 34 case GL_BGRA_EXT:
44 storageFormat = GL_BGRA8_EXT; 35 storageFormat = GL_BGRA8_EXT;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 { 217 {
227 Resource* resource = &it->second; 218 Resource* resource = &it->second;
228 if (resource->glId && !resource->external) { 219 if (resource->glId && !resource->external) {
229 WebGraphicsContext3D* context3d = m_context->context3D(); 220 WebGraphicsContext3D* context3d = m_context->context3D();
230 DCHECK(context3d); 221 DCHECK(context3d);
231 GLC(context3d, context3d->deleteTexture(resource->glId)); 222 GLC(context3d, context3d->deleteTexture(resource->glId));
232 } 223 }
233 if (resource->pixels) 224 if (resource->pixels)
234 delete[] resource->pixels; 225 delete[] resource->pixels;
235 226
236 g_debugResDestroyed[g_debugResDestroyedCount % g_debugMaxResourcesTracked] = (*it).first | g_debugZone;
237 m_resources.erase(it); 227 m_resources.erase(it);
238 } 228 }
239 229
240 void ResourceProvider::deleteOwnedResources(int pool) 230 void ResourceProvider::deleteOwnedResources(int pool)
241 { 231 {
242 DCHECK(m_threadChecker.CalledOnValidThread()); 232 DCHECK(m_threadChecker.CalledOnValidThread());
243 ResourceIdArray toDelete; 233 ResourceIdArray toDelete;
244 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end() ; ++it) { 234 for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end() ; ++it) {
245 if (it->second.pool == pool && !it->second.external && !it->second.marke dForDeletion) 235 if (it->second.pool == pool && !it->second.external && !it->second.marke dForDeletion)
246 toDelete.push_back(it->first); 236 toDelete.push_back(it->first);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 return false; 335 return false;
346 336
347 context3d->shallowFlushCHROMIUM(); 337 context3d->shallowFlushCHROMIUM();
348 return true; 338 return true;
349 } 339 }
350 340
351 const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id) 341 const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id)
352 { 342 {
353 DCHECK(m_threadChecker.CalledOnValidThread()); 343 DCHECK(m_threadChecker.CalledOnValidThread());
354 ResourceMap::iterator it = m_resources.find(id); 344 ResourceMap::iterator it = m_resources.find(id);
355 345 CHECK(it != m_resources.end());
356 if (it == m_resources.end()) {
357 int resourceCount = m_resources.size();
358 int64 resDestroyedCount = g_debugResDestroyedCount;
359 ResourceId resDestroyed[g_debugMaxResourcesTracked];
360 for (int64 i = 0; i < g_debugMaxResourcesTracked; ++i)
361 resDestroyed[i] = g_debugResDestroyed[i];
362 ResourceId resToDestroy = id;
363
364 base::debug::Alias(&resourceCount);
365 base::debug::Alias(&resDestroyedCount);
366 for (int64 i = 0; i < g_debugMaxResourcesTracked; ++i)
367 base::debug::Alias(&resDestroyed[i]);
368 base::debug::Alias(&resToDestroy);
369 CHECK(it != m_resources.end());
370 }
371
372 Resource* resource = &it->second; 346 Resource* resource = &it->second;
373 DCHECK(!resource->lockedForWrite); 347 DCHECK(!resource->lockedForWrite);
374 DCHECK(!resource->exported); 348 DCHECK(!resource->exported);
375 resource->lockForReadCount++; 349 resource->lockForReadCount++;
376 return resource; 350 return resource;
377 } 351 }
378 352
379 void ResourceProvider::unlockForRead(ResourceId id) 353 void ResourceProvider::unlockForRead(ResourceId id)
380 { 354 {
381 DCHECK(m_threadChecker.CalledOnValidThread()); 355 DCHECK(m_threadChecker.CalledOnValidThread());
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 GLC(context3d, context3d->genMailboxCHROMIUM(name)); 645 GLC(context3d, context3d->genMailboxCHROMIUM(name));
672 source->mailbox.setName(name); 646 source->mailbox.setName(name);
673 } 647 }
674 648
675 resource->mailbox = source->mailbox; 649 resource->mailbox = source->mailbox;
676 GLC(context, context->bindTexture(GL_TEXTURE_2D, source->glId)); 650 GLC(context, context->bindTexture(GL_TEXTURE_2D, source->glId));
677 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbo x.name)); 651 GLC(context, context->produceTextureCHROMIUM(GL_TEXTURE_2D, resource->mailbo x.name));
678 return true; 652 return true;
679 } 653 }
680 654
681 void ResourceProvider::debugNotifyEnterZone(unsigned int zone)
682 {
683 g_debugZone = zone;
684 }
685
686 void ResourceProvider::debugNotifyLeaveZone()
687 {
688 g_debugZone = 0;
689 }
690
691
692 } // namespace cc 655 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource_provider.h ('k') | cc/resource_update_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698