cc: Rename Texture class to Resource.
Renames Texture to Resource and ScopedTexture to ScopedResource. BUG= TEST=cc_unittests Review URL: https://codereview.chromium.org/11377055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166689 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
cc
cc.gypcc_tests.gypdirect_renderer.ccdirect_renderer.hgl_renderer.ccgl_renderer.hheads_up_display_layer_impl.ccheads_up_display_layer_impl.hlayer_tree_host.ccprioritized_resource.ccprioritized_resource.hprioritized_resource_manager.hprioritized_resource_unittest.ccrenderer.hresource.ccresource.hscoped_resource.ccscoped_resource.hscoped_resource_unittest.ccsoftware_renderer.ccsoftware_renderer.htexture_uploader.cc
@@ -151,6 +151,8 @@
|
|||||||
'renderer.cc',
|
'renderer.cc',
|
||||||
'renderer.h',
|
'renderer.h',
|
||||||
'rendering_stats.h',
|
'rendering_stats.h',
|
||||||
|
'resource.cc',
|
||||||
|
'resource.h',
|
||||||
'resource_provider.cc',
|
'resource_provider.cc',
|
||||||
'resource_provider.h',
|
'resource_provider.h',
|
||||||
'resource_update.cc',
|
'resource_update.cc',
|
||||||
@@ -166,8 +168,8 @@
|
|||||||
'scoped_ptr_deque.h',
|
'scoped_ptr_deque.h',
|
||||||
'scoped_ptr_hash_map.h',
|
'scoped_ptr_hash_map.h',
|
||||||
'scoped_ptr_vector.h',
|
'scoped_ptr_vector.h',
|
||||||
'scoped_texture.cc',
|
'scoped_resource.cc',
|
||||||
'scoped_texture.h',
|
'scoped_resource.h',
|
||||||
'scoped_thread_proxy.cc',
|
'scoped_thread_proxy.cc',
|
||||||
'scoped_thread_proxy.h',
|
'scoped_thread_proxy.h',
|
||||||
'scrollbar_animation_controller.cc',
|
'scrollbar_animation_controller.cc',
|
||||||
@@ -204,8 +206,6 @@
|
|||||||
'stream_video_draw_quad.h',
|
'stream_video_draw_quad.h',
|
||||||
'switches.cc',
|
'switches.cc',
|
||||||
'switches.h',
|
'switches.h',
|
||||||
'texture.cc',
|
|
||||||
'texture.h',
|
|
||||||
'texture_copier.cc',
|
'texture_copier.cc',
|
||||||
'texture_copier.h',
|
'texture_copier.h',
|
||||||
'texture_draw_quad.cc',
|
'texture_draw_quad.cc',
|
||||||
|
@@ -42,7 +42,7 @@
|
|||||||
'resource_update_controller_unittest.cc',
|
'resource_update_controller_unittest.cc',
|
||||||
'scheduler_state_machine_unittest.cc',
|
'scheduler_state_machine_unittest.cc',
|
||||||
'scheduler_unittest.cc',
|
'scheduler_unittest.cc',
|
||||||
'scoped_texture_unittest.cc',
|
'scoped_resource_unittest.cc',
|
||||||
'scrollbar_animation_controller_linear_fade_unittest.cc',
|
'scrollbar_animation_controller_linear_fade_unittest.cc',
|
||||||
'scrollbar_layer_unittest.cc',
|
'scrollbar_layer_unittest.cc',
|
||||||
'software_renderer_unittest.cc',
|
'software_renderer_unittest.cc',
|
||||||
|
@@ -122,7 +122,7 @@ void DirectRenderer::decideRenderPassAllocationsForFrame(const RenderPassList& r
|
|||||||
renderPassesInFrame.insert(std::pair<RenderPass::Id, const RenderPass*>(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i]));
|
renderPassesInFrame.insert(std::pair<RenderPass::Id, const RenderPass*>(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i]));
|
||||||
|
|
||||||
std::vector<RenderPass::Id> passesToDelete;
|
std::vector<RenderPass::Id> passesToDelete;
|
||||||
ScopedPtrHashMap<RenderPass::Id, CachedTexture>::const_iterator passIterator;
|
ScopedPtrHashMap<RenderPass::Id, CachedResource>::const_iterator passIterator;
|
||||||
for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPassTextures.end(); ++passIterator) {
|
for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPassTextures.end(); ++passIterator) {
|
||||||
base::hash_map<RenderPass::Id, const RenderPass*>::const_iterator it = renderPassesInFrame.find(passIterator->first);
|
base::hash_map<RenderPass::Id, const RenderPass*>::const_iterator it = renderPassesInFrame.find(passIterator->first);
|
||||||
if (it == renderPassesInFrame.end()) {
|
if (it == renderPassesInFrame.end()) {
|
||||||
@@ -133,7 +133,7 @@ void DirectRenderer::decideRenderPassAllocationsForFrame(const RenderPassList& r
|
|||||||
const RenderPass* renderPassInFrame = it->second;
|
const RenderPass* renderPassInFrame = it->second;
|
||||||
const gfx::Size& requiredSize = renderPassTextureSize(renderPassInFrame);
|
const gfx::Size& requiredSize = renderPassTextureSize(renderPassInFrame);
|
||||||
GLenum requiredFormat = renderPassTextureFormat(renderPassInFrame);
|
GLenum requiredFormat = renderPassTextureFormat(renderPassInFrame);
|
||||||
CachedTexture* texture = passIterator->second;
|
CachedResource* texture = passIterator->second;
|
||||||
DCHECK(texture);
|
DCHECK(texture);
|
||||||
|
|
||||||
if (texture->id() && (texture->size() != requiredSize || texture->format() != requiredFormat))
|
if (texture->id() && (texture->size() != requiredSize || texture->format() != requiredFormat))
|
||||||
@@ -146,7 +146,7 @@ void DirectRenderer::decideRenderPassAllocationsForFrame(const RenderPassList& r
|
|||||||
|
|
||||||
for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) {
|
for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) {
|
||||||
if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id())) {
|
if (!m_renderPassTextures.contains(renderPassesInDrawOrder[i]->id())) {
|
||||||
scoped_ptr<CachedTexture> texture = CachedTexture::create(m_resourceProvider);
|
scoped_ptr<CachedResource> texture = CachedResource::create(m_resourceProvider);
|
||||||
m_renderPassTextures.set(renderPassesInDrawOrder[i]->id(), texture.Pass());
|
m_renderPassTextures.set(renderPassesInDrawOrder[i]->id(), texture.Pass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ void DirectRenderer::drawRenderPass(DrawingFrame& frame, const RenderPass* rende
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedTexture* texture = m_renderPassTextures.get(renderPass->id());
|
CachedResource* texture = m_renderPassTextures.get(renderPass->id());
|
||||||
if (texture)
|
if (texture)
|
||||||
texture->setIsComplete(!renderPass->hasOcclusionFromOutsideTargetSurface());
|
texture->setIsComplete(!renderPass->hasOcclusionFromOutsideTargetSurface());
|
||||||
}
|
}
|
||||||
@@ -210,7 +210,7 @@ bool DirectRenderer::useRenderPass(DrawingFrame& frame, const RenderPass* render
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedTexture* texture = m_renderPassTextures.get(renderPass->id());
|
CachedResource* texture = m_renderPassTextures.get(renderPass->id());
|
||||||
DCHECK(texture);
|
DCHECK(texture);
|
||||||
if (!texture->id() && !texture->allocate(Renderer::ImplPool, renderPassTextureSize(renderPass), renderPassTextureFormat(renderPass), ResourceProvider::TextureUsageFramebuffer))
|
if (!texture->id() && !texture->allocate(Renderer::ImplPool, renderPassTextureSize(renderPass), renderPassTextureFormat(renderPass), ResourceProvider::TextureUsageFramebuffer))
|
||||||
return false;
|
return false;
|
||||||
@@ -220,7 +220,7 @@ bool DirectRenderer::useRenderPass(DrawingFrame& frame, const RenderPass* render
|
|||||||
|
|
||||||
bool DirectRenderer::haveCachedResourcesForRenderPassId(RenderPass::Id id) const
|
bool DirectRenderer::haveCachedResourcesForRenderPassId(RenderPass::Id id) const
|
||||||
{
|
{
|
||||||
CachedTexture* texture = m_renderPassTextures.get(id);
|
CachedResource* texture = m_renderPassTextures.get(id);
|
||||||
return texture && texture->id() && texture->isComplete();
|
return texture && texture->id() && texture->isComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
#include "cc/cc_export.h"
|
#include "cc/cc_export.h"
|
||||||
#include "cc/renderer.h"
|
#include "cc/renderer.h"
|
||||||
#include "cc/resource_provider.h"
|
#include "cc/resource_provider.h"
|
||||||
#include "cc/scoped_texture.h"
|
#include "cc/scoped_resource.h"
|
||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ protected:
|
|||||||
const RenderPassIdHashMap* renderPassesById;
|
const RenderPassIdHashMap* renderPassesById;
|
||||||
const RenderPass* rootRenderPass;
|
const RenderPass* rootRenderPass;
|
||||||
const RenderPass* currentRenderPass;
|
const RenderPass* currentRenderPass;
|
||||||
const ScopedTexture* currentTexture;
|
const ScopedResource* currentTexture;
|
||||||
|
|
||||||
gfx::RectF rootDamageRect;
|
gfx::RectF rootDamageRect;
|
||||||
|
|
||||||
@@ -48,19 +48,19 @@ protected:
|
|||||||
gfx::RectF scissorRectInRenderPassSpace;
|
gfx::RectF scissorRectInRenderPassSpace;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CachedTexture : public ScopedTexture {
|
class CachedResource : public ScopedResource {
|
||||||
public:
|
public:
|
||||||
static scoped_ptr<CachedTexture> create(ResourceProvider* resourceProvider) {
|
static scoped_ptr<CachedResource> create(ResourceProvider* resourceProvider) {
|
||||||
return make_scoped_ptr(new CachedTexture(resourceProvider));
|
return make_scoped_ptr(new CachedResource(resourceProvider));
|
||||||
}
|
}
|
||||||
virtual ~CachedTexture() {}
|
virtual ~CachedResource() {}
|
||||||
|
|
||||||
bool isComplete() const { return m_isComplete; }
|
bool isComplete() const { return m_isComplete; }
|
||||||
void setIsComplete(bool isComplete) { m_isComplete = isComplete; }
|
void setIsComplete(bool isComplete) { m_isComplete = isComplete; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit CachedTexture(ResourceProvider* resourceProvider)
|
explicit CachedResource(ResourceProvider* resourceProvider)
|
||||||
: ScopedTexture(resourceProvider)
|
: ScopedResource(resourceProvider)
|
||||||
, m_isComplete(false)
|
, m_isComplete(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
bool m_isComplete;
|
bool m_isComplete;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CachedTexture);
|
DISALLOW_COPY_AND_ASSIGN(CachedResource);
|
||||||
};
|
};
|
||||||
|
|
||||||
static gfx::RectF quadVertexRect();
|
static gfx::RectF quadVertexRect();
|
||||||
@@ -84,7 +84,7 @@ protected:
|
|||||||
bool useRenderPass(DrawingFrame&, const RenderPass*);
|
bool useRenderPass(DrawingFrame&, const RenderPass*);
|
||||||
|
|
||||||
virtual void bindFramebufferToOutputSurface(DrawingFrame&) = 0;
|
virtual void bindFramebufferToOutputSurface(DrawingFrame&) = 0;
|
||||||
virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedTexture*, const gfx::Rect& framebufferRect) = 0;
|
virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedResource*, const gfx::Rect& framebufferRect) = 0;
|
||||||
virtual void setDrawViewportSize(const gfx::Size&) = 0;
|
virtual void setDrawViewportSize(const gfx::Size&) = 0;
|
||||||
virtual void setScissorTestRect(const gfx::Rect& scissorRect) = 0;
|
virtual void setScissorTestRect(const gfx::Rect& scissorRect) = 0;
|
||||||
virtual void clearFramebuffer(DrawingFrame&) = 0;
|
virtual void clearFramebuffer(DrawingFrame&) = 0;
|
||||||
@@ -93,7 +93,7 @@ protected:
|
|||||||
virtual void finishDrawingFrame(DrawingFrame&) = 0;
|
virtual void finishDrawingFrame(DrawingFrame&) = 0;
|
||||||
virtual bool flippedFramebuffer() const = 0;
|
virtual bool flippedFramebuffer() const = 0;
|
||||||
|
|
||||||
ScopedPtrHashMap<RenderPass::Id, CachedTexture> m_renderPassTextures;
|
ScopedPtrHashMap<RenderPass::Id, CachedResource> m_renderPassTextures;
|
||||||
ResourceProvider* m_resourceProvider;
|
ResourceProvider* m_resourceProvider;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
#include "cc/proxy.h"
|
#include "cc/proxy.h"
|
||||||
#include "cc/render_pass.h"
|
#include "cc/render_pass.h"
|
||||||
#include "cc/render_surface_filters.h"
|
#include "cc/render_surface_filters.h"
|
||||||
#include "cc/scoped_texture.h"
|
#include "cc/scoped_resource.h"
|
||||||
#include "cc/settings.h"
|
#include "cc/settings.h"
|
||||||
#include "cc/single_thread_proxy.h"
|
#include "cc/single_thread_proxy.h"
|
||||||
#include "cc/stream_video_draw_quad.h"
|
#include "cc/stream_video_draw_quad.h"
|
||||||
@@ -358,7 +358,7 @@ static GrContext* getFilterGrContext(bool hasImplThread)
|
|||||||
return WebSharedGraphicsContext3D::mainThreadGrContext();
|
return WebSharedGraphicsContext3D::mainThreadGrContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedTexture* sourceTexture, bool hasImplThread)
|
static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilterOperations& filters, ScopedResource* sourceTexture, bool hasImplThread)
|
||||||
{
|
{
|
||||||
if (filters.isEmpty())
|
if (filters.isEmpty())
|
||||||
return SkBitmap();
|
return SkBitmap();
|
||||||
@@ -376,7 +376,7 @@ static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte
|
|||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedTexture* sourceTexture, bool hasImplThread)
|
static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, ScopedResource* sourceTexture, bool hasImplThread)
|
||||||
{
|
{
|
||||||
if (!filter)
|
if (!filter)
|
||||||
return SkBitmap();
|
return SkBitmap();
|
||||||
@@ -428,7 +428,7 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
|
|||||||
return device.accessBitmap(false);
|
return device.accessBitmap(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(
|
scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
|
||||||
DrawingFrame& frame, const RenderPassDrawQuad* quad,
|
DrawingFrame& frame, const RenderPassDrawQuad* quad,
|
||||||
const WebKit::WebFilterOperations& filters,
|
const WebKit::WebFilterOperations& filters,
|
||||||
const WebTransformationMatrix& contentsDeviceTransform,
|
const WebTransformationMatrix& contentsDeviceTransform,
|
||||||
@@ -451,12 +451,12 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(
|
|||||||
// FIXME: When this algorithm changes, update LayerTreeHost::prioritizeTextures() accordingly.
|
// FIXME: When this algorithm changes, update LayerTreeHost::prioritizeTextures() accordingly.
|
||||||
|
|
||||||
if (filters.isEmpty())
|
if (filters.isEmpty())
|
||||||
return scoped_ptr<ScopedTexture>();
|
return scoped_ptr<ScopedResource>();
|
||||||
|
|
||||||
// FIXME: We only allow background filters on an opaque render surface because other surfaces may contain
|
// FIXME: We only allow background filters on an opaque render surface because other surfaces may contain
|
||||||
// translucent pixels, and the contents behind those translucent pixels wouldn't have the filter applied.
|
// translucent pixels, and the contents behind those translucent pixels wouldn't have the filter applied.
|
||||||
if (frame.currentRenderPass->hasTransparentBackground())
|
if (frame.currentRenderPass->hasTransparentBackground())
|
||||||
return scoped_ptr<ScopedTexture>();
|
return scoped_ptr<ScopedResource>();
|
||||||
DCHECK(!frame.currentTexture);
|
DCHECK(!frame.currentTexture);
|
||||||
|
|
||||||
// FIXME: Do a single readback for both the surface and replica and cache the filtered results (once filter textures are not reused).
|
// FIXME: Do a single readback for both the surface and replica and cache the filtered results (once filter textures are not reused).
|
||||||
@@ -468,20 +468,20 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(
|
|||||||
|
|
||||||
deviceRect.Intersect(frame.currentRenderPass->outputRect());
|
deviceRect.Intersect(frame.currentRenderPass->outputRect());
|
||||||
|
|
||||||
scoped_ptr<ScopedTexture> deviceBackgroundTexture = ScopedTexture::create(m_resourceProvider);
|
scoped_ptr<ScopedResource> deviceBackgroundTexture = ScopedResource::create(m_resourceProvider);
|
||||||
if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
|
if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect))
|
||||||
return scoped_ptr<ScopedTexture>();
|
return scoped_ptr<ScopedResource>();
|
||||||
|
|
||||||
SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get(), m_client->hasImplThread());
|
SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get(), m_client->hasImplThread());
|
||||||
if (!filteredDeviceBackground.getTexture())
|
if (!filteredDeviceBackground.getTexture())
|
||||||
return scoped_ptr<ScopedTexture>();
|
return scoped_ptr<ScopedResource>();
|
||||||
|
|
||||||
GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.getTexture());
|
GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.getTexture());
|
||||||
int filteredDeviceBackgroundTextureId = texture->getTextureHandle();
|
int filteredDeviceBackgroundTextureId = texture->getTextureHandle();
|
||||||
|
|
||||||
scoped_ptr<ScopedTexture> backgroundTexture = ScopedTexture::create(m_resourceProvider);
|
scoped_ptr<ScopedResource> backgroundTexture = ScopedResource::create(m_resourceProvider);
|
||||||
if (!backgroundTexture->allocate(Renderer::ImplPool, quad->quadRect().size(), GL_RGBA, ResourceProvider::TextureUsageFramebuffer))
|
if (!backgroundTexture->allocate(Renderer::ImplPool, quad->quadRect().size(), GL_RGBA, ResourceProvider::TextureUsageFramebuffer))
|
||||||
return scoped_ptr<ScopedTexture>();
|
return scoped_ptr<ScopedResource>();
|
||||||
|
|
||||||
const RenderPass* targetRenderPass = frame.currentRenderPass;
|
const RenderPass* targetRenderPass = frame.currentRenderPass;
|
||||||
bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(), quad->quadRect());
|
bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(), quad->quadRect());
|
||||||
@@ -498,13 +498,13 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(
|
|||||||
useRenderPass(frame, targetRenderPass);
|
useRenderPass(frame, targetRenderPass);
|
||||||
|
|
||||||
if (!usingBackgroundTexture)
|
if (!usingBackgroundTexture)
|
||||||
return scoped_ptr<ScopedTexture>();
|
return scoped_ptr<ScopedResource>();
|
||||||
return backgroundTexture.Pass();
|
return backgroundTexture.Pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQuad* quad)
|
void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQuad* quad)
|
||||||
{
|
{
|
||||||
CachedTexture* contentsTexture = m_renderPassTextures.get(quad->renderPassId());
|
CachedResource* contentsTexture = m_renderPassTextures.get(quad->renderPassId());
|
||||||
if (!contentsTexture || !contentsTexture->id())
|
if (!contentsTexture || !contentsTexture->id())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -522,7 +522,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
WebTransformationMatrix contentsDeviceTransformInverse = contentsDeviceTransform.inverse();
|
WebTransformationMatrix contentsDeviceTransformInverse = contentsDeviceTransform.inverse();
|
||||||
scoped_ptr<ScopedTexture> backgroundTexture = drawBackgroundFilters(
|
scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters(
|
||||||
frame, quad, renderPass->backgroundFilters(),
|
frame, quad, renderPass->backgroundFilters(),
|
||||||
contentsDeviceTransform, contentsDeviceTransformInverse);
|
contentsDeviceTransform, contentsDeviceTransformInverse);
|
||||||
|
|
||||||
@@ -1294,7 +1294,7 @@ void GLRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect)
|
|||||||
enforceMemoryPolicy();
|
enforceMemoryPolicy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLRenderer::getFramebufferTexture(ScopedTexture* texture, const gfx::Rect& deviceRect)
|
bool GLRenderer::getFramebufferTexture(ScopedResource* texture, const gfx::Rect& deviceRect)
|
||||||
{
|
{
|
||||||
DCHECK(!texture->id() || (texture->size() == deviceRect.size() && texture->format() == GL_RGB));
|
DCHECK(!texture->id() || (texture->size() == deviceRect.size() && texture->format() == GL_RGB));
|
||||||
|
|
||||||
@@ -1308,7 +1308,7 @@ bool GLRenderer::getFramebufferTexture(ScopedTexture* texture, const gfx::Rect&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLRenderer::useScopedTexture(DrawingFrame& frame, const ScopedTexture* texture, const gfx::Rect& viewportRect)
|
bool GLRenderer::useScopedTexture(DrawingFrame& frame, const ScopedResource* texture, const gfx::Rect& viewportRect)
|
||||||
{
|
{
|
||||||
DCHECK(texture->id());
|
DCHECK(texture->id());
|
||||||
frame.currentRenderPass = 0;
|
frame.currentRenderPass = 0;
|
||||||
@@ -1323,7 +1323,7 @@ void GLRenderer::bindFramebufferToOutputSurface(DrawingFrame& frame)
|
|||||||
GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0));
|
GLC(m_context, m_context->bindFramebuffer(GL_FRAMEBUFFER, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedTexture* texture, const gfx::Rect& framebufferRect)
|
bool GLRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedResource* texture, const gfx::Rect& framebufferRect)
|
||||||
{
|
{
|
||||||
DCHECK(texture->id());
|
DCHECK(texture->id());
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ class WebGraphicsContext3D;
|
|||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
|
|
||||||
class ScopedTexture;
|
class ScopedResource;
|
||||||
class StreamVideoDrawQuad;
|
class StreamVideoDrawQuad;
|
||||||
class TextureDrawQuad;
|
class TextureDrawQuad;
|
||||||
class GeometryBinding;
|
class GeometryBinding;
|
||||||
@@ -71,11 +71,11 @@ protected:
|
|||||||
const gfx::QuadF& sharedGeometryQuad() const { return m_sharedGeometryQuad; }
|
const gfx::QuadF& sharedGeometryQuad() const { return m_sharedGeometryQuad; }
|
||||||
const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(); }
|
const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(); }
|
||||||
|
|
||||||
bool getFramebufferTexture(ScopedTexture*, const gfx::Rect& deviceRect);
|
bool getFramebufferTexture(ScopedResource*, const gfx::Rect& deviceRect);
|
||||||
void releaseRenderPassTextures();
|
void releaseRenderPassTextures();
|
||||||
|
|
||||||
virtual void bindFramebufferToOutputSurface(DrawingFrame&) OVERRIDE;
|
virtual void bindFramebufferToOutputSurface(DrawingFrame&) OVERRIDE;
|
||||||
virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedTexture*, const gfx::Rect& framebufferRect) OVERRIDE;
|
virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedResource*, const gfx::Rect& framebufferRect) OVERRIDE;
|
||||||
virtual void setDrawViewportSize(const gfx::Size&) OVERRIDE;
|
virtual void setDrawViewportSize(const gfx::Size&) OVERRIDE;
|
||||||
virtual void setScissorTestRect(const gfx::Rect& scissorRect) OVERRIDE;
|
virtual void setScissorTestRect(const gfx::Rect& scissorRect) OVERRIDE;
|
||||||
virtual void clearFramebuffer(DrawingFrame&) OVERRIDE;
|
virtual void clearFramebuffer(DrawingFrame&) OVERRIDE;
|
||||||
@@ -90,7 +90,7 @@ private:
|
|||||||
|
|
||||||
void drawCheckerboardQuad(const DrawingFrame&, const CheckerboardDrawQuad*);
|
void drawCheckerboardQuad(const DrawingFrame&, const CheckerboardDrawQuad*);
|
||||||
void drawDebugBorderQuad(const DrawingFrame&, const DebugBorderDrawQuad*);
|
void drawDebugBorderQuad(const DrawingFrame&, const DebugBorderDrawQuad*);
|
||||||
scoped_ptr<ScopedTexture> drawBackgroundFilters(
|
scoped_ptr<ScopedResource> drawBackgroundFilters(
|
||||||
DrawingFrame&, const RenderPassDrawQuad*, const WebKit::WebFilterOperations&,
|
DrawingFrame&, const RenderPassDrawQuad*, const WebKit::WebFilterOperations&,
|
||||||
const WebKit::WebTransformationMatrix& contentsDeviceTransform,
|
const WebKit::WebTransformationMatrix& contentsDeviceTransform,
|
||||||
const WebKit::WebTransformationMatrix& contentsDeviceTransformInverse);
|
const WebKit::WebTransformationMatrix& contentsDeviceTransformInverse);
|
||||||
@@ -108,7 +108,7 @@ private:
|
|||||||
|
|
||||||
void copyTextureToFramebuffer(const DrawingFrame&, int textureId, const gfx::Rect&, const WebKit::WebTransformationMatrix& drawMatrix);
|
void copyTextureToFramebuffer(const DrawingFrame&, int textureId, const gfx::Rect&, const WebKit::WebTransformationMatrix& drawMatrix);
|
||||||
|
|
||||||
bool useScopedTexture(DrawingFrame&, const ScopedTexture*, const gfx::Rect& viewportRect);
|
bool useScopedTexture(DrawingFrame&, const ScopedResource*, const gfx::Rect& viewportRect);
|
||||||
|
|
||||||
bool makeContextCurrent();
|
bool makeContextCurrent();
|
||||||
|
|
||||||
|
@@ -69,7 +69,7 @@ void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider)
|
|||||||
LayerImpl::willDraw(resourceProvider);
|
LayerImpl::willDraw(resourceProvider);
|
||||||
|
|
||||||
if (!m_hudTexture)
|
if (!m_hudTexture)
|
||||||
m_hudTexture = ScopedTexture::create(resourceProvider);
|
m_hudTexture = ScopedResource::create(resourceProvider);
|
||||||
|
|
||||||
// FIXME: Scale the HUD by deviceScale to make it more friendly under high DPI.
|
// FIXME: Scale the HUD by deviceScale to make it more friendly under high DPI.
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
#include "cc/cc_export.h"
|
#include "cc/cc_export.h"
|
||||||
#include "cc/font_atlas.h"
|
#include "cc/font_atlas.h"
|
||||||
#include "cc/layer_impl.h"
|
#include "cc/layer_impl.h"
|
||||||
#include "cc/scoped_texture.h"
|
#include "cc/scoped_resource.h"
|
||||||
|
|
||||||
class SkCanvas;
|
class SkCanvas;
|
||||||
class SkPaint;
|
class SkPaint;
|
||||||
@@ -54,7 +54,7 @@ private:
|
|||||||
void drawDebugRects(SkCanvas*, DebugRectHistory*);
|
void drawDebugRects(SkCanvas*, DebugRectHistory*);
|
||||||
|
|
||||||
scoped_ptr<FontAtlas> m_fontAtlas;
|
scoped_ptr<FontAtlas> m_fontAtlas;
|
||||||
scoped_ptr<ScopedTexture> m_hudTexture;
|
scoped_ptr<ScopedResource> m_hudTexture;
|
||||||
scoped_ptr<SkCanvas> m_hudCanvas;
|
scoped_ptr<SkCanvas> m_hudCanvas;
|
||||||
|
|
||||||
double m_averageFPS;
|
double m_averageFPS;
|
||||||
|
@@ -627,7 +627,7 @@ size_t LayerTreeHost::calculateMemoryForRenderSurfaces(const LayerList& updateLi
|
|||||||
Layer* renderSurfaceLayer = updateList[i].get();
|
Layer* renderSurfaceLayer = updateList[i].get();
|
||||||
RenderSurface* renderSurface = renderSurfaceLayer->renderSurface();
|
RenderSurface* renderSurface = renderSurfaceLayer->renderSurface();
|
||||||
|
|
||||||
size_t bytes = Texture::memorySizeBytes(renderSurface->contentRect().size(), GL_RGBA);
|
size_t bytes = Resource::memorySizeBytes(renderSurface->contentRect().size(), GL_RGBA);
|
||||||
contentsTextureBytes += bytes;
|
contentsTextureBytes += bytes;
|
||||||
|
|
||||||
if (renderSurfaceLayer->backgroundFilters().isEmpty())
|
if (renderSurfaceLayer->backgroundFilters().isEmpty())
|
||||||
@@ -636,7 +636,7 @@ size_t LayerTreeHost::calculateMemoryForRenderSurfaces(const LayerList& updateLi
|
|||||||
if (bytes > maxBackgroundTextureBytes)
|
if (bytes > maxBackgroundTextureBytes)
|
||||||
maxBackgroundTextureBytes = bytes;
|
maxBackgroundTextureBytes = bytes;
|
||||||
if (!readbackBytes)
|
if (!readbackBytes)
|
||||||
readbackBytes = Texture::memorySizeBytes(m_deviceViewportSize, GL_RGBA);
|
readbackBytes = Resource::memorySizeBytes(m_deviceViewportSize, GL_RGBA);
|
||||||
}
|
}
|
||||||
return readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes;
|
return readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes;
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ PrioritizedResource::PrioritizedResource(PrioritizedResourceManager* manager, gf
|
|||||||
// m_manager is set in registerTexture() so validity can be checked.
|
// m_manager is set in registerTexture() so validity can be checked.
|
||||||
DCHECK(format || size.IsEmpty());
|
DCHECK(format || size.IsEmpty());
|
||||||
if (format)
|
if (format)
|
||||||
m_bytes = Texture::memorySizeBytes(size, format);
|
m_bytes = Resource::memorySizeBytes(size, format);
|
||||||
if (manager)
|
if (manager)
|
||||||
manager->registerTexture(this);
|
manager->registerTexture(this);
|
||||||
}
|
}
|
||||||
@@ -57,7 +57,7 @@ void PrioritizedResource::setDimensions(gfx::Size size, GLenum format)
|
|||||||
m_isAbovePriorityCutoff = false;
|
m_isAbovePriorityCutoff = false;
|
||||||
m_format = format;
|
m_format = format;
|
||||||
m_size = size;
|
m_size = size;
|
||||||
m_bytes = Texture::memorySizeBytes(size, format);
|
m_bytes = Resource::memorySizeBytes(size, format);
|
||||||
DCHECK(m_manager || !m_backing);
|
DCHECK(m_manager || !m_backing);
|
||||||
if (m_manager)
|
if (m_manager)
|
||||||
m_manager->returnBackingTexture(this);
|
m_manager->returnBackingTexture(this);
|
||||||
@@ -133,7 +133,7 @@ void PrioritizedResource::setToSelfManagedMemoryPlaceholder(size_t bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrioritizedResource::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)
|
: Resource(id, size, format)
|
||||||
, m_owner(0)
|
, m_owner(0)
|
||||||
, m_priorityAtLastPriorityUpdate(PriorityCalculator::lowestPriority())
|
, m_priorityAtLastPriorityUpdate(PriorityCalculator::lowestPriority())
|
||||||
, m_wasAbovePriorityCutoffAtLastPriorityUpdate(false)
|
, m_wasAbovePriorityCutoffAtLastPriorityUpdate(false)
|
||||||
|
@@ -10,12 +10,12 @@
|
|||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "cc/cc_export.h"
|
#include "cc/cc_export.h"
|
||||||
#include "cc/priority_calculator.h"
|
#include "cc/priority_calculator.h"
|
||||||
|
#include "cc/resource.h"
|
||||||
#include "cc/resource_provider.h"
|
#include "cc/resource_provider.h"
|
||||||
#include "cc/texture.h"
|
#include "third_party/khronos/GLES2/gl2.h"
|
||||||
#include "ui/gfx/rect.h"
|
#include "ui/gfx/rect.h"
|
||||||
#include "ui/gfx/size.h"
|
#include "ui/gfx/size.h"
|
||||||
#include "ui/gfx/vector2d.h"
|
#include "ui/gfx/vector2d.h"
|
||||||
#include "third_party/khronos/GLES2/gl2.h"
|
|
||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ private:
|
|||||||
friend class PrioritizedResourceManager;
|
friend class PrioritizedResourceManager;
|
||||||
friend class PrioritizedResourceTest;
|
friend class PrioritizedResourceTest;
|
||||||
|
|
||||||
class Backing : public Texture {
|
class Backing : public Resource {
|
||||||
public:
|
public:
|
||||||
Backing(unsigned id, ResourceProvider*, gfx::Size, GLenum format);
|
Backing(unsigned id, ResourceProvider*, gfx::Size, GLenum format);
|
||||||
~Backing();
|
~Backing();
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
#include "cc/proxy.h"
|
#include "cc/proxy.h"
|
||||||
#include "cc/prioritized_resource.h"
|
#include "cc/prioritized_resource.h"
|
||||||
#include "cc/priority_calculator.h"
|
#include "cc/priority_calculator.h"
|
||||||
#include "cc/texture.h"
|
#include "cc/resource.h"
|
||||||
#include "third_party/khronos/GLES2/gl2.h"
|
#include "third_party/khronos/GLES2/gl2.h"
|
||||||
#include "ui/gfx/size.h"
|
#include "ui/gfx/size.h"
|
||||||
|
|
||||||
|
@@ -7,11 +7,11 @@
|
|||||||
#include "cc/prioritized_resource.h"
|
#include "cc/prioritized_resource.h"
|
||||||
|
|
||||||
#include "cc/prioritized_resource_manager.h"
|
#include "cc/prioritized_resource_manager.h"
|
||||||
|
#include "cc/resource.h"
|
||||||
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
|
#include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread
|
||||||
#include "cc/test/fake_graphics_context.h"
|
#include "cc/test/fake_graphics_context.h"
|
||||||
#include "cc/test/fake_proxy.h"
|
#include "cc/test/fake_proxy.h"
|
||||||
#include "cc/test/tiled_layer_test_common.h"
|
#include "cc/test/tiled_layer_test_common.h"
|
||||||
#include "cc/texture.h"
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
using namespace cc;
|
using namespace cc;
|
||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
size_t texturesMemorySize(size_t textureCount)
|
size_t texturesMemorySize(size_t textureCount)
|
||||||
{
|
{
|
||||||
return Texture::memorySizeBytes(m_textureSize, m_textureFormat) * textureCount;
|
return Resource::memorySizeBytes(m_textureSize, m_textureFormat) * textureCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures)
|
scoped_ptr<PrioritizedResourceManager> createManager(size_t maxTextures)
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
|
|
||||||
class ScopedTexture;
|
class ScopedResource;
|
||||||
|
|
||||||
class CC_EXPORT RendererClient {
|
class CC_EXPORT RendererClient {
|
||||||
public:
|
public:
|
||||||
|
@@ -4,18 +4,18 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "cc/texture.h"
|
#include "cc/resource.h"
|
||||||
#include "third_party/khronos/GLES2/gl2ext.h"
|
#include "third_party/khronos/GLES2/gl2ext.h"
|
||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
|
|
||||||
void Texture::setDimensions(const gfx::Size& size, GLenum format)
|
void Resource::setDimensions(const gfx::Size& size, GLenum format)
|
||||||
{
|
{
|
||||||
m_size = size;
|
m_size = size;
|
||||||
m_format = format;
|
m_format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Texture::bytes() const
|
size_t Resource::bytes() const
|
||||||
{
|
{
|
||||||
if (m_size.IsEmpty())
|
if (m_size.IsEmpty())
|
||||||
return 0u;
|
return 0u;
|
||||||
@@ -23,7 +23,7 @@ size_t Texture::bytes() const
|
|||||||
return memorySizeBytes(m_size, m_format);
|
return memorySizeBytes(m_size, m_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Texture::bytesPerPixel(GLenum format)
|
size_t Resource::bytesPerPixel(GLenum format)
|
||||||
{
|
{
|
||||||
unsigned int componentsPerPixel = 0;
|
unsigned int componentsPerPixel = 0;
|
||||||
unsigned int bytesPerComponent = 1;
|
unsigned int bytesPerComponent = 1;
|
||||||
@@ -41,7 +41,7 @@ size_t Texture::bytesPerPixel(GLenum format)
|
|||||||
return componentsPerPixel * bytesPerComponent;
|
return componentsPerPixel * bytesPerComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Texture::memorySizeBytes(const gfx::Size& size, GLenum format)
|
size_t Resource::memorySizeBytes(const gfx::Size& size, GLenum format)
|
||||||
{
|
{
|
||||||
return bytesPerPixel(format) * size.width() * size.height();
|
return bytesPerPixel(format) * size.width() * size.height();
|
||||||
}
|
}
|
@@ -2,8 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef CC_TEXTURE_H_
|
#ifndef CC_RESOURCE_H_
|
||||||
#define CC_TEXTURE_H_
|
#define CC_RESOURCE_H_
|
||||||
|
|
||||||
#include "cc/cc_export.h"
|
#include "cc/cc_export.h"
|
||||||
#include "cc/resource_provider.h"
|
#include "cc/resource_provider.h"
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
|
|
||||||
class CC_EXPORT Texture {
|
class CC_EXPORT Resource {
|
||||||
public:
|
public:
|
||||||
Texture() : m_id(0) { }
|
Resource() : m_id(0) { }
|
||||||
Texture(unsigned id, gfx::Size size, GLenum format)
|
Resource(unsigned id, gfx::Size size, GLenum format)
|
||||||
: m_id(id)
|
: m_id(id)
|
||||||
, m_size(size)
|
, m_size(size)
|
||||||
, m_format(format) { }
|
, m_format(format) { }
|
||||||
@@ -40,4 +40,4 @@ private:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CC_TEXTURE_H_
|
#endif // CC_RESOURCE_H_
|
@@ -4,22 +4,22 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "cc/scoped_texture.h"
|
#include "cc/scoped_resource.h"
|
||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
|
|
||||||
ScopedTexture::ScopedTexture(ResourceProvider* resourceProvider)
|
ScopedResource::ScopedResource(ResourceProvider* resourceProvider)
|
||||||
: m_resourceProvider(resourceProvider)
|
: m_resourceProvider(resourceProvider)
|
||||||
{
|
{
|
||||||
DCHECK(m_resourceProvider);
|
DCHECK(m_resourceProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedTexture::~ScopedTexture()
|
ScopedResource::~ScopedResource()
|
||||||
{
|
{
|
||||||
free();
|
free();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScopedTexture::allocate(int pool, const gfx::Size& size, GLenum format, ResourceProvider::TextureUsageHint hint)
|
bool ScopedResource::allocate(int pool, const gfx::Size& size, GLenum format, ResourceProvider::TextureUsageHint hint)
|
||||||
{
|
{
|
||||||
DCHECK(!id());
|
DCHECK(!id());
|
||||||
DCHECK(!size.IsEmpty());
|
DCHECK(!size.IsEmpty());
|
||||||
@@ -34,7 +34,7 @@ bool ScopedTexture::allocate(int pool, const gfx::Size& size, GLenum format, Res
|
|||||||
return id();
|
return id();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopedTexture::free()
|
void ScopedResource::free()
|
||||||
{
|
{
|
||||||
if (id()) {
|
if (id()) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@@ -45,7 +45,7 @@ void ScopedTexture::free()
|
|||||||
setId(0);
|
setId(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopedTexture::leak()
|
void ScopedResource::leak()
|
||||||
{
|
{
|
||||||
setId(0);
|
setId(0);
|
||||||
}
|
}
|
@@ -2,14 +2,14 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef CC_SCOPED_TEXTURE_H_
|
#ifndef CC_SCOPED_RESOURCE_H_
|
||||||
#define CC_SCOPED_TEXTURE_H_
|
#define CC_SCOPED_RESOURCE_H_
|
||||||
|
|
||||||
#include "base/basictypes.h"
|
#include "base/basictypes.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/memory/scoped_ptr.h"
|
#include "base/memory/scoped_ptr.h"
|
||||||
#include "cc/cc_export.h"
|
#include "cc/cc_export.h"
|
||||||
#include "cc/texture.h"
|
#include "cc/resource.h"
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include "base/threading/platform_thread.h"
|
#include "base/threading/platform_thread.h"
|
||||||
@@ -17,22 +17,22 @@
|
|||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
|
|
||||||
class CC_EXPORT ScopedTexture : protected Texture {
|
class CC_EXPORT ScopedResource : protected Resource {
|
||||||
public:
|
public:
|
||||||
static scoped_ptr<ScopedTexture> create(ResourceProvider* resourceProvider) { return make_scoped_ptr(new ScopedTexture(resourceProvider)); }
|
static scoped_ptr<ScopedResource> create(ResourceProvider* resourceProvider) { return make_scoped_ptr(new ScopedResource(resourceProvider)); }
|
||||||
virtual ~ScopedTexture();
|
virtual ~ScopedResource();
|
||||||
|
|
||||||
using Texture::id;
|
using Resource::id;
|
||||||
using Texture::size;
|
using Resource::size;
|
||||||
using Texture::format;
|
using Resource::format;
|
||||||
using Texture::bytes;
|
using Resource::bytes;
|
||||||
|
|
||||||
bool allocate(int pool, const gfx::Size&, GLenum format, ResourceProvider::TextureUsageHint);
|
bool allocate(int pool, const gfx::Size&, GLenum format, ResourceProvider::TextureUsageHint);
|
||||||
void free();
|
void free();
|
||||||
void leak();
|
void leak();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit ScopedTexture(ResourceProvider*);
|
explicit ScopedResource(ResourceProvider*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ResourceProvider* m_resourceProvider;
|
ResourceProvider* m_resourceProvider;
|
||||||
@@ -41,9 +41,9 @@ private:
|
|||||||
base::PlatformThreadId m_allocateThreadIdentifier;
|
base::PlatformThreadId m_allocateThreadIdentifier;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ScopedTexture);
|
DISALLOW_COPY_AND_ASSIGN(ScopedResource);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CC_SCOPED_TEXTURE_H_
|
#endif // CC_SCOPED_RESOURCE_H_
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "cc/scoped_texture.h"
|
#include "cc/scoped_resource.h"
|
||||||
|
|
||||||
#include "cc/renderer.h"
|
#include "cc/renderer.h"
|
||||||
#include "cc/test/fake_graphics_context.h"
|
#include "cc/test/fake_graphics_context.h"
|
||||||
@@ -18,11 +18,11 @@ using namespace WebKitTests;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
TEST(ScopedTextureTest, NewScopedTexture)
|
TEST(ScopedResourceTest, NewScopedResource)
|
||||||
{
|
{
|
||||||
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
||||||
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
||||||
scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvider.get());
|
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
|
||||||
|
|
||||||
// New scoped textures do not hold a texture yet.
|
// New scoped textures do not hold a texture yet.
|
||||||
EXPECT_EQ(0u, texture->id());
|
EXPECT_EQ(0u, texture->id());
|
||||||
@@ -32,11 +32,11 @@ TEST(ScopedTextureTest, NewScopedTexture)
|
|||||||
EXPECT_EQ(0u, texture->bytes());
|
EXPECT_EQ(0u, texture->bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ScopedTextureTest, CreateScopedTexture)
|
TEST(ScopedResourceTest, CreateScopedResource)
|
||||||
{
|
{
|
||||||
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
||||||
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
||||||
scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvider.get());
|
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
|
||||||
texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
|
texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
|
||||||
|
|
||||||
// The texture has an allocated byte-size now.
|
// The texture has an allocated byte-size now.
|
||||||
@@ -48,13 +48,13 @@ TEST(ScopedTextureTest, CreateScopedTexture)
|
|||||||
EXPECT_EQ(gfx::Size(30, 30), texture->size());
|
EXPECT_EQ(gfx::Size(30, 30), texture->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ScopedTextureTest, ScopedTextureIsDeleted)
|
TEST(ScopedResourceTest, ScopedResourceIsDeleted)
|
||||||
{
|
{
|
||||||
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
||||||
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
||||||
|
|
||||||
{
|
{
|
||||||
scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvider.get());
|
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
|
||||||
|
|
||||||
EXPECT_EQ(0u, resourceProvider->numResources());
|
EXPECT_EQ(0u, resourceProvider->numResources());
|
||||||
texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
|
texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
|
||||||
@@ -65,7 +65,7 @@ TEST(ScopedTextureTest, ScopedTextureIsDeleted)
|
|||||||
EXPECT_EQ(0u, resourceProvider->numResources());
|
EXPECT_EQ(0u, resourceProvider->numResources());
|
||||||
|
|
||||||
{
|
{
|
||||||
scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvider.get());
|
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
|
||||||
EXPECT_EQ(0u, resourceProvider->numResources());
|
EXPECT_EQ(0u, resourceProvider->numResources());
|
||||||
texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
|
texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
|
||||||
EXPECT_LT(0u, texture->id());
|
EXPECT_LT(0u, texture->id());
|
||||||
@@ -75,13 +75,13 @@ TEST(ScopedTextureTest, ScopedTextureIsDeleted)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ScopedTextureTest, LeakScopedTexture)
|
TEST(ScopedResourceTest, LeakScopedResource)
|
||||||
{
|
{
|
||||||
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
scoped_ptr<GraphicsContext> context(createFakeGraphicsContext());
|
||||||
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
scoped_ptr<ResourceProvider> resourceProvider(ResourceProvider::create(context.get()));
|
||||||
|
|
||||||
{
|
{
|
||||||
scoped_ptr<ScopedTexture> texture = ScopedTexture::create(resourceProvider.get());
|
scoped_ptr<ScopedResource> texture = ScopedResource::create(resourceProvider.get());
|
||||||
|
|
||||||
EXPECT_EQ(0u, resourceProvider->numResources());
|
EXPECT_EQ(0u, resourceProvider->numResources());
|
||||||
texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
|
texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny);
|
@@ -128,7 +128,7 @@ void SoftwareRenderer::bindFramebufferToOutputSurface(DrawingFrame& frame)
|
|||||||
m_skCurrentCanvas = m_skRootCanvas.get();
|
m_skCurrentCanvas = m_skRootCanvas.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoftwareRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedTexture* texture, const gfx::Rect& framebufferRect)
|
bool SoftwareRenderer::bindFramebufferToTexture(DrawingFrame& frame, const ScopedResource* texture, const gfx::Rect& framebufferRect)
|
||||||
{
|
{
|
||||||
m_currentFramebufferLock = make_scoped_ptr(new ResourceProvider::ScopedWriteLockSoftware(m_resourceProvider, texture->id()));
|
m_currentFramebufferLock = make_scoped_ptr(new ResourceProvider::ScopedWriteLockSoftware(m_resourceProvider, texture->id()));
|
||||||
m_skCurrentCanvas = m_currentFramebufferLock->skCanvas();
|
m_skCurrentCanvas = m_currentFramebufferLock->skCanvas();
|
||||||
@@ -276,7 +276,7 @@ void SoftwareRenderer::drawTileQuad(const DrawingFrame& frame, const TileDrawQua
|
|||||||
|
|
||||||
void SoftwareRenderer::drawRenderPassQuad(const DrawingFrame& frame, const RenderPassDrawQuad* quad)
|
void SoftwareRenderer::drawRenderPassQuad(const DrawingFrame& frame, const RenderPassDrawQuad* quad)
|
||||||
{
|
{
|
||||||
CachedTexture* contentTexture = m_renderPassTextures.get(quad->renderPassId());
|
CachedResource* contentTexture = m_renderPassTextures.get(quad->renderPassId());
|
||||||
if (!contentTexture || !contentTexture->id())
|
if (!contentTexture || !contentTexture->id())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void bindFramebufferToOutputSurface(DrawingFrame&) OVERRIDE;
|
virtual void bindFramebufferToOutputSurface(DrawingFrame&) OVERRIDE;
|
||||||
virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedTexture*, const gfx::Rect& framebufferRect) OVERRIDE;
|
virtual bool bindFramebufferToTexture(DrawingFrame&, const ScopedResource*, const gfx::Rect& framebufferRect) OVERRIDE;
|
||||||
virtual void setDrawViewportSize(const gfx::Size&) OVERRIDE;
|
virtual void setDrawViewportSize(const gfx::Size&) OVERRIDE;
|
||||||
virtual void setScissorTestRect(const gfx::Rect& scissorRect) OVERRIDE;
|
virtual void setScissorTestRect(const gfx::Rect& scissorRect) OVERRIDE;
|
||||||
virtual void clearFramebuffer(DrawingFrame&) OVERRIDE;
|
virtual void clearFramebuffer(DrawingFrame&) OVERRIDE;
|
||||||
|
@@ -12,8 +12,8 @@
|
|||||||
#include "base/debug/alias.h"
|
#include "base/debug/alias.h"
|
||||||
#include "base/debug/trace_event.h"
|
#include "base/debug/trace_event.h"
|
||||||
#include "base/metrics/histogram.h"
|
#include "base/metrics/histogram.h"
|
||||||
#include "cc/texture.h"
|
|
||||||
#include "cc/prioritized_resource.h"
|
#include "cc/prioritized_resource.h"
|
||||||
|
#include "cc/resource.h"
|
||||||
#include "third_party/khronos/GLES2/gl2.h"
|
#include "third_party/khronos/GLES2/gl2.h"
|
||||||
#include "third_party/khronos/GLES2/gl2ext.h"
|
#include "third_party/khronos/GLES2/gl2ext.h"
|
||||||
#include "ui/gfx/rect.h"
|
#include "ui/gfx/rect.h"
|
||||||
@@ -230,7 +230,7 @@ void TextureUploader::uploadWithTexSubImage(const uint8* image,
|
|||||||
gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
|
gfx::Vector2d offset(source_rect.origin() - image_rect.origin());
|
||||||
|
|
||||||
const uint8* pixel_source;
|
const uint8* pixel_source;
|
||||||
unsigned int bytes_per_pixel = Texture::bytesPerPixel(format);
|
unsigned int bytes_per_pixel = Resource::bytesPerPixel(format);
|
||||||
|
|
||||||
if (image_rect.width() == source_rect.width() && !offset.x()) {
|
if (image_rect.width() == source_rect.width() && !offset.x()) {
|
||||||
pixel_source = &image[bytes_per_pixel * offset.y() * image_rect.width()];
|
pixel_source = &image[bytes_per_pixel * offset.y() * image_rect.width()];
|
||||||
@@ -314,7 +314,7 @@ void TextureUploader::uploadWithMapTexSubImage(const uint8* image,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int bytes_per_pixel = Texture::bytesPerPixel(format);
|
unsigned int bytes_per_pixel = Resource::bytesPerPixel(format);
|
||||||
|
|
||||||
if (image_rect.width() == source_rect.width() && !offset.x()) {
|
if (image_rect.width() == source_rect.width() && !offset.x()) {
|
||||||
memcpy(pixel_dest,
|
memcpy(pixel_dest,
|
||||||
|
Reference in New Issue
Block a user