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

Unified Diff: cc/resource_provider.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address code review comments and fix all cc_unittests Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: cc/resource_provider.cc
diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc
index 0013126a8315229e7e82ad17465bf9c516128cd3..103396d82d7557b9da60b6afd42446dcd11a01a7 100644
--- a/cc/resource_provider.cc
+++ b/cc/resource_provider.cc
@@ -15,7 +15,6 @@
#include "base/string_split.h"
#include "base/string_util.h"
#include "cc/gl_renderer.h" // For the GLC() macro.
-#include "cc/proxy.h"
#include "cc/texture_uploader.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
@@ -128,13 +127,13 @@ ResourceProvider::~ResourceProvider()
WebGraphicsContext3D* ResourceProvider::graphicsContext3D()
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
return m_context->context3D();
}
bool ResourceProvider::inUseByConsumer(ResourceId id)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
Resource* resource = &it->second;
@@ -157,7 +156,7 @@ ResourceProvider::ResourceId ResourceProvider::createResource(int pool, const In
ResourceProvider::ResourceId ResourceProvider::createGLTexture(int pool, const IntSize& size, GLenum format, TextureUsageHint hint)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
unsigned textureId = 0;
WebGraphicsContext3D* context3d = m_context->context3D();
DCHECK(context3d);
@@ -183,7 +182,7 @@ ResourceProvider::ResourceId ResourceProvider::createGLTexture(int pool, const I
ResourceProvider::ResourceId ResourceProvider::createBitmap(int pool, const IntSize& size)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
uint8_t* pixels = new uint8_t[size.width() * size.height() * 4];
@@ -195,7 +194,7 @@ ResourceProvider::ResourceId ResourceProvider::createBitmap(int pool, const IntS
ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture(unsigned textureId)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
DCHECK(m_context->context3D());
ResourceId id = m_nextId++;
Resource resource(textureId, 0, IntSize(), 0);
@@ -206,7 +205,7 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture
void ResourceProvider::deleteResource(ResourceId id)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
Resource* resource = &it->second;
@@ -237,7 +236,7 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it)
void ResourceProvider::deleteOwnedResources(int pool)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ResourceIdArray toDelete;
for (ResourceMap::iterator it = m_resources.begin(); it != m_resources.end(); ++it) {
if (it->second.pool == pool && !it->second.external && !it->second.markedForDeletion)
@@ -257,7 +256,7 @@ ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id)
void ResourceProvider::upload(ResourceId id, const uint8_t* image, const IntRect& imageRect, const IntRect& sourceRect, const IntSize& destOffset)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
Resource* resource = &it->second;
@@ -320,7 +319,7 @@ double ResourceProvider::estimatedUploadsPerSecond()
void ResourceProvider::flush()
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D();
if (context3d)
context3d->flush();
@@ -328,7 +327,7 @@ void ResourceProvider::flush()
bool ResourceProvider::shallowFlushIfSupported()
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D();
if (!context3d || !m_useShallowFlush)
return false;
@@ -339,7 +338,7 @@ bool ResourceProvider::shallowFlushIfSupported()
const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
@@ -352,7 +351,7 @@ const ResourceProvider::Resource* ResourceProvider::lockForRead(ResourceId id)
void ResourceProvider::unlockForRead(ResourceId id)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
Resource* resource = &it->second;
@@ -363,7 +362,7 @@ void ResourceProvider::unlockForRead(ResourceId id)
const ResourceProvider::Resource* ResourceProvider::lockForWrite(ResourceId id)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
Resource* resource = &it->second;
@@ -377,7 +376,7 @@ const ResourceProvider::Resource* ResourceProvider::lockForWrite(ResourceId id)
void ResourceProvider::unlockForWrite(ResourceId id)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ResourceMap::iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
Resource* resource = &it->second;
@@ -460,7 +459,7 @@ ResourceProvider::ResourceProvider(GraphicsContext* context)
bool ResourceProvider::initialize()
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D();
if (!context3d) {
m_maxTextureSize = INT_MAX / 2;
@@ -496,7 +495,7 @@ bool ResourceProvider::initialize()
int ResourceProvider::createChild(int pool)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
Child childInfo;
childInfo.pool = pool;
int child = m_nextChild++;
@@ -506,7 +505,7 @@ int ResourceProvider::createChild(int pool)
void ResourceProvider::destroyChild(int child)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ChildMap::iterator it = m_children.find(child);
DCHECK(it != m_children.end());
deleteOwnedResources(it->second.pool);
@@ -516,7 +515,7 @@ void ResourceProvider::destroyChild(int child)
const ResourceProvider::ResourceIdMap& ResourceProvider::getChildToParentMap(int child) const
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ChildMap::const_iterator it = m_children.find(child);
DCHECK(it != m_children.end());
return it->second.childToParentMap;
@@ -524,7 +523,7 @@ const ResourceProvider::ResourceIdMap& ResourceProvider::getChildToParentMap(int
ResourceProvider::TransferableResourceList ResourceProvider::prepareSendToParent(const ResourceIdArray& resources)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
TransferableResourceList list;
list.syncPoint = 0;
WebGraphicsContext3D* context3d = m_context->context3D();
@@ -546,7 +545,7 @@ ResourceProvider::TransferableResourceList ResourceProvider::prepareSendToParent
ResourceProvider::TransferableResourceList ResourceProvider::prepareSendToChild(int child, const ResourceIdArray& resources)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
TransferableResourceList list;
list.syncPoint = 0;
WebGraphicsContext3D* context3d = m_context->context3D();
@@ -573,7 +572,7 @@ ResourceProvider::TransferableResourceList ResourceProvider::prepareSendToChild(
void ResourceProvider::receiveFromChild(int child, const TransferableResourceList& resources)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D();
if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing.
@@ -605,7 +604,7 @@ void ResourceProvider::receiveFromChild(int child, const TransferableResourceLis
void ResourceProvider::receiveFromParent(const TransferableResourceList& resources)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
WebGraphicsContext3D* context3d = m_context->context3D();
if (!context3d || !context3d->makeContextCurrent()) {
// FIXME: Implement this path for software compositing.
@@ -629,7 +628,7 @@ void ResourceProvider::receiveFromParent(const TransferableResourceList& resourc
bool ResourceProvider::transferResource(WebGraphicsContext3D* context, ResourceId id, TransferableResource* resource)
{
- DCHECK(Proxy::isImplThread());
+ DCHECK(m_threadChecker.CalledOnValidThread());
ResourceMap::const_iterator it = m_resources.find(id);
CHECK(it != m_resources.end());
const Resource* source = &it->second;

Powered by Google App Engine
This is Rietveld 408576698