Skip to content

Commit

Permalink
cc: Rename Texture class to Resource.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
reveman@google.com committed Nov 8, 2012
1 parent 1c2433b commit f7685bc
Show file tree
Hide file tree
Showing 22 changed files with 105 additions and 105 deletions.
8 changes: 4 additions & 4 deletions cc/cc.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@
'renderer.cc',
'renderer.h',
'rendering_stats.h',
'resource.cc',
'resource.h',
'resource_provider.cc',
'resource_provider.h',
'resource_update.cc',
Expand All @@ -166,8 +168,8 @@
'scoped_ptr_deque.h',
'scoped_ptr_hash_map.h',
'scoped_ptr_vector.h',
'scoped_texture.cc',
'scoped_texture.h',
'scoped_resource.cc',
'scoped_resource.h',
'scoped_thread_proxy.cc',
'scoped_thread_proxy.h',
'scrollbar_animation_controller.cc',
Expand Down Expand Up @@ -204,8 +206,6 @@
'stream_video_draw_quad.h',
'switches.cc',
'switches.h',
'texture.cc',
'texture.h',
'texture_copier.cc',
'texture_copier.h',
'texture_draw_quad.cc',
Expand Down
2 changes: 1 addition & 1 deletion cc/cc_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
'resource_update_controller_unittest.cc',
'scheduler_state_machine_unittest.cc',
'scheduler_unittest.cc',
'scoped_texture_unittest.cc',
'scoped_resource_unittest.cc',
'scrollbar_animation_controller_linear_fade_unittest.cc',
'scrollbar_layer_unittest.cc',
'software_renderer_unittest.cc',
Expand Down
12 changes: 6 additions & 6 deletions cc/direct_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void DirectRenderer::decideRenderPassAllocationsForFrame(const RenderPassList& r
renderPassesInFrame.insert(std::pair<RenderPass::Id, const RenderPass*>(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i]));

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) {
base::hash_map<RenderPass::Id, const RenderPass*>::const_iterator it = renderPassesInFrame.find(passIterator->first);
if (it == renderPassesInFrame.end()) {
Expand All @@ -133,7 +133,7 @@ void DirectRenderer::decideRenderPassAllocationsForFrame(const RenderPassList& r
const RenderPass* renderPassInFrame = it->second;
const gfx::Size& requiredSize = renderPassTextureSize(renderPassInFrame);
GLenum requiredFormat = renderPassTextureFormat(renderPassInFrame);
CachedTexture* texture = passIterator->second;
CachedResource* texture = passIterator->second;
DCHECK(texture);

if (texture->id() && (texture->size() != requiredSize || texture->format() != requiredFormat))
Expand All @@ -146,7 +146,7 @@ void DirectRenderer::decideRenderPassAllocationsForFrame(const RenderPassList& r

for (size_t i = 0; i < renderPassesInDrawOrder.size(); ++i) {
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());
}
}
Expand Down Expand Up @@ -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)
texture->setIsComplete(!renderPass->hasOcclusionFromOutsideTargetSurface());
}
Expand All @@ -210,7 +210,7 @@ bool DirectRenderer::useRenderPass(DrawingFrame& frame, const RenderPass* render
return true;
}

CachedTexture* texture = m_renderPassTextures.get(renderPass->id());
CachedResource* texture = m_renderPassTextures.get(renderPass->id());
DCHECK(texture);
if (!texture->id() && !texture->allocate(Renderer::ImplPool, renderPassTextureSize(renderPass), renderPassTextureFormat(renderPass), ResourceProvider::TextureUsageFramebuffer))
return false;
Expand All @@ -220,7 +220,7 @@ bool DirectRenderer::useRenderPass(DrawingFrame& frame, const RenderPass* render

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();
}

Expand Down
22 changes: 11 additions & 11 deletions cc/direct_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "cc/cc_export.h"
#include "cc/renderer.h"
#include "cc/resource_provider.h"
#include "cc/scoped_texture.h"
#include "cc/scoped_resource.h"

namespace cc {

Expand Down Expand Up @@ -38,7 +38,7 @@ class CC_EXPORT DirectRenderer : public Renderer {
const RenderPassIdHashMap* renderPassesById;
const RenderPass* rootRenderPass;
const RenderPass* currentRenderPass;
const ScopedTexture* currentTexture;
const ScopedResource* currentTexture;

gfx::RectF rootDamageRect;

Expand All @@ -48,27 +48,27 @@ class CC_EXPORT DirectRenderer : public Renderer {
gfx::RectF scissorRectInRenderPassSpace;
};

class CachedTexture : public ScopedTexture {
class CachedResource : public ScopedResource {
public:
static scoped_ptr<CachedTexture> create(ResourceProvider* resourceProvider) {
return make_scoped_ptr(new CachedTexture(resourceProvider));
static scoped_ptr<CachedResource> create(ResourceProvider* resourceProvider) {
return make_scoped_ptr(new CachedResource(resourceProvider));
}
virtual ~CachedTexture() {}
virtual ~CachedResource() {}

bool isComplete() const { return m_isComplete; }
void setIsComplete(bool isComplete) { m_isComplete = isComplete; }

protected:
explicit CachedTexture(ResourceProvider* resourceProvider)
: ScopedTexture(resourceProvider)
explicit CachedResource(ResourceProvider* resourceProvider)
: ScopedResource(resourceProvider)
, m_isComplete(false)
{
}

private:
bool m_isComplete;

DISALLOW_COPY_AND_ASSIGN(CachedTexture);
DISALLOW_COPY_AND_ASSIGN(CachedResource);
};

static gfx::RectF quadVertexRect();
Expand All @@ -84,7 +84,7 @@ class CC_EXPORT DirectRenderer : public Renderer {
bool useRenderPass(DrawingFrame&, const RenderPass*);

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 setScissorTestRect(const gfx::Rect& scissorRect) = 0;
virtual void clearFramebuffer(DrawingFrame&) = 0;
Expand All @@ -93,7 +93,7 @@ class CC_EXPORT DirectRenderer : public Renderer {
virtual void finishDrawingFrame(DrawingFrame&) = 0;
virtual bool flippedFramebuffer() const = 0;

ScopedPtrHashMap<RenderPass::Id, CachedTexture> m_renderPassTextures;
ScopedPtrHashMap<RenderPass::Id, CachedResource> m_renderPassTextures;
ResourceProvider* m_resourceProvider;

private:
Expand Down
34 changes: 17 additions & 17 deletions cc/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "cc/proxy.h"
#include "cc/render_pass.h"
#include "cc/render_surface_filters.h"
#include "cc/scoped_texture.h"
#include "cc/scoped_resource.h"
#include "cc/settings.h"
#include "cc/single_thread_proxy.h"
#include "cc/stream_video_draw_quad.h"
Expand Down Expand Up @@ -358,7 +358,7 @@ static GrContext* getFilterGrContext(bool hasImplThread)
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())
return SkBitmap();
Expand All @@ -376,7 +376,7 @@ static inline SkBitmap applyFilters(GLRenderer* renderer, const WebKit::WebFilte
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)
return SkBitmap();
Expand Down Expand Up @@ -428,7 +428,7 @@ static SkBitmap applyImageFilter(GLRenderer* renderer, SkImageFilter* filter, Sc
return device.accessBitmap(false);
}

scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(
scoped_ptr<ScopedResource> GLRenderer::drawBackgroundFilters(
DrawingFrame& frame, const RenderPassDrawQuad* quad,
const WebKit::WebFilterOperations& filters,
const WebTransformationMatrix& contentsDeviceTransform,
Expand All @@ -451,12 +451,12 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(
// FIXME: When this algorithm changes, update LayerTreeHost::prioritizeTextures() accordingly.

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
// translucent pixels, and the contents behind those translucent pixels wouldn't have the filter applied.
if (frame.currentRenderPass->hasTransparentBackground())
return scoped_ptr<ScopedTexture>();
return scoped_ptr<ScopedResource>();
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).
Expand All @@ -468,20 +468,20 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(

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))
return scoped_ptr<ScopedTexture>();
return scoped_ptr<ScopedResource>();

SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get(), m_client->hasImplThread());
if (!filteredDeviceBackground.getTexture())
return scoped_ptr<ScopedTexture>();
return scoped_ptr<ScopedResource>();

GrTexture* texture = reinterpret_cast<GrTexture*>(filteredDeviceBackground.getTexture());
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))
return scoped_ptr<ScopedTexture>();
return scoped_ptr<ScopedResource>();

const RenderPass* targetRenderPass = frame.currentRenderPass;
bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(), quad->quadRect());
Expand All @@ -498,13 +498,13 @@ scoped_ptr<ScopedTexture> GLRenderer::drawBackgroundFilters(
useRenderPass(frame, targetRenderPass);

if (!usingBackgroundTexture)
return scoped_ptr<ScopedTexture>();
return scoped_ptr<ScopedResource>();
return backgroundTexture.Pass();
}

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())
return;

Expand All @@ -522,7 +522,7 @@ void GLRenderer::drawRenderPassQuad(DrawingFrame& frame, const RenderPassDrawQua
return;

WebTransformationMatrix contentsDeviceTransformInverse = contentsDeviceTransform.inverse();
scoped_ptr<ScopedTexture> backgroundTexture = drawBackgroundFilters(
scoped_ptr<ScopedResource> backgroundTexture = drawBackgroundFilters(
frame, quad, renderPass->backgroundFilters(),
contentsDeviceTransform, contentsDeviceTransformInverse);

Expand Down Expand Up @@ -1294,7 +1294,7 @@ void GLRenderer::getFramebufferPixels(void *pixels, const gfx::Rect& rect)
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));

Expand All @@ -1308,7 +1308,7 @@ bool GLRenderer::getFramebufferTexture(ScopedTexture* texture, const gfx::Rect&
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());
frame.currentRenderPass = 0;
Expand All @@ -1323,7 +1323,7 @@ void GLRenderer::bindFramebufferToOutputSurface(DrawingFrame& frame)
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());

Expand Down
10 changes: 5 additions & 5 deletions cc/gl_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WebGraphicsContext3D;

namespace cc {

class ScopedTexture;
class ScopedResource;
class StreamVideoDrawQuad;
class TextureDrawQuad;
class GeometryBinding;
Expand Down Expand Up @@ -71,11 +71,11 @@ class CC_EXPORT GLRenderer : public DirectRenderer,
const gfx::QuadF& sharedGeometryQuad() const { return m_sharedGeometryQuad; }
const GeometryBinding* sharedGeometry() const { return m_sharedGeometry.get(); }

bool getFramebufferTexture(ScopedTexture*, const gfx::Rect& deviceRect);
bool getFramebufferTexture(ScopedResource*, const gfx::Rect& deviceRect);
void releaseRenderPassTextures();

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 setScissorTestRect(const gfx::Rect& scissorRect) OVERRIDE;
virtual void clearFramebuffer(DrawingFrame&) OVERRIDE;
Expand All @@ -90,7 +90,7 @@ class CC_EXPORT GLRenderer : public DirectRenderer,

void drawCheckerboardQuad(const DrawingFrame&, const CheckerboardDrawQuad*);
void drawDebugBorderQuad(const DrawingFrame&, const DebugBorderDrawQuad*);
scoped_ptr<ScopedTexture> drawBackgroundFilters(
scoped_ptr<ScopedResource> drawBackgroundFilters(
DrawingFrame&, const RenderPassDrawQuad*, const WebKit::WebFilterOperations&,
const WebKit::WebTransformationMatrix& contentsDeviceTransform,
const WebKit::WebTransformationMatrix& contentsDeviceTransformInverse);
Expand All @@ -108,7 +108,7 @@ class CC_EXPORT GLRenderer : public DirectRenderer,

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();

Expand Down
2 changes: 1 addition & 1 deletion cc/heads_up_display_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void HeadsUpDisplayLayerImpl::willDraw(ResourceProvider* resourceProvider)
LayerImpl::willDraw(resourceProvider);

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.

Expand Down
4 changes: 2 additions & 2 deletions cc/heads_up_display_layer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "cc/cc_export.h"
#include "cc/font_atlas.h"
#include "cc/layer_impl.h"
#include "cc/scoped_texture.h"
#include "cc/scoped_resource.h"

class SkCanvas;
class SkPaint;
Expand Down Expand Up @@ -54,7 +54,7 @@ class CC_EXPORT HeadsUpDisplayLayerImpl : public LayerImpl {
void drawDebugRects(SkCanvas*, DebugRectHistory*);

scoped_ptr<FontAtlas> m_fontAtlas;
scoped_ptr<ScopedTexture> m_hudTexture;
scoped_ptr<ScopedResource> m_hudTexture;
scoped_ptr<SkCanvas> m_hudCanvas;

double m_averageFPS;
Expand Down
4 changes: 2 additions & 2 deletions cc/layer_tree_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ size_t LayerTreeHost::calculateMemoryForRenderSurfaces(const LayerList& updateLi
Layer* renderSurfaceLayer = updateList[i].get();
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;

if (renderSurfaceLayer->backgroundFilters().isEmpty())
Expand All @@ -636,7 +636,7 @@ size_t LayerTreeHost::calculateMemoryForRenderSurfaces(const LayerList& updateLi
if (bytes > maxBackgroundTextureBytes)
maxBackgroundTextureBytes = bytes;
if (!readbackBytes)
readbackBytes = Texture::memorySizeBytes(m_deviceViewportSize, GL_RGBA);
readbackBytes = Resource::memorySizeBytes(m_deviceViewportSize, GL_RGBA);
}
return readbackBytes + maxBackgroundTextureBytes + contentsTextureBytes;
}
Expand Down
Loading

0 comments on commit f7685bc

Please sign in to comment.