summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 21:28:29 +0000
committerccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 21:28:29 +0000
commit0ce5cf3f048f6a859d08f4fcaba69f0975c54239 (patch)
tree88ee0fbb9e6acd4e004629c39d08b598e07e6027
parentf0071314b3ea233f6d661434782e41ad517b3832 (diff)
downloadchromium_src-0ce5cf3f048f6a859d08f4fcaba69f0975c54239.zip
chromium_src-0ce5cf3f048f6a859d08f4fcaba69f0975c54239.tar.gz
chromium_src-0ce5cf3f048f6a859d08f4fcaba69f0975c54239.tar.bz2
Remove the pools from the ResourceProvider.
Pools were used in the past and were planned to be used to call deleteOwnedResources. We have moved the responsibility of deleting resources to the structure that created them (for example, the PrioritizedResourceManager now deletes contents textures, instead of calling deleteOwnedResources). BUG=164947 Review URL: https://codereview.chromium.org/11578019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173212 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/direct_renderer.cc2
-rw-r--r--cc/gl_renderer.cc4
-rw-r--r--cc/heads_up_display_layer_impl.cc2
-rw-r--r--cc/layer_tree_host.cc2
-rw-r--r--cc/layer_tree_host_impl_unittest.cc13
-rw-r--r--cc/prioritized_resource_manager.cc5
-rw-r--r--cc/prioritized_resource_manager.h7
-rw-r--r--cc/prioritized_resource_unittest.cc2
-rw-r--r--cc/renderer.h7
-rw-r--r--cc/resource_pool.cc8
-rw-r--r--cc/resource_pool.h10
-rw-r--r--cc/resource_provider.cc48
-rw-r--r--cc/resource_provider.h27
-rw-r--r--cc/resource_provider_unittest.cc41
-rw-r--r--cc/resource_update_controller_unittest.cc2
-rw-r--r--cc/scoped_resource.cc4
-rw-r--r--cc/scoped_resource.h2
-rw-r--r--cc/scoped_resource_unittest.cc8
-rw-r--r--cc/software_renderer_unittest.cc4
-rw-r--r--cc/tile_manager.cc3
-rw-r--r--cc/tiled_layer_unittest.cc2
-rw-r--r--cc/video_layer_impl.cc2
22 files changed, 72 insertions, 133 deletions
diff --git a/cc/direct_renderer.cc b/cc/direct_renderer.cc
index 3460160..1682e91 100644
--- a/cc/direct_renderer.cc
+++ b/cc/direct_renderer.cc
@@ -277,7 +277,7 @@ bool DirectRenderer::useRenderPass(DrawingFrame& frame, const RenderPass* render
gfx::Size size = renderPassTextureSize(renderPass);
size.Enlarge(m_enlargePassTextureAmount.x(), m_enlargePassTextureAmount.y());
- if (!texture->id() && !texture->Allocate(Renderer::ImplPool, size, renderPassTextureFormat(renderPass), ResourceProvider::TextureUsageFramebuffer))
+ if (!texture->id() && !texture->Allocate(size, renderPassTextureFormat(renderPass), ResourceProvider::TextureUsageFramebuffer))
return false;
return bindFramebufferToTexture(frame, texture, renderPass->output_rect);
diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc
index 5cd493c..e78a7f9 100644
--- a/cc/gl_renderer.cc
+++ b/cc/gl_renderer.cc
@@ -484,7 +484,7 @@ scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
int filteredDeviceBackgroundTextureId = texture->getTextureHandle();
scoped_ptr<ScopedResource> backgroundTexture = ScopedResource::create(m_resourceProvider);
- if (!backgroundTexture->Allocate(Renderer::ImplPool, quad->rect.size(), GL_RGBA, ResourceProvider::TextureUsageFramebuffer))
+ if (!backgroundTexture->Allocate(quad->rect.size(), GL_RGBA, ResourceProvider::TextureUsageFramebuffer))
return scoped_ptr<ScopedResource>();
const RenderPass* targetRenderPass = frame.currentRenderPass;
@@ -1455,7 +1455,7 @@ bool GLRenderer::getFramebufferTexture(ScopedResource* texture, const gfx::Rect&
{
DCHECK(!texture->id() || (texture->size() == deviceRect.size() && texture->format() == GL_RGB));
- if (!texture->id() && !texture->Allocate(Renderer::ImplPool, deviceRect.size(), GL_RGB, ResourceProvider::TextureUsageAny))
+ if (!texture->id() && !texture->Allocate(deviceRect.size(), GL_RGB, ResourceProvider::TextureUsageAny))
return false;
ResourceProvider::ScopedWriteLockGL lock(m_resourceProvider, texture->id());
diff --git a/cc/heads_up_display_layer_impl.cc b/cc/heads_up_display_layer_impl.cc
index 90e0fe1..4ef5b97 100644
--- a/cc/heads_up_display_layer_impl.cc
+++ b/cc/heads_up_display_layer_impl.cc
@@ -77,7 +77,7 @@ void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider)
m_hudTexture->Free();
if (!m_hudTexture->id())
- m_hudTexture->Allocate(Renderer::ImplPool, bounds(), GL_RGBA, ResourceProvider::TextureUsageAny);
+ m_hudTexture->Allocate(bounds(), GL_RGBA, ResourceProvider::TextureUsageAny);
}
void HeadsUpDisplayLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appendQuadsData)
diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc
index ca5e7f10..9d7b6f3 100644
--- a/cc/layer_tree_host.cc
+++ b/cc/layer_tree_host.cc
@@ -153,7 +153,7 @@ void LayerTreeHost::initializeRenderer()
maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates());
m_settings.maxPartialTextureUpdates = maxPartialTextureUpdates;
- m_contentsTextureManager = PrioritizedResourceManager::create(Renderer::ContentPool, m_proxy.get());
+ m_contentsTextureManager = PrioritizedResourceManager::create(m_proxy.get());
m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(gfx::Size(), GL_RGBA);
m_rendererInitialized = true;
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index 3c6ce48..3221929 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -1051,7 +1051,7 @@ private:
setTilingData(*tilingData.get());
setSkipsDraw(skipsDraw);
if (!tileMissing) {
- ResourceProvider::ResourceId resource = resourceProvider->createResource(Renderer::ContentPool, gfx::Size(), GL_RGBA, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId resource = resourceProvider->createResource(gfx::Size(), GL_RGBA, ResourceProvider::TextureUsageAny);
pushTileProperties(0, 0, resource, gfx::Rect(), false);
}
if (animating)
@@ -1675,7 +1675,7 @@ private:
, m_quadsAppended(false)
, m_quadRect(5, 5, 5, 5)
, m_quadVisibleRect(5, 5, 5, 5)
- , m_resourceId(resourceProvider->createResource(Renderer::ContentPool, gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny))
+ , m_resourceId(resourceProvider->createResource(gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny))
{
setAnchorPoint(gfx::PointF(0, 0));
setBounds(gfx::Size(10, 10));
@@ -2750,15 +2750,14 @@ public:
void createResources(ResourceProvider* provider)
{
DCHECK(provider);
- int pool = 0;
gfx::Size size(10, 10);
GLenum format = GL_RGBA;
ResourceProvider::TextureUsageHint hint = ResourceProvider::TextureUsageAny;
setScrollbarGeometry(ScrollbarGeometryFixedThumb::create(FakeWebScrollbarThemeGeometryNonEmpty::create()));
- setBackTrackResourceId(provider->createResource(pool, size, format, hint));
- setForeTrackResourceId(provider->createResource(pool, size, format, hint));
- setThumbResourceId(provider->createResource(pool, size, format, hint));
+ setBackTrackResourceId(provider->createResource(size, format, hint));
+ setForeTrackResourceId(provider->createResource(size, format, hint));
+ setThumbResourceId(provider->createResource(size, format, hint));
}
protected:
@@ -2770,7 +2769,7 @@ protected:
static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvider* provider)
{
- ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId resourceId = provider->createResource(gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), gfx::Transform());
diff --git a/cc/prioritized_resource_manager.cc b/cc/prioritized_resource_manager.cc
index ae7f634..f8d2ea4 100644
--- a/cc/prioritized_resource_manager.cc
+++ b/cc/prioritized_resource_manager.cc
@@ -15,14 +15,13 @@ using namespace std;
namespace cc {
-PrioritizedResourceManager::PrioritizedResourceManager(int pool, const Proxy* proxy)
+PrioritizedResourceManager::PrioritizedResourceManager(const Proxy* proxy)
: m_proxy(proxy)
, m_maxMemoryLimitBytes(defaultMemoryAllocationLimit())
, m_externalPriorityCutoff(PriorityCalculator::allowEverythingCutoff())
, m_memoryUseBytes(0)
, m_memoryAboveCutoffBytes(0)
, m_memoryAvailableBytes(0)
- , m_pool(pool)
, m_backingsTailNotSorted(false)
, m_memoryVisibleBytes(0)
, m_memoryVisibleAndNearbyBytes(0)
@@ -396,7 +395,7 @@ PrioritizedResource::Backing* PrioritizedResourceManager::createBacking(gfx::Siz
{
DCHECK(m_proxy->isImplThread() && m_proxy->isMainThreadBlocked());
DCHECK(resourceProvider);
- ResourceProvider::ResourceId resourceId = resourceProvider->createResource(m_pool, size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId resourceId = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
PrioritizedResource::Backing* backing = new PrioritizedResource::Backing(resourceId, resourceProvider, size, format);
m_memoryUseBytes += backing->bytes();
return backing;
diff --git a/cc/prioritized_resource_manager.h b/cc/prioritized_resource_manager.h
index cd14a89..6e2664a 100644
--- a/cc/prioritized_resource_manager.h
+++ b/cc/prioritized_resource_manager.h
@@ -38,9 +38,9 @@ class Proxy;
class CC_EXPORT PrioritizedResourceManager {
public:
- static scoped_ptr<PrioritizedResourceManager> create(int pool, const Proxy* proxy)
+ static scoped_ptr<PrioritizedResourceManager> create(const Proxy* proxy)
{
- return make_scoped_ptr(new PrioritizedResourceManager(pool, proxy));
+ return make_scoped_ptr(new PrioritizedResourceManager(proxy));
}
scoped_ptr<PrioritizedResource> createTexture(gfx::Size size, GLenum format)
{
@@ -152,7 +152,7 @@ private:
return a < b;
}
- PrioritizedResourceManager(int pool, const Proxy* proxy);
+ PrioritizedResourceManager(const Proxy* proxy);
bool evictBackingsToReduceMemory(size_t limitBytes,
int priorityCutoff,
@@ -176,7 +176,6 @@ private:
size_t m_memoryUseBytes;
size_t m_memoryAboveCutoffBytes;
size_t m_memoryAvailableBytes;
- int m_pool;
typedef base::hash_set<PrioritizedResource*> TextureSet;
typedef std::vector<PrioritizedResource*> TextureVector;
diff --git a/cc/prioritized_resource_unittest.cc b/cc/prioritized_resource_unittest.cc
index f04df01..1cc343c 100644
--- a/cc/prioritized_resource_unittest.cc
+++ b/cc/prioritized_resource_unittest.cc
@@ -39,7 +39,7 @@ public:
scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures)
{
- scoped_ptr<PrioritizedResourceManager> manager = PrioritizedResourceManager::create(0, &m_proxy);
+ scoped_ptr<PrioritizedResourceManager> manager = PrioritizedResourceManager::create(&m_proxy);
manager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
return manager.Pass();
}
diff --git a/cc/renderer.h b/cc/renderer.h
index 981679c..87346aa 100644
--- a/cc/renderer.h
+++ b/cc/renderer.h
@@ -32,13 +32,6 @@ protected:
class CC_EXPORT Renderer {
public:
- // This enum defines the various resource pools for the ResourceProvider
- // where textures get allocated.
- enum ResourcePool {
- ImplPool = 1, // This pool is for textures that get allocated on the impl thread (e.g. RenderSurfaces).
- ContentPool // This pool is for textures that get allocated on the main thread (e.g. tiles).
- };
-
virtual ~Renderer() { }
virtual const RendererCapabilities& capabilities() const = 0;
diff --git a/cc/resource_pool.cc b/cc/resource_pool.cc
index 5f54ca8..d82f62f 100644
--- a/cc/resource_pool.cc
+++ b/cc/resource_pool.cc
@@ -9,11 +9,9 @@
namespace cc {
ResourcePool::Resource::Resource(cc::ResourceProvider* resource_provider,
- cc::Renderer::ResourcePool pool_id,
const gfx::Size& size,
GLenum format)
: cc::Resource(resource_provider->createResource(
- pool_id,
size,
format,
ResourceProvider::TextureUsageAny),
@@ -29,10 +27,8 @@ ResourcePool::Resource::~Resource() {
resource_provider_->deleteResource(id());
}
-ResourcePool::ResourcePool(ResourceProvider* resource_provider,
- Renderer::ResourcePool pool_id)
+ResourcePool::ResourcePool(ResourceProvider* resource_provider)
: resource_provider_(resource_provider),
- pool_id_(pool_id),
max_memory_usage_bytes_(0),
memory_usage_bytes_(0) {
}
@@ -58,7 +54,7 @@ scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource(
// Create new resource.
Resource* resource = new Resource(
- resource_provider_, pool_id_, size, format);
+ resource_provider_, size, format);
memory_usage_bytes_ += resource->bytes();
return make_scoped_ptr(resource);
}
diff --git a/cc/resource_pool.h b/cc/resource_pool.h
index 3f71833..6ec8472 100644
--- a/cc/resource_pool.h
+++ b/cc/resource_pool.h
@@ -19,7 +19,6 @@ class ResourcePool {
class Resource : public cc::Resource {
public:
Resource(ResourceProvider* resource_provider,
- Renderer::ResourcePool pool_id,
const gfx::Size& size,
GLenum format);
~Resource();
@@ -30,9 +29,8 @@ class ResourcePool {
DISALLOW_COPY_AND_ASSIGN(Resource);
};
- static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider,
- Renderer::ResourcePool pool_id) {
- return make_scoped_ptr(new ResourcePool(resource_provider, pool_id));
+ static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider) {
+ return make_scoped_ptr(new ResourcePool(resource_provider));
}
virtual ~ResourcePool();
@@ -46,12 +44,10 @@ class ResourcePool {
void SetMaxMemoryUsageBytes(size_t max_memory_usage_bytes);
protected:
- ResourcePool(ResourceProvider* resource_provider,
- Renderer::ResourcePool pool_id);
+ ResourcePool(ResourceProvider* resource_provider);
private:
ResourceProvider* resource_provider_;
- Renderer::ResourcePool pool_id_;
size_t max_memory_usage_bytes_;
size_t memory_usage_bytes_;
diff --git a/cc/resource_provider.cc b/cc/resource_provider.cc
index 2cd7b4c..980a685 100644
--- a/cc/resource_provider.cc
+++ b/cc/resource_provider.cc
@@ -54,7 +54,6 @@ ResourceProvider::Resource::Resource()
, glUploadQueryId(0)
, pixels(0)
, pixelBuffer(0)
- , pool(0)
, lockForReadCount(0)
, lockedForWrite(false)
, external(false)
@@ -68,13 +67,12 @@ ResourceProvider::Resource::Resource()
{
}
-ResourceProvider::Resource::Resource(unsigned textureId, int pool, const gfx::Size& size, GLenum format, GLenum filter)
+ResourceProvider::Resource::Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenum filter)
: glId(textureId)
, glPixelBufferId(0)
, glUploadQueryId(0)
, pixels(0)
, pixelBuffer(0)
- , pool(pool)
, lockForReadCount(0)
, lockedForWrite(false)
, external(false)
@@ -88,13 +86,12 @@ ResourceProvider::Resource::Resource(unsigned textureId, int pool, const gfx::Si
{
}
-ResourceProvider::Resource::Resource(uint8_t* pixels, int pool, const gfx::Size& size, GLenum format, GLenum filter)
+ResourceProvider::Resource::Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum filter)
: glId(0)
, glPixelBufferId(0)
, glUploadQueryId(0)
, pixels(pixels)
, pixelBuffer(0)
- , pool(pool)
, lockForReadCount(0)
, lockedForWrite(false)
, external(false)
@@ -148,21 +145,21 @@ bool ResourceProvider::inUseByConsumer(ResourceId id)
return !!resource->lockForReadCount || resource->exported;
}
-ResourceProvider::ResourceId ResourceProvider::createResource(int pool, const gfx::Size& size, GLenum format, TextureUsageHint hint)
+ResourceProvider::ResourceId ResourceProvider::createResource(const gfx::Size& size, GLenum format, TextureUsageHint hint)
{
switch (m_defaultResourceType) {
case GLTexture:
- return createGLTexture(pool, size, format, hint);
+ return createGLTexture(size, format, hint);
case Bitmap:
DCHECK(format == GL_RGBA);
- return createBitmap(pool, size);
+ return createBitmap(size);
}
LOG(FATAL) << "Invalid default resource type.";
return 0;
}
-ResourceProvider::ResourceId ResourceProvider::createGLTexture(int pool, const gfx::Size& size, GLenum format, TextureUsageHint hint)
+ResourceProvider::ResourceId ResourceProvider::createGLTexture(const gfx::Size& size, GLenum format, TextureUsageHint hint)
{
DCHECK_LE(size.width(), m_maxTextureSize);
DCHECK_LE(size.height(), m_maxTextureSize);
@@ -187,19 +184,19 @@ ResourceProvider::ResourceId ResourceProvider::createGLTexture(int pool, const g
GLC(context3d, context3d->texImage2D(GL_TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GL_UNSIGNED_BYTE, 0));
ResourceId id = m_nextId++;
- Resource resource(textureId, pool, size, format, GL_LINEAR);
+ Resource resource(textureId, size, format, GL_LINEAR);
m_resources[id] = resource;
return id;
}
-ResourceProvider::ResourceId ResourceProvider::createBitmap(int pool, const gfx::Size& size)
+ResourceProvider::ResourceId ResourceProvider::createBitmap(const gfx::Size& size)
{
DCHECK(m_threadChecker.CalledOnValidThread());
uint8_t* pixels = new uint8_t[size.width() * size.height() * 4];
ResourceId id = m_nextId++;
- Resource resource(pixels, pool, size, GL_RGBA, GL_LINEAR);
+ Resource resource(pixels, size, GL_RGBA, GL_LINEAR);
m_resources[id] = resource;
return id;
}
@@ -217,7 +214,7 @@ ResourceProvider::ResourceId ResourceProvider::createResourceFromExternalTexture
GLC(context3d, context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
ResourceId id = m_nextId++;
- Resource resource(textureId, 0, gfx::Size(), 0, GL_LINEAR);
+ Resource resource(textureId, gfx::Size(), 0, GL_LINEAR);
resource.external = true;
m_resources[id] = resource;
return id;
@@ -266,18 +263,6 @@ void ResourceProvider::deleteResourceInternal(ResourceMap::iterator it)
m_resources.erase(it);
}
-void ResourceProvider::deleteOwnedResources(int pool)
-{
- 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)
- toDelete.push_back(it->first);
- }
- for (ResourceIdArray::iterator it = toDelete.begin(); it != toDelete.end(); ++it)
- deleteResource(*it);
-}
-
ResourceProvider::ResourceType ResourceProvider::resourceType(ResourceId id)
{
ResourceMap::iterator it = m_resources.find(id);
@@ -545,22 +530,23 @@ bool ResourceProvider::initialize()
return true;
}
-int ResourceProvider::createChild(int pool)
+int ResourceProvider::createChild()
{
DCHECK(m_threadChecker.CalledOnValidThread());
Child childInfo;
- childInfo.pool = pool;
int child = m_nextChild++;
m_children[child] = childInfo;
return child;
}
-void ResourceProvider::destroyChild(int child)
+void ResourceProvider::destroyChild(int child_id)
{
DCHECK(m_threadChecker.CalledOnValidThread());
- ChildMap::iterator it = m_children.find(child);
+ ChildMap::iterator it = m_children.find(child_id);
DCHECK(it != m_children.end());
- deleteOwnedResources(it->second.pool);
+ Child& child = it->second;
+ for (ResourceIdMap::iterator child_it = child.childToParentMap.begin(); child_it != child.childToParentMap.end(); ++child_it)
+ deleteResource(child_it->second);
m_children.erase(it);
}
@@ -643,7 +629,7 @@ void ResourceProvider::receiveFromChild(int child, const TransferableResourceLis
GLC(context3d, context3d->bindTexture(GL_TEXTURE_2D, textureId));
GLC(context3d, context3d->consumeTextureCHROMIUM(GL_TEXTURE_2D, it->mailbox.name));
ResourceId id = m_nextId++;
- Resource resource(textureId, childInfo.pool, it->size, it->format, it->filter);
+ Resource resource(textureId, it->size, it->format, it->filter);
resource.mailbox.setName(it->mailbox.name);
m_resources[id] = resource;
childInfo.parentToChildMap[id] = it->id;
diff --git a/cc/resource_provider.h b/cc/resource_provider.h
index 730d9b4..6d951df 100644
--- a/cc/resource_provider.h
+++ b/cc/resource_provider.h
@@ -40,7 +40,10 @@ public:
typedef unsigned ResourceId;
typedef std::vector<ResourceId> ResourceIdArray;
typedef base::hash_map<ResourceId, ResourceId> ResourceIdMap;
- enum TextureUsageHint { TextureUsageAny, TextureUsageFramebuffer };
+ enum TextureUsageHint {
+ TextureUsageAny,
+ TextureUsageFramebuffer,
+ };
enum ResourceType {
GLTexture = 1,
Bitmap,
@@ -67,19 +70,16 @@ public:
ResourceType resourceType(ResourceId);
// Creates a resource of the default resource type.
- ResourceId createResource(int pool, const gfx::Size&, GLenum format, TextureUsageHint);
+ ResourceId createResource(const gfx::Size&, GLenum format, TextureUsageHint);
// You can also explicitly create a specific resource type.
- ResourceId createGLTexture(int pool, const gfx::Size&, GLenum format, TextureUsageHint);
- ResourceId createBitmap(int pool, const gfx::Size&);
+ ResourceId createGLTexture(const gfx::Size&, GLenum format, TextureUsageHint);
+ ResourceId createBitmap(const gfx::Size&);
// Wraps an external texture into a GL resource.
ResourceId createResourceFromExternalTexture(unsigned textureId);
void deleteResource(ResourceId);
- // Deletes all resources owned by a given pool.
- void deleteOwnedResources(int pool);
-
// Update pixels from image, copying sourceRect (in image) into destRect (in the resource).
void setPixels(ResourceId, const uint8_t* image, const gfx::Rect& imageRect, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset);
@@ -97,11 +97,10 @@ public:
// Returns true if the shallow flush occurred, false otherwise.
bool shallowFlushIfSupported();
- // Creates accounting for a child, and associate it with a pool. Resources
- // transfered from that child will go to that pool. Returns a child ID.
- int createChild(int pool);
+ // Creates accounting for a child. Returns a child ID.
+ int createChild();
- // Destroys accounting for the child, deleting all resources from that pool.
+ // Destroys accounting for the child, deleting all accounted resources.
void destroyChild(int child);
// Gets the child->parent resource ID map.
@@ -230,8 +229,8 @@ public:
private:
struct Resource {
Resource();
- Resource(unsigned textureId, int pool, const gfx::Size& size, GLenum format, GLenum filter);
- Resource(uint8_t* pixels, int pool, const gfx::Size& size, GLenum format, GLenum filter);
+ Resource(unsigned textureId, const gfx::Size& size, GLenum format, GLenum filter);
+ Resource(uint8_t* pixels, const gfx::Size& size, GLenum format, GLenum filter);
unsigned glId;
// Pixel buffer used for set pixels without unnecessary copying.
@@ -241,7 +240,6 @@ private:
Mailbox mailbox;
uint8_t* pixels;
uint8_t* pixelBuffer;
- int pool;
int lockForReadCount;
bool lockedForWrite;
bool external;
@@ -259,7 +257,6 @@ private:
Child();
~Child();
- int pool;
ResourceIdMap childToParentMap;
ResourceIdMap parentToChildMap;
};
diff --git a/cc/resource_provider_unittest.cc b/cc/resource_provider_unittest.cc
index 56d924b..3a90f6e 100644
--- a/cc/resource_provider_unittest.cc
+++ b/cc/resource_provider_unittest.cc
@@ -310,11 +310,10 @@ TEST_P(ResourceProviderTest, Basic)
{
gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
- int pool = 1;
size_t pixelSize = textureSize(size, format);
ASSERT_EQ(4U, pixelSize);
- ResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id = m_resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
expectNumResources(1);
uint8_t data[4] = {1, 2, 3, 4};
@@ -329,33 +328,14 @@ TEST_P(ResourceProviderTest, Basic)
expectNumResources(0);
}
-TEST_P(ResourceProviderTest, DeleteOwnedResources)
-{
- gfx::Size size(1, 1);
- WGC3Denum format = GL_RGBA;
- int pool = 1;
-
- const int count = 3;
- for (int i = 0; i < count; ++i)
- m_resourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
- expectNumResources(3);
-
- m_resourceProvider->deleteOwnedResources(pool+1);
- expectNumResources(3);
-
- m_resourceProvider->deleteOwnedResources(pool);
- expectNumResources(0);
-}
-
TEST_P(ResourceProviderTest, Upload)
{
gfx::Size size(2, 2);
WGC3Denum format = GL_RGBA;
- int pool = 1;
size_t pixelSize = textureSize(size, format);
ASSERT_EQ(16U, pixelSize);
- ResourceProvider::ResourceId id = m_resourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id = m_resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
uint8_t image[16] = {0};
gfx::Rect imageRect(gfx::Point(), size);
@@ -422,21 +402,19 @@ TEST_P(ResourceProviderTest, TransferResources)
gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
- int pool = 1;
size_t pixelSize = textureSize(size, format);
ASSERT_EQ(4U, pixelSize);
- ResourceProvider::ResourceId id1 = childResourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id1 = childResourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
uint8_t data1[4] = {1, 2, 3, 4};
gfx::Rect rect(gfx::Point(), size);
childResourceProvider->setPixels(id1, data1, rect, rect, gfx::Vector2d());
- ResourceProvider::ResourceId id2 = childResourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id2 = childResourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
uint8_t data2[4] = {5, 5, 5, 5};
childResourceProvider->setPixels(id2, data2, rect, rect, gfx::Vector2d());
- int childPool = 2;
- int childId = m_resourceProvider->createChild(childPool);
+ int childId = m_resourceProvider->createChild();
{
// Transfer some resources to the parent.
@@ -539,17 +517,15 @@ TEST_P(ResourceProviderTest, DeleteTransferredResources)
gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
- int pool = 1;
size_t pixelSize = textureSize(size, format);
ASSERT_EQ(4U, pixelSize);
- ResourceProvider::ResourceId id = childResourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id = childResourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
uint8_t data[4] = {1, 2, 3, 4};
gfx::Rect rect(gfx::Point(), size);
childResourceProvider->setPixels(id, data, rect, rect, gfx::Vector2d());
- int childPool = 2;
- int childId = m_resourceProvider->createChild(childPool);
+ int childId = m_resourceProvider->createChild();
{
// Transfer some resource to the parent.
@@ -601,7 +577,6 @@ TEST_P(ResourceProviderTest, ScopedSampler)
gfx::Size size(1, 1);
WGC3Denum format = GL_RGBA;
- int pool = 1;
int textureId = 1;
// Check that the texture gets created with the right sampler settings.
@@ -610,7 +585,7 @@ TEST_P(ResourceProviderTest, ScopedSampler)
EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
EXPECT_CALL(*context, texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
- ResourceProvider::ResourceId id = resourceProvider->createResource(pool, size, format, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId id = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
// Creating a sampler with the default filter should not change any texture
// parameters.
diff --git a/cc/resource_update_controller_unittest.cc b/cc/resource_update_controller_unittest.cc
index 3056f6e..798e81c 100644
--- a/cc/resource_update_controller_unittest.cc
+++ b/cc/resource_update_controller_unittest.cc
@@ -65,7 +65,7 @@ public:
ResourceUpdateControllerTest()
: m_proxy(scoped_ptr<Thread>(NULL))
, m_queue(make_scoped_ptr(new ResourceUpdateQueue))
- , m_resourceManager(PrioritizedResourceManager::create(Renderer::ContentPool, &m_proxy))
+ , m_resourceManager(PrioritizedResourceManager::create(&m_proxy))
, m_fullUploadCountExpected(0)
, m_partialCountExpected(0)
, m_totalUploadCountExpected(0)
diff --git a/cc/scoped_resource.cc b/cc/scoped_resource.cc
index 5295b55..c5894aa 100644
--- a/cc/scoped_resource.cc
+++ b/cc/scoped_resource.cc
@@ -15,13 +15,13 @@ ScopedResource::~ScopedResource() {
Free();
}
-bool ScopedResource::Allocate(int pool, const gfx::Size& size, GLenum format,
+bool ScopedResource::Allocate(const gfx::Size& size, GLenum format,
ResourceProvider::TextureUsageHint hint) {
DCHECK(!id());
DCHECK(!size.IsEmpty());
set_dimensions(size, format);
- set_id(resource_provider_->createResource(pool, size, format, hint));
+ set_id(resource_provider_->createResource(size, format, hint));
#ifndef NDEBUG
allocate_thread_id_ = base::PlatformThread::CurrentId();
diff --git a/cc/scoped_resource.h b/cc/scoped_resource.h
index c112300..7f0814f 100644
--- a/cc/scoped_resource.h
+++ b/cc/scoped_resource.h
@@ -25,7 +25,7 @@ class CC_EXPORT ScopedResource : public Resource {
}
virtual ~ScopedResource();
- bool Allocate(int pool, const gfx::Size&, GLenum format,
+ bool Allocate(const gfx::Size&, GLenum format,
ResourceProvider::TextureUsageHint);
void Free();
void Leak();
diff --git a/cc/scoped_resource_unittest.cc b/cc/scoped_resource_unittest.cc
index 6a72564..902052c 100644
--- a/cc/scoped_resource_unittest.cc
+++ b/cc/scoped_resource_unittest.cc
@@ -34,7 +34,7 @@ TEST(ScopedResourceTest, CreateScopedResource)
scoped_ptr<OutputSurface> context(createFakeOutputSurface());
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
- texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
+ texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
// The texture has an allocated byte-size now.
size_t expectedBytes = 30 * 30 * 4;
@@ -54,7 +54,7 @@ TEST(ScopedResourceTest, ScopedResourceIsDeleted)
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
EXPECT_EQ(0u, resourceProvider->numResources());
- texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
+ texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
EXPECT_LT(0u, texture->id());
EXPECT_EQ(1u, resourceProvider->numResources());
}
@@ -64,7 +64,7 @@ TEST(ScopedResourceTest, ScopedResourceIsDeleted)
{
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
EXPECT_EQ(0u, resourceProvider->numResources());
- texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
+ texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
EXPECT_LT(0u, texture->id());
EXPECT_EQ(1u, resourceProvider->numResources());
texture->Free();
@@ -81,7 +81,7 @@ TEST(ScopedResourceTest, LeakScopedResource)
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
EXPECT_EQ(0u, resourceProvider->numResources());
- texture->Allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
+ texture->Allocate(gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
EXPECT_LT(0u, texture->id());
EXPECT_EQ(1u, resourceProvider->numResources());
diff --git a/cc/software_renderer_unittest.cc b/cc/software_renderer_unittest.cc
index 1e5eed2..529d9c7 100644
--- a/cc/software_renderer_unittest.cc
+++ b/cc/software_renderer_unittest.cc
@@ -110,8 +110,8 @@ TEST_F(SoftwareRendererTest, tileQuad)
setViewportSize(outerSize);
initializeRenderer();
- ResourceProvider::ResourceId resourceYellow = resourceProvider()->createResource(1, outerSize, GL_RGBA, ResourceProvider::TextureUsageAny);
- ResourceProvider::ResourceId resourceCyan = resourceProvider()->createResource(1, innerSize, GL_RGBA, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId resourceYellow = resourceProvider()->createResource(outerSize, GL_RGBA, ResourceProvider::TextureUsageAny);
+ ResourceProvider::ResourceId resourceCyan = resourceProvider()->createResource(innerSize, GL_RGBA, ResourceProvider::TextureUsageAny);
SkColor yellow = SK_ColorYELLOW;
SkColor cyan = SK_ColorCYAN;
diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc
index 2c18e89..54c6c2c 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -136,8 +136,7 @@ TileManager::TileManager(
ResourceProvider* resource_provider,
size_t num_raster_threads)
: client_(client),
- resource_pool_(ResourcePool::Create(resource_provider,
- Renderer::ImplPool)),
+ resource_pool_(ResourcePool::Create(resource_provider)),
manage_tiles_pending_(false),
manage_tiles_call_count_(0),
check_for_completed_set_pixels_pending_(false) {
diff --git a/cc/tiled_layer_unittest.cc b/cc/tiled_layer_unittest.cc
index 10f05ea..b6f4fdd 100644
--- a/cc/tiled_layer_unittest.cc
+++ b/cc/tiled_layer_unittest.cc
@@ -59,7 +59,7 @@ public:
{
m_layerTreeHost = LayerTreeHost::create(&m_fakeLayerImplTreeHostClient, m_settings, scoped_ptr<Thread>(NULL));
m_proxy = m_layerTreeHost->proxy();
- m_resourceManager = PrioritizedResourceManager::create(Renderer::ContentPool, m_proxy);
+ m_resourceManager = PrioritizedResourceManager::create(m_proxy);
m_layerTreeHost->initializeRendererIfNeeded();
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked(m_proxy);
m_resourceProvider = ResourceProvider::create(m_outputSurface.get());
diff --git a/cc/video_layer_impl.cc b/cc/video_layer_impl.cc
index 3ba0b65..9b05839 100644
--- a/cc/video_layer_impl.cc
+++ b/cc/video_layer_impl.cc
@@ -316,7 +316,7 @@ bool VideoLayerImpl::FramePlane::allocateData(
if (resourceId)
return true;
- resourceId = resourceProvider->createResource(Renderer::ImplPool, size, format, ResourceProvider::TextureUsageAny);
+ resourceId = resourceProvider->createResource(size, format, ResourceProvider::TextureUsageAny);
return resourceId;
}