cc: Rename PrioritizedTexture to PrioritizedResource.
sed -e ' s/PrioritizedTexture/PrioritizedResource/g s/prioritized_texture/prioritized_resource/g s/PRIORITIZED_TEXTURE/PRIORITIZED_RESOURCE/g s/managedTexture/managedResource/g s/textureManager/resourceManager/g s/constentsTextureManager/constentsResourceManager/g ' BUG= TEST=cc_unittests Review URL: https://codereview.chromium.org/11369109 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166520 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
cc
bitmap_content_layer_updater.ccbitmap_content_layer_updater.hbitmap_skpicture_content_layer_updater.ccbitmap_skpicture_content_layer_updater.hcc.gypcc_tests.gypgl_renderer_unittest.ccimage_layer_updater.ccimage_layer_updater.hlayer_tree_host.cclayer_tree_host.hlayer_tree_host_impl.cclayer_tree_host_unittest.cclayer_updater.cclayer_updater.hprioritized_resource.ccprioritized_resource.hprioritized_resource_manager.ccprioritized_resource_manager.hprioritized_resource_unittest.ccresource_update.ccresource_update.hresource_update_controller.ccresource_update_controller_unittest.ccresource_update_queue.ccsingle_thread_proxy.ccskpicture_content_layer_updater.ccskpicture_content_layer_updater.h
test
texture_uploader.cctexture_uploader_unittest.ccthread_proxy.htiled_layer.cctiled_layer.htiled_layer_unittest.cc@ -13,7 +13,7 @@
|
||||
|
||||
namespace cc {
|
||||
|
||||
BitmapContentLayerUpdater::Resource::Resource(BitmapContentLayerUpdater* updater, scoped_ptr<PrioritizedTexture> texture)
|
||||
BitmapContentLayerUpdater::Resource::Resource(BitmapContentLayerUpdater* updater, scoped_ptr<PrioritizedResource> texture)
|
||||
: LayerUpdater::Resource(texture.Pass())
|
||||
, m_updater(updater)
|
||||
{
|
||||
@ -43,9 +43,9 @@ BitmapContentLayerUpdater::~BitmapContentLayerUpdater()
|
||||
{
|
||||
}
|
||||
|
||||
scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::createResource(PrioritizedTextureManager* manager)
|
||||
scoped_ptr<LayerUpdater::Resource> BitmapContentLayerUpdater::createResource(PrioritizedResourceManager* manager)
|
||||
{
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedTexture::create(manager)));
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager)));
|
||||
}
|
||||
|
||||
void BitmapContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats& stats)
|
||||
@ -58,7 +58,7 @@ void BitmapContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, co
|
||||
paintContents(m_canvas.get(), contentRect, contentsWidthScale, contentsHeightScale, resultingOpaqueRect, stats);
|
||||
}
|
||||
|
||||
void BitmapContentLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedTexture* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate)
|
||||
void BitmapContentLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedResource* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate)
|
||||
{
|
||||
ResourceUpdate upload = ResourceUpdate::Create(
|
||||
texture,
|
||||
|
@ -22,7 +22,7 @@ class CC_EXPORT BitmapContentLayerUpdater : public ContentLayerUpdater {
|
||||
public:
|
||||
class Resource : public LayerUpdater::Resource {
|
||||
public:
|
||||
Resource(BitmapContentLayerUpdater*, scoped_ptr<PrioritizedTexture>);
|
||||
Resource(BitmapContentLayerUpdater*, scoped_ptr<PrioritizedResource>);
|
||||
virtual ~Resource();
|
||||
|
||||
virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE;
|
||||
@ -35,9 +35,9 @@ public:
|
||||
|
||||
static scoped_refptr<BitmapContentLayerUpdater> create(scoped_ptr<LayerPainter>);
|
||||
|
||||
virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedTextureManager*) OVERRIDE;
|
||||
virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedResourceManager*) OVERRIDE;
|
||||
virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats&) OVERRIDE;
|
||||
void updateTexture(ResourceUpdateQueue&, PrioritizedTexture*, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate);
|
||||
void updateTexture(ResourceUpdateQueue&, PrioritizedResource*, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate);
|
||||
|
||||
virtual void setOpaque(bool) OVERRIDE;
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
namespace cc {
|
||||
|
||||
BitmapSkPictureContentLayerUpdater::Resource::Resource(BitmapSkPictureContentLayerUpdater* updater, scoped_ptr<PrioritizedTexture> texture)
|
||||
BitmapSkPictureContentLayerUpdater::Resource::Resource(BitmapSkPictureContentLayerUpdater* updater, scoped_ptr<PrioritizedResource> texture)
|
||||
: ContentLayerUpdater::Resource(texture.Pass())
|
||||
, m_updater(updater)
|
||||
{
|
||||
@ -54,9 +54,9 @@ BitmapSkPictureContentLayerUpdater::~BitmapSkPictureContentLayerUpdater()
|
||||
{
|
||||
}
|
||||
|
||||
scoped_ptr<LayerUpdater::Resource> BitmapSkPictureContentLayerUpdater::createResource(PrioritizedTextureManager* manager)
|
||||
scoped_ptr<LayerUpdater::Resource> BitmapSkPictureContentLayerUpdater::createResource(PrioritizedResourceManager* manager)
|
||||
{
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedTexture::create(manager)));
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager)));
|
||||
}
|
||||
|
||||
void BitmapSkPictureContentLayerUpdater::paintContentsRect(SkCanvas* canvas, const gfx::Rect& sourceRect, RenderingStats& stats)
|
||||
|
@ -16,7 +16,7 @@ class BitmapSkPictureContentLayerUpdater : public SkPictureContentLayerUpdater {
|
||||
public:
|
||||
class Resource : public ContentLayerUpdater::Resource {
|
||||
public:
|
||||
Resource(BitmapSkPictureContentLayerUpdater*, scoped_ptr<PrioritizedTexture>);
|
||||
Resource(BitmapSkPictureContentLayerUpdater*, scoped_ptr<PrioritizedResource>);
|
||||
|
||||
virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE;
|
||||
|
||||
@ -29,7 +29,7 @@ public:
|
||||
|
||||
static scoped_refptr<BitmapSkPictureContentLayerUpdater> create(scoped_ptr<LayerPainter>);
|
||||
|
||||
virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedTextureManager*) OVERRIDE;
|
||||
virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedResourceManager*) OVERRIDE;
|
||||
void paintContentsRect(SkCanvas*, const gfx::Rect& sourceRect, RenderingStats&);
|
||||
|
||||
private:
|
||||
|
@ -112,10 +112,10 @@
|
||||
'page_scale_animation.cc',
|
||||
'page_scale_animation.h',
|
||||
'platform_color.h',
|
||||
'prioritized_texture.cc',
|
||||
'prioritized_texture.h',
|
||||
'prioritized_texture_manager.cc',
|
||||
'prioritized_texture_manager.h',
|
||||
'prioritized_resource.cc',
|
||||
'prioritized_resource.h',
|
||||
'prioritized_resource_manager.cc',
|
||||
'prioritized_resource_manager.h',
|
||||
'priority_calculator.cc',
|
||||
'priority_calculator.h',
|
||||
'program_binding.cc',
|
||||
|
@ -32,7 +32,7 @@
|
||||
'nine_patch_layer_impl_unittest.cc',
|
||||
'nine_patch_layer_unittest.cc',
|
||||
'occlusion_tracker_unittest.cc',
|
||||
'prioritized_texture_unittest.cc',
|
||||
'prioritized_resource_unittest.cc',
|
||||
'quad_culler_unittest.cc',
|
||||
'render_pass_unittest.cc',
|
||||
'render_surface_filters_unittest.cc',
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "cc/gl_renderer.h"
|
||||
|
||||
#include "cc/draw_quad.h"
|
||||
#include "cc/prioritized_texture_manager.h"
|
||||
#include "cc/prioritized_resource_manager.h"
|
||||
#include "cc/resource_provider.h"
|
||||
#include "cc/settings.h"
|
||||
#include "cc/single_thread_proxy.h"
|
||||
@ -61,7 +61,7 @@ public:
|
||||
: m_setFullRootLayerDamageCount(0)
|
||||
, m_lastCallWasSetVisibility(0)
|
||||
, m_rootLayer(LayerImpl::create(1))
|
||||
, m_memoryAllocationLimitBytes(PrioritizedTextureManager::defaultMemoryAllocationLimit())
|
||||
, m_memoryAllocationLimitBytes(PrioritizedResourceManager::defaultMemoryAllocationLimit())
|
||||
{
|
||||
m_rootLayer->createRenderSurface();
|
||||
RenderPass::Id renderPassId = m_rootLayer->renderSurface()->renderPassId();
|
||||
|
@ -21,12 +21,12 @@ scoped_refptr<ImageLayerUpdater> ImageLayerUpdater::create()
|
||||
}
|
||||
|
||||
scoped_ptr<LayerUpdater::Resource> ImageLayerUpdater::createResource(
|
||||
PrioritizedTextureManager* manager)
|
||||
PrioritizedResourceManager* manager)
|
||||
{
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedTexture::create(manager)));
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager)));
|
||||
}
|
||||
|
||||
void ImageLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedTexture* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate)
|
||||
void ImageLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedResource* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate)
|
||||
{
|
||||
// Source rect should never go outside the image pixels, even if this
|
||||
// is requested because the texture extends outside the image.
|
||||
|
@ -17,7 +17,7 @@ class ImageLayerUpdater : public LayerUpdater {
|
||||
public:
|
||||
class Resource : public LayerUpdater::Resource {
|
||||
public:
|
||||
Resource(ImageLayerUpdater* updater, scoped_ptr<PrioritizedTexture> texture)
|
||||
Resource(ImageLayerUpdater* updater, scoped_ptr<PrioritizedResource> texture)
|
||||
: LayerUpdater::Resource(texture.Pass())
|
||||
, m_updater(updater)
|
||||
{
|
||||
@ -32,9 +32,9 @@ public:
|
||||
static scoped_refptr<ImageLayerUpdater> create();
|
||||
|
||||
virtual scoped_ptr<LayerUpdater::Resource> createResource(
|
||||
PrioritizedTextureManager*) OVERRIDE;
|
||||
PrioritizedResourceManager*) OVERRIDE;
|
||||
|
||||
void updateTexture(ResourceUpdateQueue&, PrioritizedTexture*, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate);
|
||||
void updateTexture(ResourceUpdateQueue&, PrioritizedResource*, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate);
|
||||
|
||||
void setBitmap(const SkBitmap&);
|
||||
|
||||
|
@ -163,7 +163,7 @@ void LayerTreeHost::initializeRenderer()
|
||||
// Update m_settings based on partial update capability.
|
||||
m_settings.maxPartialTextureUpdates = min(m_settings.maxPartialTextureUpdates, m_proxy->maxPartialTextureUpdates());
|
||||
|
||||
m_contentsTextureManager = PrioritizedTextureManager::create(0, m_proxy->rendererCapabilities().maxTextureSize, Renderer::ContentPool);
|
||||
m_contentsTextureManager = PrioritizedResourceManager::create(0, m_proxy->rendererCapabilities().maxTextureSize, Renderer::ContentPool);
|
||||
m_surfaceMemoryPlaceholder = m_contentsTextureManager->createTexture(gfx::Size(), GL_RGBA);
|
||||
|
||||
m_rendererInitialized = true;
|
||||
@ -470,7 +470,7 @@ void LayerTreeHost::loseContext(int numTimes)
|
||||
m_proxy->loseContext();
|
||||
}
|
||||
|
||||
PrioritizedTextureManager* LayerTreeHost::contentsTextureManager() const
|
||||
PrioritizedResourceManager* LayerTreeHost::contentsTextureManager() const
|
||||
{
|
||||
return m_contentsTextureManager.get();
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "cc/layer_tree_host_client.h"
|
||||
#include "cc/layer_tree_host_common.h"
|
||||
#include "cc/occlusion_tracker.h"
|
||||
#include "cc/prioritized_texture_manager.h"
|
||||
#include "cc/prioritized_resource_manager.h"
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/rate_limiter.h"
|
||||
#include "cc/rendering_stats.h"
|
||||
@ -44,7 +44,7 @@ class FontAtlas;
|
||||
class Layer;
|
||||
class LayerTreeHostImpl;
|
||||
class LayerTreeHostImplClient;
|
||||
class PrioritizedTextureManager;
|
||||
class PrioritizedResourceManager;
|
||||
class ResourceUpdateQueue;
|
||||
class HeadsUpDisplayLayer;
|
||||
class Region;
|
||||
@ -184,7 +184,7 @@ public:
|
||||
|
||||
void setHasTransparentBackground(bool transparent) { m_hasTransparentBackground = transparent; }
|
||||
|
||||
PrioritizedTextureManager* contentsTextureManager() const;
|
||||
PrioritizedResourceManager* contentsTextureManager() const;
|
||||
|
||||
bool visible() const { return m_visible; }
|
||||
void setVisible(bool);
|
||||
@ -258,8 +258,8 @@ private:
|
||||
scoped_refptr<Layer> m_rootLayer;
|
||||
scoped_refptr<HeadsUpDisplayLayer> m_hudLayer;
|
||||
|
||||
scoped_ptr<PrioritizedTextureManager> m_contentsTextureManager;
|
||||
scoped_ptr<PrioritizedTexture> m_surfaceMemoryPlaceholder;
|
||||
scoped_ptr<PrioritizedResourceManager> m_contentsTextureManager;
|
||||
scoped_ptr<PrioritizedResource> m_surfaceMemoryPlaceholder;
|
||||
|
||||
LayerTreeSettings m_settings;
|
||||
|
||||
@ -280,7 +280,7 @@ private:
|
||||
SkColor m_backgroundColor;
|
||||
bool m_hasTransparentBackground;
|
||||
|
||||
typedef ScopedPtrVector<PrioritizedTexture> TextureList;
|
||||
typedef ScopedPtrVector<PrioritizedResource> TextureList;
|
||||
size_t m_partialTextureUpdateRequests;
|
||||
|
||||
static bool s_needsFilterContext;
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "cc/math_util.h"
|
||||
#include "cc/overdraw_metrics.h"
|
||||
#include "cc/page_scale_animation.h"
|
||||
#include "cc/prioritized_texture_manager.h"
|
||||
#include "cc/prioritized_resource_manager.h"
|
||||
#include "cc/render_pass_draw_quad.h"
|
||||
#include "cc/rendering_stats.h"
|
||||
#include "cc/scrollbar_animation_controller.h"
|
||||
@ -216,7 +216,7 @@ LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
|
||||
, m_deviceScaleFactor(1)
|
||||
, m_visible(true)
|
||||
, m_contentsTexturesPurged(false)
|
||||
, m_managedMemoryPolicy(PrioritizedTextureManager::defaultMemoryAllocationLimit(),
|
||||
, m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationLimit(),
|
||||
PriorityCalculator::allowEverythingCutoff(),
|
||||
0,
|
||||
PriorityCalculator::allowNothingCutoff())
|
||||
|
@ -2637,12 +2637,12 @@ private:
|
||||
{
|
||||
if (m_texture.get())
|
||||
return;
|
||||
m_texture = PrioritizedTexture::create(layerTreeHost()->contentsTextureManager());
|
||||
m_texture = PrioritizedResource::create(layerTreeHost()->contentsTextureManager());
|
||||
m_texture->setDimensions(gfx::Size(10, 10), GL_RGBA);
|
||||
m_bitmap.setConfig(SkBitmap::kARGB_8888_Config, 10, 10);
|
||||
}
|
||||
|
||||
scoped_ptr<PrioritizedTexture> m_texture;
|
||||
scoped_ptr<PrioritizedResource> m_texture;
|
||||
SkBitmap m_bitmap;
|
||||
};
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
namespace cc {
|
||||
|
||||
LayerUpdater::Resource::Resource(scoped_ptr<PrioritizedTexture> texture)
|
||||
LayerUpdater::Resource::Resource(scoped_ptr<PrioritizedResource> texture)
|
||||
: m_texture(texture.Pass())
|
||||
{
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "cc/cc_export.h"
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
#include "third_party/khronos/GLES2/gl2.h"
|
||||
|
||||
namespace gfx {
|
||||
@ -28,21 +28,21 @@ public:
|
||||
public:
|
||||
virtual ~Resource();
|
||||
|
||||
PrioritizedTexture* texture() { return m_texture.get(); }
|
||||
void swapTextureWith(scoped_ptr<PrioritizedTexture>& texture) { m_texture.swap(texture); }
|
||||
PrioritizedResource* texture() { return m_texture.get(); }
|
||||
void swapTextureWith(scoped_ptr<PrioritizedResource>& texture) { m_texture.swap(texture); }
|
||||
// TODO(reveman): partialUpdate should be a property of this class
|
||||
// instead of an argument passed to update().
|
||||
virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) = 0;
|
||||
protected:
|
||||
explicit Resource(scoped_ptr<PrioritizedTexture> texture);
|
||||
explicit Resource(scoped_ptr<PrioritizedResource> texture);
|
||||
|
||||
private:
|
||||
scoped_ptr<PrioritizedTexture> m_texture;
|
||||
scoped_ptr<PrioritizedResource> m_texture;
|
||||
};
|
||||
|
||||
LayerUpdater() { }
|
||||
|
||||
virtual scoped_ptr<Resource> createResource(PrioritizedTextureManager*) = 0;
|
||||
virtual scoped_ptr<Resource> createResource(PrioritizedResourceManager*) = 0;
|
||||
// The |resultingOpaqueRect| gives back a region of the layer that was painted opaque. If the layer is marked opaque in the updater,
|
||||
// then this region should be ignored in preference for the entire layer's area.
|
||||
virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats&) { }
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
|
||||
#include "cc/platform_color.h"
|
||||
#include "cc/prioritized_texture_manager.h"
|
||||
#include "cc/prioritized_resource_manager.h"
|
||||
#include "cc/priority_calculator.h"
|
||||
#include "cc/proxy.h"
|
||||
#include <algorithm>
|
||||
@ -16,7 +16,7 @@ using namespace std;
|
||||
|
||||
namespace cc {
|
||||
|
||||
PrioritizedTexture::PrioritizedTexture(PrioritizedTextureManager* manager, gfx::Size size, GLenum format)
|
||||
PrioritizedResource::PrioritizedResource(PrioritizedResourceManager* manager, gfx::Size size, GLenum format)
|
||||
: m_size(size)
|
||||
, m_format(format)
|
||||
, m_bytes(0)
|
||||
@ -35,13 +35,13 @@ PrioritizedTexture::PrioritizedTexture(PrioritizedTextureManager* manager, gfx::
|
||||
manager->registerTexture(this);
|
||||
}
|
||||
|
||||
PrioritizedTexture::~PrioritizedTexture()
|
||||
PrioritizedResource::~PrioritizedResource()
|
||||
{
|
||||
if (m_manager)
|
||||
m_manager->unregisterTexture(this);
|
||||
}
|
||||
|
||||
void PrioritizedTexture::setTextureManager(PrioritizedTextureManager* manager)
|
||||
void PrioritizedResource::setTextureManager(PrioritizedResourceManager* manager)
|
||||
{
|
||||
if (m_manager == manager)
|
||||
return;
|
||||
@ -51,7 +51,7 @@ void PrioritizedTexture::setTextureManager(PrioritizedTextureManager* manager)
|
||||
manager->registerTexture(this);
|
||||
}
|
||||
|
||||
void PrioritizedTexture::setDimensions(gfx::Size size, GLenum format)
|
||||
void PrioritizedResource::setDimensions(gfx::Size size, GLenum format)
|
||||
{
|
||||
if (m_format != format || m_size != size) {
|
||||
m_isAbovePriorityCutoff = false;
|
||||
@ -64,33 +64,33 @@ void PrioritizedTexture::setDimensions(gfx::Size size, GLenum format)
|
||||
}
|
||||
}
|
||||
|
||||
bool PrioritizedTexture::requestLate()
|
||||
bool PrioritizedResource::requestLate()
|
||||
{
|
||||
if (!m_manager)
|
||||
return false;
|
||||
return m_manager->requestLate(this);
|
||||
}
|
||||
|
||||
bool PrioritizedTexture::backingResourceWasEvicted() const
|
||||
bool PrioritizedResource::backingResourceWasEvicted() const
|
||||
{
|
||||
return m_backing ? m_backing->resourceHasBeenDeleted() : false;
|
||||
}
|
||||
|
||||
void PrioritizedTexture::acquireBackingTexture(ResourceProvider* resourceProvider)
|
||||
void PrioritizedResource::acquireBackingTexture(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(m_isAbovePriorityCutoff);
|
||||
if (m_isAbovePriorityCutoff)
|
||||
m_manager->acquireBackingTextureIfNeeded(this, resourceProvider);
|
||||
}
|
||||
|
||||
ResourceProvider::ResourceId PrioritizedTexture::resourceId() const
|
||||
ResourceProvider::ResourceId PrioritizedResource::resourceId() const
|
||||
{
|
||||
if (m_backing)
|
||||
return m_backing->id();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PrioritizedTexture::setPixels(ResourceProvider* resourceProvider,
|
||||
void PrioritizedResource::setPixels(ResourceProvider* resourceProvider,
|
||||
const uint8_t* image, const gfx::Rect& imageRect,
|
||||
const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset)
|
||||
{
|
||||
@ -106,7 +106,7 @@ void PrioritizedTexture::setPixels(ResourceProvider* resourceProvider,
|
||||
m_contentsSwizzled = !PlatformColor::sameComponentOrder(m_format);
|
||||
}
|
||||
|
||||
void PrioritizedTexture::link(Backing* backing)
|
||||
void PrioritizedResource::link(Backing* backing)
|
||||
{
|
||||
DCHECK(backing);
|
||||
DCHECK(!backing->m_owner);
|
||||
@ -116,7 +116,7 @@ void PrioritizedTexture::link(Backing* backing)
|
||||
m_backing->m_owner = this;
|
||||
}
|
||||
|
||||
void PrioritizedTexture::unlink()
|
||||
void PrioritizedResource::unlink()
|
||||
{
|
||||
DCHECK(m_backing);
|
||||
DCHECK(m_backing->m_owner == this);
|
||||
@ -125,14 +125,14 @@ void PrioritizedTexture::unlink()
|
||||
m_backing = 0;
|
||||
}
|
||||
|
||||
void PrioritizedTexture::setToSelfManagedMemoryPlaceholder(size_t bytes)
|
||||
void PrioritizedResource::setToSelfManagedMemoryPlaceholder(size_t bytes)
|
||||
{
|
||||
setDimensions(gfx::Size(), GL_RGBA);
|
||||
setIsSelfManaged(true);
|
||||
m_bytes = bytes;
|
||||
}
|
||||
|
||||
PrioritizedTexture::Backing::Backing(unsigned id, ResourceProvider* resourceProvider, gfx::Size size, GLenum format)
|
||||
PrioritizedResource::Backing::Backing(unsigned id, ResourceProvider* resourceProvider, gfx::Size size, GLenum format)
|
||||
: Texture(id, size, format)
|
||||
, m_owner(0)
|
||||
, m_priorityAtLastPriorityUpdate(PriorityCalculator::lowestPriority())
|
||||
@ -145,13 +145,13 @@ PrioritizedTexture::Backing::Backing(unsigned id, ResourceProvider* resourceProv
|
||||
{
|
||||
}
|
||||
|
||||
PrioritizedTexture::Backing::~Backing()
|
||||
PrioritizedResource::Backing::~Backing()
|
||||
{
|
||||
DCHECK(!m_owner);
|
||||
DCHECK(m_resourceHasBeenDeleted);
|
||||
}
|
||||
|
||||
void PrioritizedTexture::Backing::deleteResource(ResourceProvider* resourceProvider)
|
||||
void PrioritizedResource::Backing::deleteResource(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DCHECK(!m_resourceHasBeenDeleted);
|
||||
@ -164,19 +164,19 @@ void PrioritizedTexture::Backing::deleteResource(ResourceProvider* resourceProvi
|
||||
m_resourceHasBeenDeleted = true;
|
||||
}
|
||||
|
||||
bool PrioritizedTexture::Backing::resourceHasBeenDeleted() const
|
||||
bool PrioritizedResource::Backing::resourceHasBeenDeleted() const
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
return m_resourceHasBeenDeleted;
|
||||
}
|
||||
|
||||
bool PrioritizedTexture::Backing::canBeRecycled() const
|
||||
bool PrioritizedResource::Backing::canBeRecycled() const
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
return !m_wasAbovePriorityCutoffAtLastPriorityUpdate && !m_inDrawingImplTree;
|
||||
}
|
||||
|
||||
void PrioritizedTexture::Backing::updatePriority()
|
||||
void PrioritizedResource::Backing::updatePriority()
|
||||
{
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
if (m_owner) {
|
||||
@ -188,7 +188,7 @@ void PrioritizedTexture::Backing::updatePriority()
|
||||
}
|
||||
}
|
||||
|
||||
void PrioritizedTexture::Backing::updateInDrawingImplTree()
|
||||
void PrioritizedResource::Backing::updateInDrawingImplTree()
|
||||
{
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
m_inDrawingImplTree = !!owner();
|
||||
@ -196,7 +196,7 @@ void PrioritizedTexture::Backing::updateInDrawingImplTree()
|
||||
DCHECK(m_priorityAtLastPriorityUpdate == PriorityCalculator::lowestPriority());
|
||||
}
|
||||
|
||||
void PrioritizedTexture::returnBackingTexture()
|
||||
void PrioritizedResource::returnBackingTexture()
|
||||
{
|
||||
DCHECK(m_manager || !m_backing);
|
||||
if (m_manager)
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CC_PRIORITIZED_TEXTURE_H_
|
||||
#define CC_PRIORITIZED_TEXTURE_H_
|
||||
#ifndef CC_PRIORITIZED_RESOURCE_H_
|
||||
#define CC_PRIORITIZED_RESOURCE_H_
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/logging.h"
|
||||
@ -19,35 +19,35 @@
|
||||
|
||||
namespace cc {
|
||||
|
||||
class PrioritizedTextureManager;
|
||||
class PrioritizedResourceManager;
|
||||
|
||||
class CC_EXPORT PrioritizedTexture {
|
||||
class CC_EXPORT PrioritizedResource {
|
||||
public:
|
||||
static scoped_ptr<PrioritizedTexture> create(PrioritizedTextureManager* manager, gfx::Size size, GLenum format)
|
||||
static scoped_ptr<PrioritizedResource> create(PrioritizedResourceManager* manager, gfx::Size size, GLenum format)
|
||||
{
|
||||
return make_scoped_ptr(new PrioritizedTexture(manager, size, format));
|
||||
return make_scoped_ptr(new PrioritizedResource(manager, size, format));
|
||||
}
|
||||
static scoped_ptr<PrioritizedTexture> create(PrioritizedTextureManager* manager)
|
||||
static scoped_ptr<PrioritizedResource> create(PrioritizedResourceManager* manager)
|
||||
{
|
||||
return make_scoped_ptr(new PrioritizedTexture(manager, gfx::Size(), 0));
|
||||
return make_scoped_ptr(new PrioritizedResource(manager, gfx::Size(), 0));
|
||||
}
|
||||
~PrioritizedTexture();
|
||||
~PrioritizedResource();
|
||||
|
||||
// Texture properties. Changing these causes the backing texture to be lost.
|
||||
// Setting these to the same value is a no-op.
|
||||
void setTextureManager(PrioritizedTextureManager*);
|
||||
PrioritizedTextureManager* textureManager() { return m_manager; }
|
||||
void setTextureManager(PrioritizedResourceManager*);
|
||||
PrioritizedResourceManager* resourceManager() { return m_manager; }
|
||||
void setDimensions(gfx::Size, GLenum format);
|
||||
GLenum format() const { return m_format; }
|
||||
gfx::Size size() const { return m_size; }
|
||||
size_t bytes() const { return m_bytes; }
|
||||
bool contentsSwizzled() const { return m_contentsSwizzled; }
|
||||
|
||||
// Set priority for the requested texture.
|
||||
// Set priority for the requested texture.
|
||||
void setRequestPriority(int priority) { m_priority = priority; }
|
||||
int requestPriority() const { return m_priority; }
|
||||
|
||||
// After PrioritizedTexture::prioritizeTextures() is called, this returns
|
||||
// After PrioritizedResource::prioritizeTextures() is called, this returns
|
||||
// if the the request succeeded and this texture can be acquired for use.
|
||||
bool canAcquireBackingTexture() const { return m_isAbovePriorityCutoff; }
|
||||
|
||||
@ -88,8 +88,8 @@ public:
|
||||
void returnBackingTexture();
|
||||
|
||||
private:
|
||||
friend class PrioritizedTextureManager;
|
||||
friend class PrioritizedTextureTest;
|
||||
friend class PrioritizedResourceManager;
|
||||
friend class PrioritizedResourceTest;
|
||||
|
||||
class Backing : public Texture {
|
||||
public:
|
||||
@ -98,7 +98,7 @@ private:
|
||||
void updatePriority();
|
||||
void updateInDrawingImplTree();
|
||||
|
||||
PrioritizedTexture* owner() { return m_owner; }
|
||||
PrioritizedResource* owner() { return m_owner; }
|
||||
bool canBeRecycled() const;
|
||||
int requestPriorityAtLastPriorityUpdate() const { return m_priorityAtLastPriorityUpdate; }
|
||||
bool wasAbovePriorityCutoffAtLastPriorityUpdate() const { return m_wasAbovePriorityCutoffAtLastPriorityUpdate; }
|
||||
@ -108,8 +108,8 @@ private:
|
||||
bool resourceHasBeenDeleted() const;
|
||||
|
||||
private:
|
||||
friend class PrioritizedTexture;
|
||||
PrioritizedTexture* m_owner;
|
||||
friend class PrioritizedResource;
|
||||
PrioritizedResource* m_owner;
|
||||
int m_priorityAtLastPriorityUpdate;
|
||||
bool m_wasAbovePriorityCutoffAtLastPriorityUpdate;
|
||||
|
||||
@ -124,11 +124,11 @@ private:
|
||||
DISALLOW_COPY_AND_ASSIGN(Backing);
|
||||
};
|
||||
|
||||
PrioritizedTexture(PrioritizedTextureManager*, gfx::Size, GLenum format);
|
||||
PrioritizedResource(PrioritizedResourceManager*, gfx::Size, GLenum format);
|
||||
|
||||
bool isAbovePriorityCutoff() { return m_isAbovePriorityCutoff; }
|
||||
void setAbovePriorityCutoff(bool isAbovePriorityCutoff) { m_isAbovePriorityCutoff = isAbovePriorityCutoff; }
|
||||
void setManagerInternal(PrioritizedTextureManager* manager) { m_manager = manager; }
|
||||
void setManagerInternal(PrioritizedResourceManager* manager) { m_manager = manager; }
|
||||
|
||||
Backing* backing() const { return m_backing; }
|
||||
void link(Backing*);
|
||||
@ -144,11 +144,11 @@ private:
|
||||
bool m_isSelfManaged;
|
||||
|
||||
Backing* m_backing;
|
||||
PrioritizedTextureManager* m_manager;
|
||||
PrioritizedResourceManager* m_manager;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PrioritizedTexture);
|
||||
DISALLOW_COPY_AND_ASSIGN(PrioritizedResource);
|
||||
};
|
||||
|
||||
} // namespace cc
|
||||
|
||||
#endif // CC_PRIORITIZED_TEXTURE_H_
|
||||
#endif // CC_PRIORITIZED_RESOURCE_H_
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "cc/prioritized_texture_manager.h"
|
||||
#include "cc/prioritized_resource_manager.h"
|
||||
|
||||
#include "base/debug/trace_event.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
#include "cc/priority_calculator.h"
|
||||
#include "cc/proxy.h"
|
||||
#include <algorithm>
|
||||
@ -17,7 +17,7 @@ using namespace std;
|
||||
|
||||
namespace cc {
|
||||
|
||||
PrioritizedTextureManager::PrioritizedTextureManager(size_t maxMemoryLimitBytes, int, int pool)
|
||||
PrioritizedResourceManager::PrioritizedResourceManager(size_t maxMemoryLimitBytes, int, int pool)
|
||||
: m_maxMemoryLimitBytes(maxMemoryLimitBytes)
|
||||
, m_externalPriorityCutoff(PriorityCalculator::allowEverythingCutoff())
|
||||
, m_memoryUseBytes(0)
|
||||
@ -32,7 +32,7 @@ PrioritizedTextureManager::PrioritizedTextureManager(size_t maxMemoryLimitBytes,
|
||||
{
|
||||
}
|
||||
|
||||
PrioritizedTextureManager::~PrioritizedTextureManager()
|
||||
PrioritizedResourceManager::~PrioritizedResourceManager()
|
||||
{
|
||||
while (m_textures.size() > 0)
|
||||
unregisterTexture(*m_textures.begin());
|
||||
@ -44,21 +44,21 @@ PrioritizedTextureManager::~PrioritizedTextureManager()
|
||||
DCHECK(m_backings.empty());
|
||||
}
|
||||
|
||||
size_t PrioritizedTextureManager::memoryVisibleBytes() const
|
||||
size_t PrioritizedResourceManager::memoryVisibleBytes() const
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
return m_memoryVisibleLastPushedBytes;
|
||||
}
|
||||
|
||||
size_t PrioritizedTextureManager::memoryVisibleAndNearbyBytes() const
|
||||
size_t PrioritizedResourceManager::memoryVisibleAndNearbyBytes() const
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
return m_memoryVisibleAndNearbyLastPushedBytes;
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::prioritizeTextures()
|
||||
void PrioritizedResourceManager::prioritizeTextures()
|
||||
{
|
||||
TRACE_EVENT0("cc", "PrioritizedTextureManager::prioritizeTextures");
|
||||
TRACE_EVENT0("cc", "PrioritizedResourceManager::prioritizeTextures");
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
// Sorting textures in this function could be replaced by a slightly
|
||||
@ -72,12 +72,12 @@ void PrioritizedTextureManager::prioritizeTextures()
|
||||
m_memoryVisibleBytes = 0;
|
||||
m_memoryVisibleAndNearbyBytes = 0;
|
||||
for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) {
|
||||
PrioritizedTexture* texture = (*it);
|
||||
PrioritizedResource* texture = (*it);
|
||||
sortedTextures.push_back(texture);
|
||||
if (PriorityCalculator::priorityIsHigher(texture->requestPriority(), PriorityCalculator::allowVisibleOnlyCutoff()))
|
||||
m_memoryVisibleBytes += texture->bytes();
|
||||
if (PriorityCalculator::priorityIsHigher(texture->requestPriority(), PriorityCalculator::allowVisibleAndNearbyCutoff()))
|
||||
m_memoryVisibleAndNearbyBytes += texture->bytes();
|
||||
m_memoryVisibleAndNearbyBytes += texture->bytes();
|
||||
}
|
||||
std::sort(sortedTextures.begin(), sortedTextures.end(), compareTextures);
|
||||
|
||||
@ -109,7 +109,7 @@ void PrioritizedTextureManager::prioritizeTextures()
|
||||
// Disallow any textures with priority below the external cutoff to have backings.
|
||||
size_t memoryLinkedTexturesBytes = 0;
|
||||
for (TextureVector::iterator it = sortedTextures.begin(); it != sortedTextures.end(); ++it) {
|
||||
PrioritizedTexture* texture = (*it);
|
||||
PrioritizedResource* texture = (*it);
|
||||
if (!PriorityCalculator::priorityIsHigher(texture->requestPriority(), m_externalPriorityCutoff) &&
|
||||
texture->haveBackingTexture())
|
||||
texture->unlink();
|
||||
@ -132,9 +132,9 @@ void PrioritizedTextureManager::prioritizeTextures()
|
||||
DCHECK(memoryAboveCutoffBytes() <= maxMemoryLimitBytes());
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::pushTexturePrioritiesToBackings()
|
||||
void PrioritizedResourceManager::pushTexturePrioritiesToBackings()
|
||||
{
|
||||
TRACE_EVENT0("cc", "PrioritizedTextureManager::pushTexturePrioritiesToBackings");
|
||||
TRACE_EVENT0("cc", "PrioritizedResourceManager::pushTexturePrioritiesToBackings");
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
|
||||
assertInvariants();
|
||||
@ -148,23 +148,23 @@ void PrioritizedTextureManager::pushTexturePrioritiesToBackings()
|
||||
m_memoryVisibleAndNearbyLastPushedBytes = m_memoryVisibleAndNearbyBytes;
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::updateBackingsInDrawingImplTree()
|
||||
void PrioritizedResourceManager::updateBackingsInDrawingImplTree()
|
||||
{
|
||||
TRACE_EVENT0("cc", "PrioritizedTextureManager::updateBackingsInDrawingImplTree");
|
||||
TRACE_EVENT0("cc", "PrioritizedResourceManager::updateBackingsInDrawingImplTree");
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
|
||||
assertInvariants();
|
||||
for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
|
||||
PrioritizedTexture::Backing* backing = (*it);
|
||||
PrioritizedResource::Backing* backing = (*it);
|
||||
backing->updateInDrawingImplTree();
|
||||
}
|
||||
sortBackings();
|
||||
assertInvariants();
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::sortBackings()
|
||||
void PrioritizedResourceManager::sortBackings()
|
||||
{
|
||||
TRACE_EVENT0("cc", "PrioritizedTextureManager::sortBackings");
|
||||
TRACE_EVENT0("cc", "PrioritizedResourceManager::sortBackings");
|
||||
DCHECK(Proxy::isImplThread());
|
||||
|
||||
// Put backings in eviction/recycling order.
|
||||
@ -172,7 +172,7 @@ void PrioritizedTextureManager::sortBackings()
|
||||
m_backingsTailNotSorted = false;
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::clearPriorities()
|
||||
void PrioritizedResourceManager::clearPriorities()
|
||||
{
|
||||
DCHECK(Proxy::isMainThread());
|
||||
for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) {
|
||||
@ -184,7 +184,7 @@ void PrioritizedTextureManager::clearPriorities()
|
||||
}
|
||||
}
|
||||
|
||||
bool PrioritizedTextureManager::requestLate(PrioritizedTexture* texture)
|
||||
bool PrioritizedResourceManager::requestLate(PrioritizedResource* texture)
|
||||
{
|
||||
DCHECK(Proxy::isMainThread());
|
||||
|
||||
@ -209,7 +209,7 @@ bool PrioritizedTextureManager::requestLate(PrioritizedTexture* texture)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::acquireBackingTextureIfNeeded(PrioritizedTexture* texture, ResourceProvider* resourceProvider)
|
||||
void PrioritizedResourceManager::acquireBackingTextureIfNeeded(PrioritizedResource* texture, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
DCHECK(!texture->isSelfManaged());
|
||||
@ -218,7 +218,7 @@ void PrioritizedTextureManager::acquireBackingTextureIfNeeded(PrioritizedTexture
|
||||
return;
|
||||
|
||||
// Find a backing below, by either recycling or allocating.
|
||||
PrioritizedTexture::Backing* backing = 0;
|
||||
PrioritizedResource::Backing* backing = 0;
|
||||
|
||||
// First try to recycle
|
||||
for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
|
||||
@ -249,7 +249,7 @@ void PrioritizedTextureManager::acquireBackingTextureIfNeeded(PrioritizedTexture
|
||||
backing->updatePriority();
|
||||
}
|
||||
|
||||
bool PrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, int priorityCutoff, EvictionPolicy evictionPolicy, ResourceProvider* resourceProvider)
|
||||
bool PrioritizedResourceManager::evictBackingsToReduceMemory(size_t limitBytes, int priorityCutoff, EvictionPolicy evictionPolicy, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
if (memoryUseBytes() <= limitBytes && PriorityCalculator::allowEverythingCutoff() == priorityCutoff)
|
||||
@ -258,7 +258,7 @@ bool PrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, i
|
||||
// Destroy backings until we are below the limit,
|
||||
// or until all backings remaining are above the cutoff.
|
||||
while (m_backings.size() > 0) {
|
||||
PrioritizedTexture::Backing* backing = m_backings.front();
|
||||
PrioritizedResource::Backing* backing = m_backings.front();
|
||||
if (memoryUseBytes() <= limitBytes &&
|
||||
PriorityCalculator::priorityIsHigher(backing->requestPriorityAtLastPriorityUpdate(), priorityCutoff))
|
||||
break;
|
||||
@ -269,12 +269,12 @@ bool PrioritizedTextureManager::evictBackingsToReduceMemory(size_t limitBytes, i
|
||||
return true;
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::reduceMemory(ResourceProvider* resourceProvider)
|
||||
void PrioritizedResourceManager::reduceMemory(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
|
||||
// Note that it will not always be the case that memoryUseBytes() <= maxMemoryLimitBytes(),
|
||||
// because we are not at liberty to delete textures that are referenced by the impl tree to
|
||||
// because we are not at liberty to delete textures that are referenced by the impl tree to
|
||||
// get more space.
|
||||
|
||||
evictBackingsToReduceMemory(m_memoryAvailableBytes, PriorityCalculator::allowEverythingCutoff(), EvictOnlyRecyclable, resourceProvider);
|
||||
@ -304,14 +304,14 @@ void PrioritizedTextureManager::reduceMemory(ResourceProvider* resourceProvider)
|
||||
deleteUnlinkedEvictedBackings();
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::clearAllMemory(ResourceProvider* resourceProvider)
|
||||
void PrioritizedResourceManager::clearAllMemory(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
DCHECK(resourceProvider);
|
||||
evictBackingsToReduceMemory(0, PriorityCalculator::allowEverythingCutoff(), EvictAnything, resourceProvider);
|
||||
}
|
||||
|
||||
bool PrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, int priorityCutoff, ResourceProvider* resourceProvider)
|
||||
bool PrioritizedResourceManager::reduceMemoryOnImplThread(size_t limitBytes, int priorityCutoff, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DCHECK(resourceProvider);
|
||||
@ -322,29 +322,29 @@ bool PrioritizedTextureManager::reduceMemoryOnImplThread(size_t limitBytes, int
|
||||
return evictBackingsToReduceMemory(limitBytes, priorityCutoff, EvictAnything, resourceProvider);
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::getEvictedBackings(BackingList& evictedBackings)
|
||||
void PrioritizedResourceManager::getEvictedBackings(BackingList& evictedBackings)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
evictedBackings.clear();
|
||||
evictedBackings.insert(evictedBackings.begin(), m_evictedBackings.begin(), m_evictedBackings.end());
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::unlinkEvictedBackings(const BackingList& evictedBackings)
|
||||
void PrioritizedResourceManager::unlinkEvictedBackings(const BackingList& evictedBackings)
|
||||
{
|
||||
DCHECK(Proxy::isMainThread());
|
||||
for (BackingList::const_iterator it = evictedBackings.begin(); it != evictedBackings.end(); ++it) {
|
||||
PrioritizedTexture::Backing* backing = (*it);
|
||||
PrioritizedResource::Backing* backing = (*it);
|
||||
if (backing->owner())
|
||||
backing->owner()->unlink();
|
||||
}
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::deleteUnlinkedEvictedBackings()
|
||||
void PrioritizedResourceManager::deleteUnlinkedEvictedBackings()
|
||||
{
|
||||
DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked()));
|
||||
BackingList newEvictedBackings;
|
||||
for (BackingList::const_iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) {
|
||||
PrioritizedTexture::Backing* backing = (*it);
|
||||
PrioritizedResource::Backing* backing = (*it);
|
||||
if (backing->owner())
|
||||
newEvictedBackings.push_back(backing);
|
||||
else
|
||||
@ -353,7 +353,7 @@ void PrioritizedTextureManager::deleteUnlinkedEvictedBackings()
|
||||
m_evictedBackings.swap(newEvictedBackings);
|
||||
}
|
||||
|
||||
bool PrioritizedTextureManager::linkedEvictedBackingsExist() const
|
||||
bool PrioritizedResourceManager::linkedEvictedBackingsExist() const
|
||||
{
|
||||
for (BackingList::const_iterator it = m_evictedBackings.begin(); it != m_evictedBackings.end(); ++it) {
|
||||
if ((*it)->owner())
|
||||
@ -362,11 +362,11 @@ bool PrioritizedTextureManager::linkedEvictedBackingsExist() const
|
||||
return false;
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::registerTexture(PrioritizedTexture* texture)
|
||||
void PrioritizedResourceManager::registerTexture(PrioritizedResource* texture)
|
||||
{
|
||||
DCHECK(Proxy::isMainThread());
|
||||
DCHECK(texture);
|
||||
DCHECK(!texture->textureManager());
|
||||
DCHECK(!texture->resourceManager());
|
||||
DCHECK(!texture->backing());
|
||||
DCHECK(!ContainsKey(m_textures, texture));
|
||||
|
||||
@ -375,7 +375,7 @@ void PrioritizedTextureManager::registerTexture(PrioritizedTexture* texture)
|
||||
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::unregisterTexture(PrioritizedTexture* texture)
|
||||
void PrioritizedResourceManager::unregisterTexture(PrioritizedResource* texture)
|
||||
{
|
||||
DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked()));
|
||||
DCHECK(texture);
|
||||
@ -387,29 +387,29 @@ void PrioritizedTextureManager::unregisterTexture(PrioritizedTexture* texture)
|
||||
texture->setAbovePriorityCutoff(false);
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::returnBackingTexture(PrioritizedTexture* texture)
|
||||
void PrioritizedResourceManager::returnBackingTexture(PrioritizedResource* texture)
|
||||
{
|
||||
DCHECK(Proxy::isMainThread() || (Proxy::isImplThread() && Proxy::isMainThreadBlocked()));
|
||||
if (texture->backing())
|
||||
texture->unlink();
|
||||
}
|
||||
|
||||
PrioritizedTexture::Backing* PrioritizedTextureManager::createBacking(gfx::Size size, GLenum format, ResourceProvider* resourceProvider)
|
||||
PrioritizedResource::Backing* PrioritizedResourceManager::createBacking(gfx::Size size, GLenum format, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
DCHECK(resourceProvider);
|
||||
ResourceProvider::ResourceId resourceId = resourceProvider->createResource(m_pool, size, format, ResourceProvider::TextureUsageAny);
|
||||
PrioritizedTexture::Backing* backing = new PrioritizedTexture::Backing(resourceId, resourceProvider, size, format);
|
||||
PrioritizedResource::Backing* backing = new PrioritizedResource::Backing(resourceId, resourceProvider, size, format);
|
||||
m_memoryUseBytes += backing->bytes();
|
||||
return backing;
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::evictFirstBackingResource(ResourceProvider* resourceProvider)
|
||||
void PrioritizedResourceManager::evictFirstBackingResource(ResourceProvider* resourceProvider)
|
||||
{
|
||||
DCHECK(Proxy::isImplThread());
|
||||
DCHECK(resourceProvider);
|
||||
DCHECK(!m_backings.empty());
|
||||
PrioritizedTexture::Backing* backing = m_backings.front();
|
||||
PrioritizedResource::Backing* backing = m_backings.front();
|
||||
|
||||
// Note that we create a backing and its resource at the same time, but we
|
||||
// delete the backing structure and its resource in two steps. This is because
|
||||
@ -421,7 +421,7 @@ void PrioritizedTextureManager::evictFirstBackingResource(ResourceProvider* reso
|
||||
m_evictedBackings.push_back(backing);
|
||||
}
|
||||
|
||||
void PrioritizedTextureManager::assertInvariants()
|
||||
void PrioritizedResourceManager::assertInvariants()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
DCHECK(Proxy::isImplThread() && Proxy::isMainThreadBlocked());
|
||||
@ -438,8 +438,8 @@ void PrioritizedTextureManager::assertInvariants()
|
||||
}
|
||||
}
|
||||
for (TextureSet::iterator it = m_textures.begin(); it != m_textures.end(); ++it) {
|
||||
PrioritizedTexture* texture = (*it);
|
||||
PrioritizedTexture::Backing* backing = texture->backing();
|
||||
PrioritizedResource* texture = (*it);
|
||||
PrioritizedResource::Backing* backing = texture->backing();
|
||||
if (backing) {
|
||||
if (backing->resourceHasBeenDeleted()) {
|
||||
DCHECK(std::find(m_backings.begin(), m_backings.end(), backing) == m_backings.end());
|
||||
@ -456,9 +456,9 @@ void PrioritizedTextureManager::assertInvariants()
|
||||
// backings that can't be evicted in the backing texture list (otherwise
|
||||
// reduceMemory will not find all textures available for eviction/recycling).
|
||||
bool reachedUnrecyclable = false;
|
||||
PrioritizedTexture::Backing* previous_backing = NULL;
|
||||
PrioritizedResource::Backing* previous_backing = NULL;
|
||||
for (BackingList::iterator it = m_backings.begin(); it != m_backings.end(); ++it) {
|
||||
PrioritizedTexture::Backing* backing = *it;
|
||||
PrioritizedResource::Backing* backing = *it;
|
||||
if (previous_backing && (!m_backingsTailNotSorted || !backing->wasAbovePriorityCutoffAtLastPriorityUpdate()))
|
||||
DCHECK(compareBackings(previous_backing, backing));
|
||||
if (!backing->canBeRecycled())
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CC_PRIORITIZED_TEXTURE_MANAGER_H_
|
||||
#define CC_PRIORITIZED_TEXTURE_MANAGER_H_
|
||||
#ifndef CC_PRIORITIZED_RESOURCE_MANAGER_H_
|
||||
#define CC_PRIORITIZED_RESOURCE_MANAGER_H_
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
@ -12,7 +12,7 @@
|
||||
#include "base/hash_tables.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "cc/cc_export.h"
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
#include "cc/priority_calculator.h"
|
||||
#include "cc/texture.h"
|
||||
#include "third_party/khronos/GLES2/gl2.h"
|
||||
@ -21,8 +21,8 @@
|
||||
#if defined(COMPILER_GCC)
|
||||
namespace BASE_HASH_NAMESPACE {
|
||||
template<>
|
||||
struct hash<cc::PrioritizedTexture*> {
|
||||
size_t operator()(cc::PrioritizedTexture* ptr) const {
|
||||
struct hash<cc::PrioritizedResource*> {
|
||||
size_t operator()(cc::PrioritizedResource* ptr) const {
|
||||
return hash<size_t>()(reinterpret_cast<size_t>(ptr));
|
||||
}
|
||||
};
|
||||
@ -33,19 +33,19 @@ namespace cc {
|
||||
|
||||
class PriorityCalculator;
|
||||
|
||||
class CC_EXPORT PrioritizedTextureManager {
|
||||
class CC_EXPORT PrioritizedResourceManager {
|
||||
public:
|
||||
static scoped_ptr<PrioritizedTextureManager> create(size_t maxMemoryLimitBytes, int maxTextureSize, int pool)
|
||||
static scoped_ptr<PrioritizedResourceManager> create(size_t maxMemoryLimitBytes, int maxTextureSize, int pool)
|
||||
{
|
||||
return make_scoped_ptr(new PrioritizedTextureManager(maxMemoryLimitBytes, maxTextureSize, pool));
|
||||
return make_scoped_ptr(new PrioritizedResourceManager(maxMemoryLimitBytes, maxTextureSize, pool));
|
||||
}
|
||||
scoped_ptr<PrioritizedTexture> createTexture(gfx::Size size, GLenum format)
|
||||
scoped_ptr<PrioritizedResource> createTexture(gfx::Size size, GLenum format)
|
||||
{
|
||||
return make_scoped_ptr(new PrioritizedTexture(this, size, format));
|
||||
return make_scoped_ptr(new PrioritizedResource(this, size, format));
|
||||
}
|
||||
~PrioritizedTextureManager();
|
||||
~PrioritizedResourceManager();
|
||||
|
||||
typedef std::list<PrioritizedTexture::Backing*> BackingList;
|
||||
typedef std::list<PrioritizedResource::Backing*> BackingList;
|
||||
|
||||
// FIXME (http://crbug.com/137094): This 64MB default is a straggler from the
|
||||
// old texture manager and is just to give us a default memory allocation before
|
||||
@ -91,16 +91,16 @@ public:
|
||||
// before updating layers.
|
||||
void unlinkEvictedBackings(const BackingList& evictedBackings);
|
||||
|
||||
bool requestLate(PrioritizedTexture*);
|
||||
bool requestLate(PrioritizedResource*);
|
||||
|
||||
void reduceMemory(ResourceProvider*);
|
||||
void clearAllMemory(ResourceProvider*);
|
||||
|
||||
void acquireBackingTextureIfNeeded(PrioritizedTexture*, ResourceProvider*);
|
||||
void acquireBackingTextureIfNeeded(PrioritizedResource*, ResourceProvider*);
|
||||
|
||||
void registerTexture(PrioritizedTexture*);
|
||||
void unregisterTexture(PrioritizedTexture*);
|
||||
void returnBackingTexture(PrioritizedTexture*);
|
||||
void registerTexture(PrioritizedResource*);
|
||||
void unregisterTexture(PrioritizedResource*);
|
||||
void returnBackingTexture(PrioritizedResource*);
|
||||
|
||||
// Update all backings' priorities from their owning texture.
|
||||
void pushTexturePrioritiesToBackings();
|
||||
@ -109,7 +109,7 @@ public:
|
||||
void updateBackingsInDrawingImplTree();
|
||||
|
||||
private:
|
||||
friend class PrioritizedTextureTest;
|
||||
friend class PrioritizedResourceTest;
|
||||
|
||||
enum EvictionPolicy {
|
||||
EvictOnlyRecyclable,
|
||||
@ -117,14 +117,14 @@ private:
|
||||
};
|
||||
|
||||
// Compare textures. Highest priority first.
|
||||
static inline bool compareTextures(PrioritizedTexture* a, PrioritizedTexture* b)
|
||||
static inline bool compareTextures(PrioritizedResource* a, PrioritizedResource* b)
|
||||
{
|
||||
if (a->requestPriority() == b->requestPriority())
|
||||
return a < b;
|
||||
return PriorityCalculator::priorityIsHigher(a->requestPriority(), b->requestPriority());
|
||||
}
|
||||
// Compare backings. Lowest priority first.
|
||||
static inline bool compareBackings(PrioritizedTexture::Backing* a, PrioritizedTexture::Backing* b)
|
||||
static inline bool compareBackings(PrioritizedResource::Backing* a, PrioritizedResource::Backing* b)
|
||||
{
|
||||
// Make textures that can be recycled appear first
|
||||
if (a->canBeRecycled() != b->canBeRecycled())
|
||||
@ -142,10 +142,10 @@ private:
|
||||
return a < b;
|
||||
}
|
||||
|
||||
PrioritizedTextureManager(size_t maxMemoryLimitBytes, int maxTextureSize, int pool);
|
||||
PrioritizedResourceManager(size_t maxMemoryLimitBytes, int maxTextureSize, int pool);
|
||||
|
||||
bool evictBackingsToReduceMemory(size_t limitBytes, int priorityCutoff, EvictionPolicy, ResourceProvider*);
|
||||
PrioritizedTexture::Backing* createBacking(gfx::Size, GLenum format, ResourceProvider*);
|
||||
PrioritizedResource::Backing* createBacking(gfx::Size, GLenum format, ResourceProvider*);
|
||||
void evictFirstBackingResource(ResourceProvider*);
|
||||
void deleteUnlinkedEvictedBackings();
|
||||
void sortBackings();
|
||||
@ -165,8 +165,8 @@ private:
|
||||
size_t m_memoryAvailableBytes;
|
||||
int m_pool;
|
||||
|
||||
typedef base::hash_set<PrioritizedTexture*> TextureSet;
|
||||
typedef std::vector<PrioritizedTexture*> TextureVector;
|
||||
typedef base::hash_set<PrioritizedResource*> TextureSet;
|
||||
typedef std::vector<PrioritizedResource*> TextureVector;
|
||||
|
||||
TextureSet m_textures;
|
||||
// This list is always sorted in eviction order, with the exception the
|
||||
@ -186,9 +186,9 @@ private:
|
||||
size_t m_memoryVisibleLastPushedBytes;
|
||||
size_t m_memoryVisibleAndNearbyLastPushedBytes;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PrioritizedTextureManager);
|
||||
DISALLOW_COPY_AND_ASSIGN(PrioritizedResourceManager);
|
||||
};
|
||||
|
||||
} // namespace cc
|
||||
|
||||
#endif // CC_PRIORITIZED_TEXTURE_MANAGER_H_
|
||||
#endif // CC_PRIORITIZED_RESOURCE_MANAGER_H_
|
@ -4,9 +4,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
|
||||
#include "cc/prioritized_texture_manager.h"
|
||||
#include "cc/prioritized_resource_manager.h"
|
||||
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
|
||||
#include "cc/test/fake_graphics_context.h"
|
||||
#include "cc/test/tiled_layer_test_common.h"
|
||||
@ -18,9 +18,9 @@ using namespace WebKitTests;
|
||||
|
||||
namespace cc {
|
||||
|
||||
class PrioritizedTextureTest : public testing::Test {
|
||||
class PrioritizedResourceTest : public testing::Test {
|
||||
public:
|
||||
PrioritizedTextureTest()
|
||||
PrioritizedResourceTest()
|
||||
: m_textureSize(256, 256)
|
||||
, m_textureFormat(GL_RGBA)
|
||||
, m_context(WebKit::createFakeGraphicsContext())
|
||||
@ -29,7 +29,7 @@ public:
|
||||
m_resourceProvider = ResourceProvider::create(m_context.get());
|
||||
}
|
||||
|
||||
virtual ~PrioritizedTextureTest()
|
||||
virtual ~PrioritizedResourceTest()
|
||||
{
|
||||
DebugScopedSetImplThread implThread;
|
||||
m_resourceProvider.reset();
|
||||
@ -40,17 +40,17 @@ public:
|
||||
return Texture::memorySizeBytes(m_textureSize, m_textureFormat) * textureCount;
|
||||
}
|
||||
|
||||
scoped_ptr<PrioritizedTextureManager> createManager(size_t maxTextures)
|
||||
scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures)
|
||||
{
|
||||
return PrioritizedTextureManager::create(texturesMemorySize(maxTextures), 1024, 0);
|
||||
return PrioritizedResourceManager::create(texturesMemorySize(maxTextures), 1024, 0);
|
||||
}
|
||||
|
||||
bool validateTexture(scoped_ptr<PrioritizedTexture>& texture, bool requestLate)
|
||||
bool validateTexture(scoped_ptr<PrioritizedResource>& texture, bool requestLate)
|
||||
{
|
||||
textureManagerAssertInvariants(texture->textureManager());
|
||||
resourceManagerAssertInvariants(texture->resourceManager());
|
||||
if (requestLate)
|
||||
texture->requestLate();
|
||||
textureManagerAssertInvariants(texture->textureManager());
|
||||
resourceManagerAssertInvariants(texture->resourceManager());
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
bool success = texture->canAcquireBackingTexture();
|
||||
if (success)
|
||||
@ -58,16 +58,16 @@ public:
|
||||
return success;
|
||||
}
|
||||
|
||||
void prioritizeTexturesAndBackings(PrioritizedTextureManager* textureManager)
|
||||
void prioritizeTexturesAndBackings(PrioritizedResourceManager* resourceManager)
|
||||
{
|
||||
textureManager->prioritizeTextures();
|
||||
textureManagerUpdateBackingsPriorities(textureManager);
|
||||
resourceManager->prioritizeTextures();
|
||||
resourceManagerUpdateBackingsPriorities(resourceManager);
|
||||
}
|
||||
|
||||
void textureManagerUpdateBackingsPriorities(PrioritizedTextureManager* textureManager)
|
||||
void resourceManagerUpdateBackingsPriorities(PrioritizedResourceManager* resourceManager)
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->pushTexturePrioritiesToBackings();
|
||||
resourceManager->pushTexturePrioritiesToBackings();
|
||||
}
|
||||
|
||||
ResourceProvider* resourceProvider()
|
||||
@ -75,15 +75,15 @@ public:
|
||||
return m_resourceProvider.get();
|
||||
}
|
||||
|
||||
void textureManagerAssertInvariants(PrioritizedTextureManager* textureManager)
|
||||
void resourceManagerAssertInvariants(PrioritizedResourceManager* resourceManager)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->assertInvariants();
|
||||
resourceManager->assertInvariants();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool textureBackingIsAbovePriorityCutoff(PrioritizedTexture* texture)
|
||||
bool textureBackingIsAbovePriorityCutoff(PrioritizedResource* texture)
|
||||
{
|
||||
return texture->m_backing->wasAbovePriorityCutoffAtLastPriorityUpdate();
|
||||
}
|
||||
@ -99,23 +99,23 @@ protected:
|
||||
|
||||
namespace {
|
||||
|
||||
TEST_F(PrioritizedTextureTest, requestTextureExceedingMaxLimit)
|
||||
TEST_F(PrioritizedResourceTest, requestTextureExceedingMaxLimit)
|
||||
{
|
||||
const size_t maxTextures = 8;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
|
||||
// Create textures for double our memory limit.
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures*2];
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures*2];
|
||||
|
||||
for (size_t i = 0; i < maxTextures*2; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
// Set decreasing priorities
|
||||
for (size_t i = 0; i < maxTextures*2; ++i)
|
||||
textures[i]->setRequestPriority(100 + i);
|
||||
|
||||
// Only lower half should be available.
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
EXPECT_TRUE(validateTexture(textures[0], false));
|
||||
EXPECT_TRUE(validateTexture(textures[7], false));
|
||||
EXPECT_FALSE(validateTexture(textures[8], false));
|
||||
@ -126,154 +126,154 @@ TEST_F(PrioritizedTextureTest, requestTextureExceedingMaxLimit)
|
||||
textures[i]->setRequestPriority(100 - i);
|
||||
|
||||
// Only upper half should be available.
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
EXPECT_FALSE(validateTexture(textures[0], false));
|
||||
EXPECT_FALSE(validateTexture(textures[7], false));
|
||||
EXPECT_TRUE(validateTexture(textures[8], false));
|
||||
EXPECT_TRUE(validateTexture(textures[15], false));
|
||||
|
||||
EXPECT_EQ(texturesMemorySize(maxTextures), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(maxTextures), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, changeMemoryLimits)
|
||||
TEST_F(PrioritizedResourceTest, changeMemoryLimits)
|
||||
{
|
||||
const size_t maxTextures = 8;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures];
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures];
|
||||
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i]->setRequestPriority(100 + i);
|
||||
|
||||
// Set max limit to 8 textures
|
||||
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
validateTexture(textures[i], false);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
resourceManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
|
||||
EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(8), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
// Set max limit to 5 textures
|
||||
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(5));
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(5));
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], false), i < 5);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
resourceManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
|
||||
EXPECT_EQ(texturesMemorySize(5), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(5), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
// Set max limit to 4 textures
|
||||
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(4));
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(4));
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
resourceManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, changePriorityCutoff)
|
||||
TEST_F(PrioritizedResourceTest, changePriorityCutoff)
|
||||
{
|
||||
const size_t maxTextures = 8;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures];
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures];
|
||||
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i]->setRequestPriority(100 + i);
|
||||
|
||||
// Set the cutoff to drop two textures. Try to requestLate on all textures, and
|
||||
// make sure that requestLate doesn't work on a texture with equal priority to
|
||||
// the cutoff.
|
||||
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
|
||||
textureManager->setExternalPriorityCutoff(106);
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
|
||||
resourceManager->setExternalPriorityCutoff(106);
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], true), i < 6);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
resourceManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(6), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
// Set the cutoff to drop two more textures.
|
||||
textureManager->setExternalPriorityCutoff(104);
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
resourceManager->setExternalPriorityCutoff(104);
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
resourceManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
// Do a one-time eviction for one more texture based on priority cutoff
|
||||
PrioritizedTextureManager::BackingList evictedBackings;
|
||||
PrioritizedResourceManager::BackingList evictedBackings;
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, resourceProvider());
|
||||
textureManager->getEvictedBackings(evictedBackings);
|
||||
resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 104, resourceProvider());
|
||||
resourceManager->getEvictedBackings(evictedBackings);
|
||||
EXPECT_EQ(0, evictedBackings.size());
|
||||
textureManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, resourceProvider());
|
||||
textureManager->getEvictedBackings(evictedBackings);
|
||||
resourceManager->reduceMemoryOnImplThread(texturesMemorySize(8), 103, resourceProvider());
|
||||
resourceManager->getEvictedBackings(evictedBackings);
|
||||
EXPECT_EQ(1, evictedBackings.size());
|
||||
}
|
||||
textureManager->unlinkEvictedBackings(evictedBackings);
|
||||
EXPECT_EQ(texturesMemorySize(3), textureManager->memoryUseBytes());
|
||||
resourceManager->unlinkEvictedBackings(evictedBackings);
|
||||
EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryUseBytes());
|
||||
|
||||
// Re-allocate the the texture after the one-time drop.
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
EXPECT_EQ(validateTexture(textures[i], false), i < 4);
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->reduceMemory(resourceProvider());
|
||||
resourceManager->reduceMemory(resourceProvider());
|
||||
}
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures)
|
||||
TEST_F(PrioritizedResourceTest, resourceManagerPartialUpdateTextures)
|
||||
{
|
||||
const size_t maxTextures = 4;
|
||||
const size_t numTextures = 4;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedTexture> textures[numTextures];
|
||||
scoped_ptr<PrioritizedTexture> moreTextures[numTextures];
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedResource> textures[numTextures];
|
||||
scoped_ptr<PrioritizedResource> moreTextures[numTextures];
|
||||
|
||||
for (size_t i = 0; i < numTextures; ++i) {
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
moreTextures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
moreTextures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < numTextures; ++i)
|
||||
textures[i]->setRequestPriority(200 + i);
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
|
||||
// Allocate textures which are currently high priority.
|
||||
EXPECT_TRUE(validateTexture(textures[0], false));
|
||||
@ -288,7 +288,7 @@ TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures)
|
||||
|
||||
for (size_t i = 0; i < numTextures; ++i)
|
||||
moreTextures[i]->setRequestPriority(100 + i);
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
|
||||
// Textures are now below cutoff.
|
||||
EXPECT_FALSE(validateTexture(textures[0], false));
|
||||
@ -315,17 +315,17 @@ TEST_F(PrioritizedTextureTest, textureManagerPartialUpdateTextures)
|
||||
EXPECT_FALSE(textures[3]->haveBackingTexture());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual)
|
||||
TEST_F(PrioritizedResourceTest, resourceManagerPrioritiesAreEqual)
|
||||
{
|
||||
const size_t maxTextures = 16;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures];
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures];
|
||||
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
// All 16 textures have the same priority except 2 higher priority.
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
@ -334,16 +334,16 @@ TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual)
|
||||
textures[1]->setRequestPriority(99);
|
||||
|
||||
// Set max limit to 8 textures
|
||||
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(8));
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
|
||||
// The two high priority textures should be available, others should not.
|
||||
for (size_t i = 0; i < 2; ++i)
|
||||
EXPECT_TRUE(validateTexture(textures[i], false));
|
||||
for (size_t i = 2; i < maxTextures; ++i)
|
||||
EXPECT_FALSE(validateTexture(textures[i], false));
|
||||
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
// Manually reserving textures should only succeed on the higher priority textures,
|
||||
// and on remaining textures up to the memory limit.
|
||||
@ -351,23 +351,23 @@ TEST_F(PrioritizedTextureTest, textureManagerPrioritiesAreEqual)
|
||||
EXPECT_TRUE(validateTexture(textures[i], true));
|
||||
for (size_t i = 9; i < maxTextures; i++)
|
||||
EXPECT_FALSE(validateTexture(textures[i], true));
|
||||
EXPECT_EQ(texturesMemorySize(8), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(8), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, textureManagerDestroyedFirst)
|
||||
TEST_F(PrioritizedResourceTest, resourceManagerDestroyedFirst)
|
||||
{
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(1);
|
||||
scoped_ptr<PrioritizedTexture> texture = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(1);
|
||||
scoped_ptr<PrioritizedResource> texture = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
// Texture is initially invalid, but it will become available.
|
||||
EXPECT_FALSE(texture->haveBackingTexture());
|
||||
|
||||
texture->setRequestPriority(100);
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
|
||||
EXPECT_TRUE(validateTexture(texture, false));
|
||||
EXPECT_TRUE(texture->canAcquireBackingTexture());
|
||||
@ -375,25 +375,25 @@ TEST_F(PrioritizedTextureTest, textureManagerDestroyedFirst)
|
||||
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
textureManager.reset();
|
||||
resourceManager.reset();
|
||||
|
||||
EXPECT_FALSE(texture->canAcquireBackingTexture());
|
||||
EXPECT_FALSE(texture->haveBackingTexture());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, textureMovedToNewManager)
|
||||
TEST_F(PrioritizedResourceTest, textureMovedToNewManager)
|
||||
{
|
||||
scoped_ptr<PrioritizedTextureManager> textureManagerOne = createManager(1);
|
||||
scoped_ptr<PrioritizedTextureManager> textureManagerTwo = createManager(1);
|
||||
scoped_ptr<PrioritizedTexture> texture = textureManagerOne->createTexture(m_textureSize, m_textureFormat);
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManagerOne = createManager(1);
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManagerTwo = createManager(1);
|
||||
scoped_ptr<PrioritizedResource> texture = resourceManagerOne->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
// Texture is initially invalid, but it will become available.
|
||||
EXPECT_FALSE(texture->haveBackingTexture());
|
||||
|
||||
texture->setRequestPriority(100);
|
||||
prioritizeTexturesAndBackings(textureManagerOne.get());
|
||||
prioritizeTexturesAndBackings(resourceManagerOne.get());
|
||||
|
||||
EXPECT_TRUE(validateTexture(texture, false));
|
||||
EXPECT_TRUE(texture->canAcquireBackingTexture());
|
||||
@ -403,47 +403,47 @@ TEST_F(PrioritizedTextureTest, textureMovedToNewManager)
|
||||
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManagerOne->clearAllMemory(resourceProvider());
|
||||
resourceManagerOne->clearAllMemory(resourceProvider());
|
||||
}
|
||||
textureManagerOne.reset();
|
||||
resourceManagerOne.reset();
|
||||
|
||||
EXPECT_FALSE(texture->canAcquireBackingTexture());
|
||||
EXPECT_FALSE(texture->haveBackingTexture());
|
||||
|
||||
texture->setTextureManager(textureManagerTwo.get());
|
||||
texture->setTextureManager(resourceManagerTwo.get());
|
||||
|
||||
prioritizeTexturesAndBackings(textureManagerTwo.get());
|
||||
prioritizeTexturesAndBackings(resourceManagerTwo.get());
|
||||
|
||||
EXPECT_TRUE(validateTexture(texture, false));
|
||||
EXPECT_TRUE(texture->canAcquireBackingTexture());
|
||||
EXPECT_TRUE(texture->haveBackingTexture());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManagerTwo->clearAllMemory(resourceProvider());
|
||||
resourceManagerTwo->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootSurface)
|
||||
TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableOutsideRootSurface)
|
||||
{
|
||||
const size_t maxTextures = 8;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
|
||||
// Half of the memory is taken by surfaces (with high priority place-holder)
|
||||
scoped_ptr<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
renderSurfacePlaceHolder->setToSelfManagedMemoryPlaceholder(texturesMemorySize(4));
|
||||
renderSurfacePlaceHolder->setRequestPriority(PriorityCalculator::renderSurfacePriority());
|
||||
|
||||
// Create textures to fill our memory limit.
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures];
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures];
|
||||
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
// Set decreasing non-visible priorities outside root surface.
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i]->setRequestPriority(100 + i);
|
||||
|
||||
// Only lower half should be available.
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
EXPECT_TRUE(validateTexture(textures[0], false));
|
||||
EXPECT_TRUE(validateTexture(textures[3], false));
|
||||
EXPECT_FALSE(validateTexture(textures[4], false));
|
||||
@ -454,42 +454,42 @@ TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableOutsideRootSur
|
||||
textures[i]->setRequestPriority(100 - i);
|
||||
|
||||
// Only upper half should be available.
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
EXPECT_FALSE(validateTexture(textures[0], false));
|
||||
EXPECT_FALSE(validateTexture(textures[3], false));
|
||||
EXPECT_TRUE(validateTexture(textures[4], false));
|
||||
EXPECT_TRUE(validateTexture(textures[7], false));
|
||||
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextures());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLate)
|
||||
TEST_F(PrioritizedResourceTest, renderSurfacesReduceMemoryAvailableForRequestLate)
|
||||
{
|
||||
const size_t maxTextures = 8;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
|
||||
// Half of the memory is taken by surfaces (with high priority place-holder)
|
||||
scoped_ptr<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
renderSurfacePlaceHolder->setToSelfManagedMemoryPlaceholder(texturesMemorySize(4));
|
||||
renderSurfacePlaceHolder->setRequestPriority(PriorityCalculator::renderSurfacePriority());
|
||||
|
||||
// Create textures to fill our memory limit.
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures];
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures];
|
||||
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
// Set equal priorities.
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i]->setRequestPriority(100);
|
||||
|
||||
// The first four to be requested late will be available.
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
for (unsigned i = 0; i < maxTextures; ++i)
|
||||
EXPECT_FALSE(validateTexture(textures[i], false));
|
||||
for (unsigned i = 0; i < maxTextures; i += 2)
|
||||
@ -497,29 +497,29 @@ TEST_F(PrioritizedTextureTest, renderSurfacesReduceMemoryAvailableForRequestLate
|
||||
for (unsigned i = 1; i < maxTextures; i += 2)
|
||||
EXPECT_FALSE(validateTexture(textures[i], true));
|
||||
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryForSelfManagedTextures());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryForSelfManagedTextures());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvailable)
|
||||
TEST_F(PrioritizedResourceTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvailable)
|
||||
{
|
||||
const size_t maxTextures = 8;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
|
||||
// Half of the memory is taken by surfaces (with high priority place-holder)
|
||||
scoped_ptr<PrioritizedTexture> renderSurfacePlaceHolder = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
scoped_ptr<PrioritizedResource> renderSurfacePlaceHolder = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
renderSurfacePlaceHolder->setToSelfManagedMemoryPlaceholder(texturesMemorySize(4));
|
||||
renderSurfacePlaceHolder->setRequestPriority(PriorityCalculator::renderSurfacePriority());
|
||||
|
||||
// Create textures to fill our memory limit.
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures];
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures];
|
||||
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
// Set 6 visible textures in the root surface, and 2 in a child surface.
|
||||
for (size_t i = 0; i < 6; ++i)
|
||||
@ -527,7 +527,7 @@ TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvail
|
||||
for (size_t i = 6; i < 8; ++i)
|
||||
textures[i]->setRequestPriority(PriorityCalculator::visiblePriority(false));
|
||||
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
|
||||
// Unable to requestLate textures in the child surface.
|
||||
EXPECT_FALSE(validateTexture(textures[6], true));
|
||||
@ -537,47 +537,47 @@ TEST_F(PrioritizedTextureTest, whenRenderSurfaceNotAvailableTexturesAlsoNotAvail
|
||||
for (size_t i = 0; i < 6; ++i)
|
||||
EXPECT_TRUE(validateTexture(textures[i], false));
|
||||
|
||||
EXPECT_EQ(texturesMemorySize(6), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryForSelfManagedTextures());
|
||||
EXPECT_LE(textureManager->memoryUseBytes(), textureManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(6), resourceManager->memoryAboveCutoffBytes());
|
||||
EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryForSelfManagedTextures());
|
||||
EXPECT_LE(resourceManager->memoryUseBytes(), resourceManager->memoryAboveCutoffBytes());
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, requestLateBackingsSorting)
|
||||
TEST_F(PrioritizedResourceTest, requestLateBackingsSorting)
|
||||
{
|
||||
const size_t maxTextures = 8;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
|
||||
|
||||
// Create textures to fill our memory limit.
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures];
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures];
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
// Set equal priorities, and allocate backings for all textures.
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i]->setRequestPriority(100);
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
for (unsigned i = 0; i < maxTextures; ++i)
|
||||
EXPECT_TRUE(validateTexture(textures[i], false));
|
||||
|
||||
// Drop the memory limit and prioritize (none will be above the threshold,
|
||||
// but they still have backings because reduceMemory hasn't been called).
|
||||
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures / 2));
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures / 2));
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
|
||||
// Push half of them back over the limit.
|
||||
for (size_t i = 0; i < maxTextures; i += 2)
|
||||
EXPECT_TRUE(textures[i]->requestLate());
|
||||
|
||||
// Push the priorities to the backings array and sort the backings array
|
||||
textureManagerUpdateBackingsPriorities(textureManager.get());
|
||||
resourceManagerUpdateBackingsPriorities(resourceManager.get());
|
||||
|
||||
// Assert that the backings list be sorted with the below-limit backings
|
||||
// before the above-limit backings.
|
||||
textureManagerAssertInvariants(textureManager.get());
|
||||
resourceManagerAssertInvariants(resourceManager.get());
|
||||
|
||||
// Make sure that we have backings for all of the textures.
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
@ -590,26 +590,26 @@ TEST_F(PrioritizedTextureTest, requestLateBackingsSorting)
|
||||
EXPECT_FALSE(textureBackingIsAbovePriorityCutoff(textures[i].get()));
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, clearUploadsToEvictedResources)
|
||||
TEST_F(PrioritizedResourceTest, clearUploadsToEvictedResources)
|
||||
{
|
||||
const size_t maxTextures = 4;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager =
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager =
|
||||
createManager(maxTextures);
|
||||
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
|
||||
resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(maxTextures));
|
||||
|
||||
// Create textures to fill our memory limit.
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures];
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures];
|
||||
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
// Set equal priorities, and allocate backings for all textures.
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i]->setRequestPriority(100);
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
for (unsigned i = 0; i < maxTextures; ++i)
|
||||
EXPECT_TRUE(validateTexture(textures[i], false));
|
||||
|
||||
@ -628,25 +628,25 @@ TEST_F(PrioritizedTextureTest, clearUploadsToEvictedResources)
|
||||
queue.clearUploadsToEvictedResources();
|
||||
EXPECT_EQ(4, queue.fullUploadSize());
|
||||
|
||||
textureManager->reduceMemoryOnImplThread(
|
||||
resourceManager->reduceMemoryOnImplThread(
|
||||
texturesMemorySize(1), PriorityCalculator::allowEverythingCutoff(), resourceProvider());
|
||||
queue.clearUploadsToEvictedResources();
|
||||
EXPECT_EQ(1, queue.fullUploadSize());
|
||||
|
||||
textureManager->reduceMemoryOnImplThread(0, PriorityCalculator::allowEverythingCutoff(), resourceProvider());
|
||||
resourceManager->reduceMemoryOnImplThread(0, PriorityCalculator::allowEverythingCutoff(), resourceProvider());
|
||||
queue.clearUploadsToEvictedResources();
|
||||
EXPECT_EQ(0, queue.fullUploadSize());
|
||||
|
||||
}
|
||||
|
||||
TEST_F(PrioritizedTextureTest, usageStatistics)
|
||||
TEST_F(PrioritizedResourceTest, usageStatistics)
|
||||
{
|
||||
const size_t maxTextures = 5;
|
||||
scoped_ptr<PrioritizedTextureManager> textureManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedTexture> textures[maxTextures];
|
||||
scoped_ptr<PrioritizedResourceManager> resourceManager = createManager(maxTextures);
|
||||
scoped_ptr<PrioritizedResource> textures[maxTextures];
|
||||
|
||||
for (size_t i = 0; i < maxTextures; ++i)
|
||||
textures[i] = textureManager->createTexture(m_textureSize, m_textureFormat);
|
||||
textures[i] = resourceManager->createTexture(m_textureSize, m_textureFormat);
|
||||
|
||||
textures[0]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1);
|
||||
textures[1]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff());
|
||||
@ -655,8 +655,8 @@ TEST_F(PrioritizedTextureTest, usageStatistics)
|
||||
textures[4]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCutoff() + 1);
|
||||
|
||||
// Set max limit to 2 textures.
|
||||
textureManager->setMaxMemoryLimitBytes(texturesMemorySize(2));
|
||||
prioritizeTexturesAndBackings(textureManager.get());
|
||||
resourceManager->setMaxMemoryLimitBytes(texturesMemorySize(2));
|
||||
prioritizeTexturesAndBackings(resourceManager.get());
|
||||
|
||||
// The first two textures should be available, others should not.
|
||||
for (size_t i = 0; i < 2; ++i)
|
||||
@ -667,9 +667,9 @@ TEST_F(PrioritizedTextureTest, usageStatistics)
|
||||
// Validate the statistics.
|
||||
{
|
||||
DebugScopedSetImplThread implThread;
|
||||
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes());
|
||||
EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes());
|
||||
EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyBytes());
|
||||
EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes());
|
||||
EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes());
|
||||
EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearbyBytes());
|
||||
}
|
||||
|
||||
// Re-prioritize the textures, but do not push the values to backings.
|
||||
@ -678,27 +678,27 @@ TEST_F(PrioritizedTextureTest, usageStatistics)
|
||||
textures[2]->setRequestPriority(PriorityCalculator::allowVisibleOnlyCutoff() - 1);
|
||||
textures[3]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCutoff() - 1);
|
||||
textures[4]->setRequestPriority(PriorityCalculator::allowVisibleAndNearbyCutoff());
|
||||
textureManager->prioritizeTextures();
|
||||
resourceManager->prioritizeTextures();
|
||||
|
||||
// Verify that we still see the old values.
|
||||
{
|
||||
DebugScopedSetImplThread implThread;
|
||||
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes());
|
||||
EXPECT_EQ(texturesMemorySize(1), textureManager->memoryVisibleBytes());
|
||||
EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleAndNearbyBytes());
|
||||
EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes());
|
||||
EXPECT_EQ(texturesMemorySize(1), resourceManager->memoryVisibleBytes());
|
||||
EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleAndNearbyBytes());
|
||||
}
|
||||
|
||||
// Push priorities to backings, and verify we see the new values.
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->pushTexturePrioritiesToBackings();
|
||||
EXPECT_EQ(texturesMemorySize(2), textureManager->memoryUseBytes());
|
||||
EXPECT_EQ(texturesMemorySize(3), textureManager->memoryVisibleBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), textureManager->memoryVisibleAndNearbyBytes());
|
||||
resourceManager->pushTexturePrioritiesToBackings();
|
||||
EXPECT_EQ(texturesMemorySize(2), resourceManager->memoryUseBytes());
|
||||
EXPECT_EQ(texturesMemorySize(3), resourceManager->memoryVisibleBytes());
|
||||
EXPECT_EQ(texturesMemorySize(4), resourceManager->memoryVisibleAndNearbyBytes());
|
||||
}
|
||||
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider());
|
||||
resourceManager->clearAllMemory(resourceProvider());
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
namespace cc {
|
||||
|
||||
ResourceUpdate ResourceUpdate::Create(PrioritizedTexture* texture,
|
||||
ResourceUpdate ResourceUpdate::Create(PrioritizedResource* texture,
|
||||
const SkBitmap* bitmap,
|
||||
gfx::Rect content_rect,
|
||||
gfx::Rect source_rect,
|
||||
@ -25,7 +25,7 @@ ResourceUpdate ResourceUpdate::Create(PrioritizedTexture* texture,
|
||||
return update;
|
||||
}
|
||||
|
||||
ResourceUpdate ResourceUpdate::CreateFromPicture(PrioritizedTexture* texture,
|
||||
ResourceUpdate ResourceUpdate::CreateFromPicture(PrioritizedResource* texture,
|
||||
SkPicture* picture,
|
||||
gfx::Rect content_rect,
|
||||
gfx::Rect source_rect,
|
||||
|
@ -14,15 +14,15 @@ class SkPicture;
|
||||
|
||||
namespace cc {
|
||||
|
||||
class PrioritizedTexture;
|
||||
class PrioritizedResource;
|
||||
|
||||
struct CC_EXPORT ResourceUpdate {
|
||||
static ResourceUpdate Create(PrioritizedTexture*,
|
||||
static ResourceUpdate Create(PrioritizedResource*,
|
||||
const SkBitmap*,
|
||||
gfx::Rect content_rect,
|
||||
gfx::Rect source_rect,
|
||||
gfx::Vector2d dest_offset);
|
||||
static ResourceUpdate CreateFromPicture(PrioritizedTexture*,
|
||||
static ResourceUpdate CreateFromPicture(PrioritizedResource*,
|
||||
SkPicture*,
|
||||
gfx::Rect content_rect,
|
||||
gfx::Rect source_rect,
|
||||
@ -31,7 +31,7 @@ struct CC_EXPORT ResourceUpdate {
|
||||
ResourceUpdate();
|
||||
virtual ~ResourceUpdate();
|
||||
|
||||
PrioritizedTexture* texture;
|
||||
PrioritizedResource* texture;
|
||||
const SkBitmap* bitmap;
|
||||
SkPicture* picture;
|
||||
gfx::Rect content_rect;
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "cc/resource_update_controller.h"
|
||||
|
||||
#include "base/debug/trace_event.h"
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
#include "cc/proxy.h"
|
||||
#include "cc/resource_provider.h"
|
||||
#include "cc/texture_copier.h"
|
||||
@ -122,7 +122,7 @@ void ResourceUpdateController::discardUploadsToEvictedResources()
|
||||
void ResourceUpdateController::updateTexture(ResourceUpdate update)
|
||||
{
|
||||
if (update.picture) {
|
||||
PrioritizedTexture* texture = update.texture;
|
||||
PrioritizedResource* texture = update.texture;
|
||||
gfx::Rect pictureRect = update.content_rect;
|
||||
gfx::Rect sourceRect = update.source_rect;
|
||||
gfx::Vector2d destOffset = update.dest_offset;
|
||||
|
@ -65,7 +65,7 @@ class ResourceUpdateControllerTest : public Test {
|
||||
public:
|
||||
ResourceUpdateControllerTest()
|
||||
: m_queue(make_scoped_ptr(new ResourceUpdateQueue))
|
||||
, m_textureManager(PrioritizedTextureManager::create(60*1024*1024, 1024, Renderer::ContentPool))
|
||||
, m_resourceManager(PrioritizedResourceManager::create(60*1024*1024, 1024, Renderer::ContentPool))
|
||||
, m_fullUploadCountExpected(0)
|
||||
, m_partialCountExpected(0)
|
||||
, m_totalUploadCountExpected(0)
|
||||
@ -82,7 +82,7 @@ public:
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked
|
||||
implThreadAndMainThreadBlocked;
|
||||
m_textureManager->clearAllMemory(m_resourceProvider.get());
|
||||
m_resourceManager->clearAllMemory(m_resourceProvider.get());
|
||||
}
|
||||
|
||||
public:
|
||||
@ -126,12 +126,12 @@ protected:
|
||||
m_bitmap.allocPixels();
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
m_textures[i] = PrioritizedTexture::create(
|
||||
m_textureManager.get(), gfx::Size(300, 150), GL_RGBA);
|
||||
m_textures[i] = PrioritizedResource::create(
|
||||
m_resourceManager.get(), gfx::Size(300, 150), GL_RGBA);
|
||||
m_textures[i]->setRequestPriority(
|
||||
PriorityCalculator::visiblePriority(true));
|
||||
}
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
DebugScopedSetImplThread implThread;
|
||||
m_resourceProvider = ResourceProvider::create(m_context.get());
|
||||
@ -200,8 +200,8 @@ protected:
|
||||
scoped_ptr<GraphicsContext> m_context;
|
||||
scoped_ptr<ResourceProvider> m_resourceProvider;
|
||||
scoped_ptr<ResourceUpdateQueue> m_queue;
|
||||
scoped_ptr<PrioritizedTexture> m_textures[4];
|
||||
scoped_ptr<PrioritizedTextureManager> m_textureManager;
|
||||
scoped_ptr<PrioritizedResource> m_textures[4];
|
||||
scoped_ptr<PrioritizedResourceManager> m_resourceManager;
|
||||
SkBitmap m_bitmap;
|
||||
int m_queryResultsAvailable;
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "cc/resource_update_queue.h"
|
||||
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
|
||||
namespace cc {
|
||||
|
||||
|
@ -337,7 +337,7 @@ bool SingleThreadProxy::commitAndComposite()
|
||||
return false;
|
||||
|
||||
// Unlink any texture backings that were deleted
|
||||
PrioritizedTextureManager::BackingList evictedContentsTexturesBackings;
|
||||
PrioritizedResourceManager::BackingList evictedContentsTexturesBackings;
|
||||
{
|
||||
DebugScopedSetImplThread implThread;
|
||||
m_layerTreeHost->contentsTextureManager()->getEvictedBackings(evictedContentsTexturesBackings);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
namespace cc {
|
||||
|
||||
SkPictureContentLayerUpdater::Resource::Resource(SkPictureContentLayerUpdater* updater, scoped_ptr<PrioritizedTexture> texture)
|
||||
SkPictureContentLayerUpdater::Resource::Resource(SkPictureContentLayerUpdater* updater, scoped_ptr<PrioritizedResource> texture)
|
||||
: LayerUpdater::Resource(texture.Pass())
|
||||
, m_updater(updater)
|
||||
{
|
||||
@ -43,9 +43,9 @@ scoped_refptr<SkPictureContentLayerUpdater> SkPictureContentLayerUpdater::create
|
||||
return make_scoped_refptr(new SkPictureContentLayerUpdater(painter.Pass()));
|
||||
}
|
||||
|
||||
scoped_ptr<LayerUpdater::Resource> SkPictureContentLayerUpdater::createResource(PrioritizedTextureManager* manager)
|
||||
scoped_ptr<LayerUpdater::Resource> SkPictureContentLayerUpdater::createResource(PrioritizedResourceManager* manager)
|
||||
{
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedTexture::create(manager)));
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager)));
|
||||
}
|
||||
|
||||
void SkPictureContentLayerUpdater::prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats& stats)
|
||||
@ -61,7 +61,7 @@ void SkPictureContentLayerUpdater::drawPicture(SkCanvas* canvas)
|
||||
canvas->drawPicture(m_picture);
|
||||
}
|
||||
|
||||
void SkPictureContentLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedTexture* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate)
|
||||
void SkPictureContentLayerUpdater::updateTexture(ResourceUpdateQueue& queue, PrioritizedResource* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate)
|
||||
{
|
||||
ResourceUpdate upload = ResourceUpdate::CreateFromPicture(
|
||||
texture, &m_picture, contentRect(), sourceRect, destOffset);
|
||||
|
@ -24,7 +24,7 @@ class SkPictureContentLayerUpdater : public ContentLayerUpdater {
|
||||
public:
|
||||
class Resource : public LayerUpdater::Resource {
|
||||
public:
|
||||
Resource(SkPictureContentLayerUpdater*, scoped_ptr<PrioritizedTexture>);
|
||||
Resource(SkPictureContentLayerUpdater*, scoped_ptr<PrioritizedResource>);
|
||||
virtual ~Resource();
|
||||
|
||||
virtual void update(ResourceUpdateQueue&, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate, RenderingStats&) OVERRIDE;
|
||||
@ -37,7 +37,7 @@ public:
|
||||
|
||||
static scoped_refptr<SkPictureContentLayerUpdater> create(scoped_ptr<LayerPainter>);
|
||||
|
||||
virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedTextureManager*) OVERRIDE;
|
||||
virtual scoped_ptr<LayerUpdater::Resource> createResource(PrioritizedResourceManager*) OVERRIDE;
|
||||
virtual void setOpaque(bool) OVERRIDE;
|
||||
|
||||
protected:
|
||||
@ -46,7 +46,7 @@ protected:
|
||||
|
||||
virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size& tileSize, float contentsWidthScale, float contentsHeightScale, gfx::Rect& resultingOpaqueRect, RenderingStats&) OVERRIDE;
|
||||
void drawPicture(SkCanvas*);
|
||||
void updateTexture(ResourceUpdateQueue& queue, PrioritizedTexture* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate);
|
||||
void updateTexture(ResourceUpdateQueue& queue, PrioritizedResource* texture, const gfx::Rect& sourceRect, const gfx::Vector2d& destOffset, bool partialUpdate);
|
||||
|
||||
bool layerIsOpaque() const { return m_layerIsOpaque; }
|
||||
|
||||
|
@ -10,7 +10,7 @@ using namespace cc;
|
||||
|
||||
namespace WebKitTests {
|
||||
|
||||
FakeLayerUpdater::Resource::Resource(FakeLayerUpdater* layer, scoped_ptr<PrioritizedTexture> texture)
|
||||
FakeLayerUpdater::Resource::Resource(FakeLayerUpdater* layer, scoped_ptr<PrioritizedResource> texture)
|
||||
: LayerUpdater::Resource(texture.Pass())
|
||||
, m_layer(layer)
|
||||
{
|
||||
@ -63,9 +63,9 @@ void FakeLayerUpdater::setRectToInvalidate(const gfx::Rect& rect, FakeTiledLayer
|
||||
m_layer = layer;
|
||||
}
|
||||
|
||||
scoped_ptr<LayerUpdater::Resource> FakeLayerUpdater::createResource(PrioritizedTextureManager* manager)
|
||||
scoped_ptr<LayerUpdater::Resource> FakeLayerUpdater::createResource(PrioritizedResourceManager* manager)
|
||||
{
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedTexture::create(manager)));
|
||||
return scoped_ptr<LayerUpdater::Resource>(new Resource(this, PrioritizedResource::create(manager)));
|
||||
}
|
||||
|
||||
FakeTiledLayerImpl::FakeTiledLayerImpl(int id)
|
||||
@ -77,10 +77,10 @@ FakeTiledLayerImpl::~FakeTiledLayerImpl()
|
||||
{
|
||||
}
|
||||
|
||||
FakeTiledLayer::FakeTiledLayer(PrioritizedTextureManager* textureManager)
|
||||
FakeTiledLayer::FakeTiledLayer(PrioritizedResourceManager* resourceManager)
|
||||
: TiledLayer()
|
||||
, m_fakeUpdater(make_scoped_refptr(new FakeLayerUpdater))
|
||||
, m_textureManager(textureManager)
|
||||
, m_resourceManager(resourceManager)
|
||||
{
|
||||
setTileSize(tileSize());
|
||||
setTextureFormat(GL_RGBA);
|
||||
@ -88,8 +88,8 @@ FakeTiledLayer::FakeTiledLayer(PrioritizedTextureManager* textureManager)
|
||||
setIsDrawable(true); // So that we don't get false positives if any of these tests expect to return false from drawsContent() for other reasons.
|
||||
}
|
||||
|
||||
FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(PrioritizedTextureManager* textureManager)
|
||||
: FakeTiledLayer(textureManager)
|
||||
FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(PrioritizedResourceManager* resourceManager)
|
||||
: FakeTiledLayer(resourceManager)
|
||||
{
|
||||
}
|
||||
|
||||
@ -124,9 +124,9 @@ void FakeTiledLayer::setTexturePriorities(const PriorityCalculator& calculator)
|
||||
}
|
||||
}
|
||||
|
||||
cc::PrioritizedTextureManager* FakeTiledLayer::textureManager() const
|
||||
cc::PrioritizedResourceManager* FakeTiledLayer::resourceManager() const
|
||||
{
|
||||
return m_textureManager;
|
||||
return m_resourceManager;
|
||||
}
|
||||
|
||||
cc::LayerUpdater* FakeTiledLayer::updater() const
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "Region.h"
|
||||
#include "cc/layer_updater.h"
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
#include "cc/resource_provider.h"
|
||||
#include "cc/resource_update_queue.h"
|
||||
#include "cc/texture_copier.h"
|
||||
@ -25,7 +25,7 @@ class FakeLayerUpdater : public cc::LayerUpdater {
|
||||
public:
|
||||
class Resource : public cc::LayerUpdater::Resource {
|
||||
public:
|
||||
Resource(FakeLayerUpdater*, scoped_ptr<cc::PrioritizedTexture>);
|
||||
Resource(FakeLayerUpdater*, scoped_ptr<cc::PrioritizedResource>);
|
||||
virtual ~Resource();
|
||||
|
||||
virtual void update(cc::ResourceUpdateQueue&, const gfx::Rect&, const gfx::Vector2d&, bool, cc::RenderingStats&) OVERRIDE;
|
||||
@ -37,7 +37,7 @@ public:
|
||||
|
||||
FakeLayerUpdater();
|
||||
|
||||
virtual scoped_ptr<cc::LayerUpdater::Resource> createResource(cc::PrioritizedTextureManager*) OVERRIDE;
|
||||
virtual scoped_ptr<cc::LayerUpdater::Resource> createResource(cc::PrioritizedResourceManager*) OVERRIDE;
|
||||
|
||||
virtual void prepareToUpdate(const gfx::Rect& contentRect, const gfx::Size&, float, float, gfx::Rect& resultingOpaqueRect, cc::RenderingStats&) OVERRIDE;
|
||||
// Sets the rect to invalidate during the next call to prepareToUpdate(). After the next
|
||||
@ -80,7 +80,7 @@ public:
|
||||
|
||||
class FakeTiledLayer : public cc::TiledLayer {
|
||||
public:
|
||||
explicit FakeTiledLayer(cc::PrioritizedTextureManager*);
|
||||
explicit FakeTiledLayer(cc::PrioritizedResourceManager*);
|
||||
|
||||
static gfx::Size tileSize() { return gfx::Size(100, 100); }
|
||||
|
||||
@ -95,7 +95,7 @@ public:
|
||||
|
||||
virtual void setTexturePriorities(const cc::PriorityCalculator&) OVERRIDE;
|
||||
|
||||
virtual cc::PrioritizedTextureManager* textureManager() const OVERRIDE;
|
||||
virtual cc::PrioritizedResourceManager* resourceManager() const OVERRIDE;
|
||||
FakeLayerUpdater* fakeLayerUpdater() { return m_fakeUpdater.get(); }
|
||||
gfx::RectF updateRect() { return m_updateRect; }
|
||||
|
||||
@ -106,13 +106,13 @@ protected:
|
||||
|
||||
private:
|
||||
scoped_refptr<FakeLayerUpdater> m_fakeUpdater;
|
||||
cc::PrioritizedTextureManager* m_textureManager;
|
||||
cc::PrioritizedResourceManager* m_resourceManager;
|
||||
gfx::RectF m_lastNeedsDisplayRect;
|
||||
};
|
||||
|
||||
class FakeTiledLayerWithScaledBounds : public FakeTiledLayer {
|
||||
public:
|
||||
explicit FakeTiledLayerWithScaledBounds(cc::PrioritizedTextureManager*);
|
||||
explicit FakeTiledLayerWithScaledBounds(cc::PrioritizedResourceManager*);
|
||||
|
||||
void setContentBounds(const gfx::Size& contentBounds) { m_forcedContentBounds = contentBounds; }
|
||||
virtual gfx::Size contentBounds() const OVERRIDE;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "base/debug/trace_event.h"
|
||||
#include "base/metrics/histogram.h"
|
||||
#include "cc/texture.h"
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
#include "third_party/khronos/GLES2/gl2.h"
|
||||
#include "third_party/khronos/GLES2/gl2ext.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "cc/texture_uploader.h"
|
||||
|
||||
#include "cc/prioritized_texture.h"
|
||||
#include "cc/prioritized_resource.h"
|
||||
#include "cc/test/fake_web_graphics_context_3d.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
@ -87,7 +87,7 @@ private:
|
||||
base::TimeTicks monotonicFrameBeginTime;
|
||||
scoped_ptr<ScrollAndScaleSet> scrollInfo;
|
||||
WebKit::WebTransformationMatrix implTransform;
|
||||
PrioritizedTextureManager::BackingList evictedContentsTexturesBackings;
|
||||
PrioritizedResourceManager::BackingList evictedContentsTexturesBackings;
|
||||
size_t memoryAllocationLimitBytes;
|
||||
};
|
||||
scoped_ptr<BeginFrameAndCommitState> m_pendingBeginFrameRequest;
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
}
|
||||
|
||||
LayerUpdater::Resource* updaterResource() { return m_updaterResource.get(); }
|
||||
PrioritizedTexture* managedTexture() { return m_updaterResource->texture(); }
|
||||
PrioritizedResource* managedResource() { return m_updaterResource->texture(); }
|
||||
|
||||
bool isDirty() const { return !dirtyRect.IsEmpty(); }
|
||||
|
||||
@ -205,7 +205,7 @@ void TiledLayer::pushPropertiesTo(LayerImpl* layer)
|
||||
if (!tile)
|
||||
continue;
|
||||
|
||||
if (!tile->managedTexture()->haveBackingTexture()) {
|
||||
if (!tile->managedResource()->haveBackingTexture()) {
|
||||
// Evicted tiles get deleted from both layers
|
||||
invalidTiles.push_back(tile);
|
||||
continue;
|
||||
@ -217,13 +217,13 @@ void TiledLayer::pushPropertiesTo(LayerImpl* layer)
|
||||
continue;
|
||||
}
|
||||
|
||||
tiledLayer->pushTileProperties(i, j, tile->managedTexture()->resourceId(), tile->opaqueRect(), tile->managedTexture()->contentsSwizzled());
|
||||
tiledLayer->pushTileProperties(i, j, tile->managedResource()->resourceId(), tile->opaqueRect(), tile->managedResource()->contentsSwizzled());
|
||||
}
|
||||
for (std::vector<UpdatableTile*>::const_iterator iter = invalidTiles.begin(); iter != invalidTiles.end(); ++iter)
|
||||
m_tiler->takeTile((*iter)->i(), (*iter)->j());
|
||||
}
|
||||
|
||||
PrioritizedTextureManager* TiledLayer::textureManager() const
|
||||
PrioritizedResourceManager* TiledLayer::resourceManager() const
|
||||
{
|
||||
if (!layerTreeHost())
|
||||
return 0;
|
||||
@ -238,7 +238,7 @@ void TiledLayer::setLayerTreeHost(LayerTreeHost* host)
|
||||
// FIXME: This should not ever be null.
|
||||
if (!tile)
|
||||
continue;
|
||||
tile->managedTexture()->setTextureManager(host->contentsTextureManager());
|
||||
tile->managedResource()->setTextureManager(host->contentsTextureManager());
|
||||
}
|
||||
}
|
||||
ContentsScalingLayer::setLayerTreeHost(host);
|
||||
@ -253,8 +253,8 @@ UpdatableTile* TiledLayer::createTile(int i, int j)
|
||||
{
|
||||
createUpdaterIfNeeded();
|
||||
|
||||
scoped_ptr<UpdatableTile> tile(UpdatableTile::create(updater()->createResource(textureManager())));
|
||||
tile->managedTexture()->setDimensions(m_tiler->tileSize(), m_textureFormat);
|
||||
scoped_ptr<UpdatableTile> tile(UpdatableTile::create(updater()->createResource(resourceManager())));
|
||||
tile->managedResource()->setDimensions(m_tiler->tileSize(), m_textureFormat);
|
||||
|
||||
UpdatableTile* addedTile = tile.get();
|
||||
m_tiler->addTile(tile.PassAs<LayerTilingData::Tile>(), i, j);
|
||||
@ -311,7 +311,7 @@ void TiledLayer::invalidateContentRect(const gfx::Rect& contentRect)
|
||||
// Returns true if tile is dirty and only part of it needs to be updated.
|
||||
bool TiledLayer::tileOnlyNeedsPartialUpdate(UpdatableTile* tile)
|
||||
{
|
||||
return !tile->dirtyRect.Contains(m_tiler->tileRect(tile)) && tile->managedTexture()->haveBackingTexture();
|
||||
return !tile->dirtyRect.Contains(m_tiler->tileRect(tile)) && tile->managedResource()->haveBackingTexture();
|
||||
}
|
||||
|
||||
bool TiledLayer::updateTiles(int left, int top, int right, int bottom, ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats, bool& didPaint)
|
||||
@ -361,7 +361,7 @@ void TiledLayer::markOcclusionsAndRequestTextures(int left, int top, int right,
|
||||
tile->occluded = true;
|
||||
occludedTileCount++;
|
||||
} else {
|
||||
succeeded &= tile->managedTexture()->requestLate();
|
||||
succeeded &= tile->managedResource()->requestLate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -383,7 +383,7 @@ bool TiledLayer::haveTexturesForTiles(int left, int top, int right, int bottom,
|
||||
continue;
|
||||
|
||||
// Ensure the entire tile is dirty if we don't have the texture.
|
||||
if (!tile->managedTexture()->haveBackingTexture())
|
||||
if (!tile->managedResource()->haveBackingTexture())
|
||||
tile->dirtyRect = m_tiler->tileRect(tile);
|
||||
|
||||
// If using occlusion and the visible region of the tile is occluded,
|
||||
@ -391,7 +391,7 @@ bool TiledLayer::haveTexturesForTiles(int left, int top, int right, int bottom,
|
||||
if (tile->occluded && !ignoreOcclusions)
|
||||
continue;
|
||||
|
||||
if (!tile->managedTexture()->canAcquireBackingTexture())
|
||||
if (!tile->managedResource()->canAcquireBackingTexture())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -421,7 +421,7 @@ gfx::Rect TiledLayer::markTilesForUpdate(int left, int top, int right, int botto
|
||||
tile->partialUpdate = true;
|
||||
else {
|
||||
tile->dirtyRect = m_tiler->tileRect(tile);
|
||||
tile->managedTexture()->returnBackingTexture();
|
||||
tile->managedResource()->returnBackingTexture();
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,7 +536,7 @@ void setPriorityForTexture(const gfx::Rect& visibleRect,
|
||||
const gfx::Rect& tileRect,
|
||||
bool drawsToRoot,
|
||||
bool isSmallAnimatedLayer,
|
||||
PrioritizedTexture* texture)
|
||||
PrioritizedResource* texture)
|
||||
{
|
||||
int priority = PriorityCalculator::lowestPriority();
|
||||
if (!visibleRect.IsEmpty())
|
||||
@ -582,7 +582,7 @@ void TiledLayer::setTexturePriorities(const PriorityCalculator& priorityCalc)
|
||||
if (!tile)
|
||||
continue;
|
||||
gfx::Rect tileRect = m_tiler->tileRect(tile);
|
||||
setPriorityForTexture(m_predictedVisibleRect, tileRect, drawsToRoot, smallAnimatedLayer, tile->managedTexture());
|
||||
setPriorityForTexture(m_predictedVisibleRect, tileRect, drawsToRoot, smallAnimatedLayer, tile->managedResource());
|
||||
}
|
||||
}
|
||||
|
||||
@ -759,8 +759,8 @@ bool TiledLayer::needsIdlePaint()
|
||||
continue;
|
||||
|
||||
bool updated = !tile->updateRect.IsEmpty();
|
||||
bool canAcquire = tile->managedTexture()->canAcquireBackingTexture();
|
||||
bool dirty = tile->isDirty() || !tile->managedTexture()->haveBackingTexture();
|
||||
bool canAcquire = tile->managedResource()->canAcquireBackingTexture();
|
||||
bool dirty = tile->isDirty() || !tile->managedResource()->haveBackingTexture();
|
||||
if (!updated && canAcquire && dirty)
|
||||
return true;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ protected:
|
||||
bool skipsDraw() const { return m_skipsDraw; }
|
||||
|
||||
// Virtual for testing
|
||||
virtual PrioritizedTextureManager* textureManager() const;
|
||||
virtual PrioritizedResourceManager* resourceManager() const;
|
||||
|
||||
private:
|
||||
virtual scoped_ptr<LayerImpl> createLayerImpl() OVERRIDE;
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
TiledLayerTest()
|
||||
: m_context(WebKit::createFakeGraphicsContext())
|
||||
, m_queue(make_scoped_ptr(new ResourceUpdateQueue))
|
||||
, m_textureManager(PrioritizedTextureManager::create(60*1024*1024, 1024, Renderer::ContentPool))
|
||||
, m_resourceManager(PrioritizedResourceManager::create(60*1024*1024, 1024, Renderer::ContentPool))
|
||||
, m_occlusion(0)
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
@ -60,7 +60,7 @@ public:
|
||||
|
||||
virtual ~TiledLayerTest()
|
||||
{
|
||||
textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get());
|
||||
resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvider.get());
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
m_resourceProvider.reset();
|
||||
}
|
||||
@ -90,11 +90,11 @@ public:
|
||||
private:
|
||||
FakeTiledLayerImpl* m_layerImpl;
|
||||
};
|
||||
void textureManagerClearAllMemory(PrioritizedTextureManager* textureManager, ResourceProvider* resourceProvider)
|
||||
void resourceManagerClearAllMemory(PrioritizedResourceManager* resourceManager, ResourceProvider* resourceProvider)
|
||||
{
|
||||
DebugScopedSetImplThreadAndMainThreadBlocked implThreadAndMainThreadBlocked;
|
||||
textureManager->clearAllMemory(resourceProvider);
|
||||
textureManager->reduceMemory(resourceProvider);
|
||||
resourceManager->clearAllMemory(resourceProvider);
|
||||
resourceManager->reduceMemory(resourceProvider);
|
||||
}
|
||||
void updateTextures()
|
||||
{
|
||||
@ -126,12 +126,12 @@ public:
|
||||
FakeTiledLayerImpl* layerImpl2 = 0)
|
||||
{
|
||||
// Get textures
|
||||
m_textureManager->clearPriorities();
|
||||
m_resourceManager->clearPriorities();
|
||||
if (layer1)
|
||||
layer1->setTexturePriorities(m_priorityCalculator);
|
||||
if (layer2)
|
||||
layer2->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
// Update content
|
||||
if (layer1)
|
||||
@ -161,13 +161,13 @@ public:
|
||||
scoped_ptr<ResourceUpdateQueue> m_queue;
|
||||
RenderingStats m_stats;
|
||||
PriorityCalculator m_priorityCalculator;
|
||||
scoped_ptr<PrioritizedTextureManager> m_textureManager;
|
||||
scoped_ptr<PrioritizedResourceManager> m_resourceManager;
|
||||
TestOcclusionTracker* m_occlusion;
|
||||
};
|
||||
|
||||
TEST_F(TiledLayerTest, pushDirtyTiles)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// The tile size is 100x100, so this invalidates and then paints two tiles.
|
||||
@ -193,7 +193,7 @@ TEST_F(TiledLayerTest, pushDirtyTiles)
|
||||
|
||||
TEST_F(TiledLayerTest, pushOccludedDirtyTiles)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
TestOcclusionTracker occluded;
|
||||
m_occlusion = &occluded;
|
||||
@ -230,7 +230,7 @@ TEST_F(TiledLayerTest, pushOccludedDirtyTiles)
|
||||
|
||||
TEST_F(TiledLayerTest, pushDeletedTiles)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// The tile size is 100x100, so this invalidates and then paints two tiles.
|
||||
@ -243,9 +243,9 @@ TEST_F(TiledLayerTest, pushDeletedTiles)
|
||||
EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 0));
|
||||
EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(0, 1));
|
||||
|
||||
m_textureManager->clearPriorities();
|
||||
textureManagerClearAllMemory(m_textureManager.get(), m_resourceProvider.get());
|
||||
m_textureManager->setMaxMemoryLimitBytes(4*1024*1024);
|
||||
m_resourceManager->clearPriorities();
|
||||
resourceManagerClearAllMemory(m_resourceManager.get(), m_resourceProvider.get());
|
||||
m_resourceManager->setMaxMemoryLimitBytes(4*1024*1024);
|
||||
|
||||
// This should drop the tiles on the impl thread.
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
@ -265,7 +265,7 @@ TEST_F(TiledLayerTest, pushDeletedTiles)
|
||||
|
||||
TEST_F(TiledLayerTest, pushIdlePaintTiles)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// The tile size is 100x100. Setup 5x5 tiles with one visible tile in the center.
|
||||
@ -301,7 +301,7 @@ TEST_F(TiledLayerTest, pushIdlePaintTiles)
|
||||
|
||||
TEST_F(TiledLayerTest, predictivePainting)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// Prepainting should occur in the scroll direction first, and the
|
||||
@ -374,10 +374,10 @@ TEST_F(TiledLayerTest, predictivePainting)
|
||||
TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed)
|
||||
{
|
||||
// Start with 2mb of memory, but the test is going to try to use just more than 1mb, so we reduce to 1mb later.
|
||||
m_textureManager->setMaxMemoryLimitBytes(2 * 1024 * 1024);
|
||||
scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
m_resourceManager->setMaxMemoryLimitBytes(2 * 1024 * 1024);
|
||||
scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl1(1);
|
||||
scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl2(2);
|
||||
|
||||
// For this test we have two layers. layer1 exhausts most texture memory, leaving room for 2 more tiles from
|
||||
@ -401,7 +401,7 @@ TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed)
|
||||
EXPECT_TRUE(needsUpdate);
|
||||
|
||||
// Reduce our memory limits to 1mb.
|
||||
m_textureManager->setMaxMemoryLimitBytes(1024 * 1024);
|
||||
m_resourceManager->setMaxMemoryLimitBytes(1024 * 1024);
|
||||
|
||||
// Now idle paint layer2. We are going to run out of memory though!
|
||||
// Oh well, commit the frame and push.
|
||||
@ -427,7 +427,7 @@ TEST_F(TiledLayerTest, pushTilesAfterIdlePaintFailed)
|
||||
|
||||
TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
TestOcclusionTracker occluded;
|
||||
m_occlusion = &occluded;
|
||||
@ -446,7 +446,7 @@ TEST_F(TiledLayerTest, pushIdlePaintedOccludedTiles)
|
||||
|
||||
TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// The tile size is 100x100, so this invalidates and then paints two tiles.
|
||||
@ -464,8 +464,8 @@ TEST_F(TiledLayerTest, pushTilesMarkedDirtyDuringPaint)
|
||||
|
||||
TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layer1Impl(1);
|
||||
ScopedFakeTiledLayerImpl layer2Impl(2);
|
||||
|
||||
@ -487,8 +487,8 @@ TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnNextLayer)
|
||||
|
||||
TEST_F(TiledLayerTest, pushTilesLayerMarkedDirtyDuringPaintOnPreviousLayer)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer1 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer2 = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layer1Impl(1);
|
||||
ScopedFakeTiledLayerImpl layer2Impl(2);
|
||||
|
||||
@ -527,9 +527,9 @@ TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
|
||||
if (runOutOfMemory[i])
|
||||
layerWidth *= 2;
|
||||
|
||||
m_textureManager->setMaxMemoryLimitBytes(memoryForLayer);
|
||||
m_resourceManager->setMaxMemoryLimitBytes(memoryForLayer);
|
||||
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// Full size layer with half being visible.
|
||||
@ -547,7 +547,7 @@ TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
|
||||
// The layer should paint it's entire contents on the first paint
|
||||
// if it is close to the viewport size and has the available memory.
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
updateTextures();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
@ -571,12 +571,12 @@ TEST_F(TiledLayerTest, paintSmallAnimatedLayersImmediately)
|
||||
|
||||
TEST_F(TiledLayerTest, idlePaintOutOfMemory)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// We have enough memory for only the visible rect, so we will run out of memory in first idle paint.
|
||||
int memoryLimit = 4 * 100 * 100; // 1 tiles, 4 bytes per pixel.
|
||||
m_textureManager->setMaxMemoryLimitBytes(memoryLimit);
|
||||
m_resourceManager->setMaxMemoryLimitBytes(memoryLimit);
|
||||
|
||||
// The tile size is 100x100, so this invalidates and then paints two tiles.
|
||||
bool needsUpdate = false;
|
||||
@ -594,7 +594,7 @@ TEST_F(TiledLayerTest, idlePaintOutOfMemory)
|
||||
|
||||
TEST_F(TiledLayerTest, idlePaintZeroSizedLayer)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
bool animating[2] = {false, true};
|
||||
@ -621,7 +621,7 @@ TEST_F(TiledLayerTest, idlePaintZeroSizedLayer)
|
||||
|
||||
TEST_F(TiledLayerTest, idlePaintNonVisibleLayers)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// Alternate between not visible and visible.
|
||||
@ -651,7 +651,7 @@ TEST_F(TiledLayerTest, idlePaintNonVisibleLayers)
|
||||
|
||||
TEST_F(TiledLayerTest, invalidateFromPrepare)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// The tile size is 100x100, so this invalidates and then paints two tiles.
|
||||
@ -686,7 +686,7 @@ TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled)
|
||||
{
|
||||
// The updateRect (that indicates what was actually painted) should be in
|
||||
// layer space, not the content space.
|
||||
scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new FakeTiledLayerWithScaledBounds(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr(new FakeTiledLayerWithScaledBounds(m_resourceManager.get()));
|
||||
|
||||
gfx::Rect layerBounds(0, 0, 300, 200);
|
||||
gfx::Rect contentBounds(0, 0, 200, 250);
|
||||
@ -700,14 +700,14 @@ TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled)
|
||||
layer->invalidateContentRect(contentBounds);
|
||||
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->updateRect());
|
||||
updateTextures();
|
||||
|
||||
// After the tiles are updated once, another invalidate only needs to update the bounds of the layer.
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->invalidateContentRect(contentBounds);
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
EXPECT_FLOAT_RECT_EQ(gfx::RectF(layerBounds), layer->updateRect());
|
||||
@ -717,14 +717,14 @@ TEST_F(TiledLayerTest, verifyUpdateRectWhenContentBoundsAreScaled)
|
||||
gfx::Rect partialDamage(30, 100, 10, 10);
|
||||
layer->invalidateContentRect(partialDamage);
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->updateRect());
|
||||
}
|
||||
|
||||
TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
ScopedFakeTiledLayerImpl layerImpl(1);
|
||||
|
||||
// Create a layer with one tile.
|
||||
@ -737,7 +737,7 @@ TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges)
|
||||
|
||||
// Push the tiles to the impl side and check that there is exactly one.
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
updateTextures();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
@ -754,7 +754,7 @@ TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges)
|
||||
|
||||
// The impl side should get 2x2 tiles now.
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
updateTextures();
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
@ -767,7 +767,7 @@ TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges)
|
||||
// impl side.
|
||||
layer->setNeedsDisplay();
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
layerPushPropertiesTo(layer.get(), layerImpl.get());
|
||||
EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(0, 0));
|
||||
@ -819,20 +819,20 @@ TEST_F(TiledLayerTest, skipsDrawGetsReset)
|
||||
layerTreeHost->updateLayers(*m_queue.get(), memoryLimit);
|
||||
EXPECT_FALSE(rootLayer->skipsDraw());
|
||||
|
||||
textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
resourceManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
layerTreeHost->setRootLayer(0);
|
||||
}
|
||||
|
||||
TEST_F(TiledLayerTest, resizeToSmaller)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
|
||||
layer->setBounds(gfx::Size(700, 700));
|
||||
layer->setVisibleContentRect(gfx::Rect(0, 0, 700, 700));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 700, 700));
|
||||
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
|
||||
layer->setBounds(gfx::Size(200, 200));
|
||||
@ -841,7 +841,7 @@ TEST_F(TiledLayerTest, resizeToSmaller)
|
||||
|
||||
TEST_F(TiledLayerTest, hugeLayerUpdateCrash)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
|
||||
int size = 1 << 30;
|
||||
layer->setBounds(gfx::Size(size, size));
|
||||
@ -850,7 +850,7 @@ TEST_F(TiledLayerTest, hugeLayerUpdateCrash)
|
||||
|
||||
// Ensure no crash for bounds where size * size would overflow an int.
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
}
|
||||
|
||||
@ -959,13 +959,13 @@ TEST_F(TiledLayerTest, partialUpdates)
|
||||
}
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
resourceManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
layerTreeHost->setRootLayer(0);
|
||||
}
|
||||
|
||||
TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
|
||||
// The tile size is 100x100, so this invalidates and then paints two tiles.
|
||||
layer->setBounds(gfx::Size(100, 200));
|
||||
@ -974,14 +974,14 @@ TEST_F(TiledLayerTest, tilesPaintedWithoutOcclusion)
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 100, 200));
|
||||
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
EXPECT_EQ(2, layer->fakeLayerUpdater()->updateCount());
|
||||
}
|
||||
|
||||
TEST_F(TiledLayerTest, tilesPaintedWithOcclusion)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
TestOcclusionTracker occluded;
|
||||
|
||||
// The tile size is 100x100.
|
||||
@ -994,7 +994,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusion)
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount());
|
||||
|
||||
@ -1004,7 +1004,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusion)
|
||||
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
occluded.setOcclusion(gfx::Rect(250, 200, 300, 100));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
@ -1017,7 +1017,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusion)
|
||||
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
occluded.setOcclusion(gfx::Rect(250, 250, 300, 100));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
@ -1031,7 +1031,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusion)
|
||||
|
||||
TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
TestOcclusionTracker occluded;
|
||||
|
||||
// The tile size is 100x100.
|
||||
@ -1045,7 +1045,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
EXPECT_EQ(24-3, layer->fakeLayerUpdater()->updateCount());
|
||||
|
||||
@ -1061,7 +1061,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
|
||||
layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 350));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount());
|
||||
|
||||
@ -1077,7 +1077,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
|
||||
layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 340));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
EXPECT_EQ(24-6, layer->fakeLayerUpdater()->updateCount());
|
||||
|
||||
@ -1089,7 +1089,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndVisiblityConstraints)
|
||||
|
||||
TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
TestOcclusionTracker occluded;
|
||||
|
||||
// The tile size is 100x100.
|
||||
@ -1101,7 +1101,7 @@ TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation)
|
||||
layer->setVisibleContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount());
|
||||
{
|
||||
@ -1114,7 +1114,7 @@ TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation)
|
||||
|
||||
layer->fakeLayerUpdater()->clearUpdateCount();
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
// Repaint without marking it dirty. The 3 culled tiles will be pre-painted now.
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
@ -1127,7 +1127,7 @@ TEST_F(TiledLayerTest, tilesNotPaintedWithoutInvalidation)
|
||||
|
||||
TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
TestOcclusionTracker occluded;
|
||||
|
||||
// The tile size is 100x100.
|
||||
@ -1145,7 +1145,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms)
|
||||
layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds()));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
EXPECT_EQ(36-3, layer->fakeLayerUpdater()->updateCount());
|
||||
|
||||
@ -1156,7 +1156,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndTransforms)
|
||||
|
||||
TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
TestOcclusionTracker occluded;
|
||||
|
||||
// The tile size is 100x100.
|
||||
@ -1177,7 +1177,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
|
||||
layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds()));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
// The content is half the size of the layer (so the number of tiles is fewer).
|
||||
// In this case, the content is 300x300, and since the tile size is 100, the
|
||||
@ -1198,7 +1198,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
|
||||
layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds()));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount());
|
||||
|
||||
@ -1221,7 +1221,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
|
||||
layer->setVisibleContentRect(gfx::Rect(gfx::Point(), layer->contentBounds()));
|
||||
layer->invalidateContentRect(gfx::Rect(0, 0, 600, 600));
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
layer->update(*m_queue.get(), &occluded, m_stats);
|
||||
EXPECT_EQ(9-1, layer->fakeLayerUpdater()->updateCount());
|
||||
|
||||
@ -1232,7 +1232,7 @@ TEST_F(TiledLayerTest, tilesPaintedWithOcclusionAndScaling)
|
||||
|
||||
TEST_F(TiledLayerTest, visibleContentOpaqueRegion)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
TestOcclusionTracker occluded;
|
||||
|
||||
// The tile size is 100x100, so this invalidates and then paints two tiles in various ways.
|
||||
@ -1249,7 +1249,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion)
|
||||
layer->setDrawOpacity(1);
|
||||
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
// If the layer doesn't paint opaque content, then the visibleContentOpaqueRegion should be empty.
|
||||
layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect());
|
||||
@ -1324,7 +1324,7 @@ TEST_F(TiledLayerTest, visibleContentOpaqueRegion)
|
||||
|
||||
TEST_F(TiledLayerTest, pixelsPaintedMetrics)
|
||||
{
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<FakeTiledLayer> layer = make_scoped_refptr(new FakeTiledLayer(m_resourceManager.get()));
|
||||
TestOcclusionTracker occluded;
|
||||
|
||||
// The tile size is 100x100, so this invalidates and then paints two tiles in various ways.
|
||||
@ -1341,7 +1341,7 @@ TEST_F(TiledLayerTest, pixelsPaintedMetrics)
|
||||
layer->setDrawOpacity(1);
|
||||
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
// Invalidates and paints the whole layer.
|
||||
layer->fakeLayerUpdater()->setOpaquePaintRect(gfx::Rect());
|
||||
@ -1522,7 +1522,7 @@ TEST_F(TiledLayerTest, dontAllocateContentsWhenTargetSurfaceCantBeAllocated)
|
||||
}
|
||||
layerTreeHost->commitComplete();
|
||||
|
||||
textureManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
resourceManagerClearAllMemory(layerTreeHost->contentsTextureManager(), m_resourceProvider.get());
|
||||
layerTreeHost->setRootLayer(0);
|
||||
}
|
||||
|
||||
@ -1546,7 +1546,7 @@ private:
|
||||
|
||||
class UpdateTrackingTiledLayer : public FakeTiledLayer {
|
||||
public:
|
||||
explicit UpdateTrackingTiledLayer(PrioritizedTextureManager* manager)
|
||||
explicit UpdateTrackingTiledLayer(PrioritizedResourceManager* manager)
|
||||
: FakeTiledLayer(manager)
|
||||
{
|
||||
scoped_ptr<TrackingLayerPainter> trackingLayerPainter(TrackingLayerPainter::create());
|
||||
@ -1568,7 +1568,7 @@ private:
|
||||
|
||||
TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
|
||||
{
|
||||
scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new UpdateTrackingTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new UpdateTrackingTiledLayer(m_resourceManager.get()));
|
||||
|
||||
gfx::Rect layerRect(0, 0, 30, 31);
|
||||
layer->setPosition(layerRect.origin());
|
||||
@ -1581,7 +1581,7 @@ TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
|
||||
layer->setDrawableContentRect(contentRect);
|
||||
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
// Update the whole tile.
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
@ -1599,7 +1599,7 @@ TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringPaint)
|
||||
|
||||
TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation)
|
||||
{
|
||||
scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new UpdateTrackingTiledLayer(m_textureManager.get()));
|
||||
scoped_refptr<UpdateTrackingTiledLayer> layer = make_scoped_refptr(new UpdateTrackingTiledLayer(m_resourceManager.get()));
|
||||
|
||||
gfx::Rect layerRect(0, 0, 30, 31);
|
||||
layer->setPosition(layerRect.origin());
|
||||
@ -1611,7 +1611,7 @@ TEST_F(TiledLayerTest, nonIntegerContentsScaleIsNotDistortedDuringInvalidation)
|
||||
layer->setDrawableContentRect(contentRect);
|
||||
|
||||
layer->setTexturePriorities(m_priorityCalculator);
|
||||
m_textureManager->prioritizeTextures();
|
||||
m_resourceManager->prioritizeTextures();
|
||||
|
||||
// Update the whole tile.
|
||||
layer->update(*m_queue.get(), 0, m_stats);
|
||||
|
Reference in New Issue
Block a user