diff options
-rw-r--r-- | cc/cc.gyp | 8 | ||||
-rw-r--r-- | cc/cc_tests.gyp | 2 | ||||
-rw-r--r-- | cc/direct_renderer.cc | 12 | ||||
-rw-r--r-- | cc/direct_renderer.h | 22 | ||||
-rw-r--r-- | cc/gl_renderer.cc | 34 | ||||
-rw-r--r-- | cc/gl_renderer.h | 10 | ||||
-rw-r--r-- | cc/heads_up_display_layer_impl.cc | 2 | ||||
-rw-r--r-- | cc/heads_up_display_layer_impl.h | 4 | ||||
-rw-r--r-- | cc/layer_tree_host.cc | 4 | ||||
-rw-r--r-- | cc/prioritized_resource.cc | 6 | ||||
-rw-r--r-- | cc/prioritized_resource.h | 6 | ||||
-rw-r--r-- | cc/prioritized_resource_manager.h | 2 | ||||
-rw-r--r-- | cc/prioritized_resource_unittest.cc | 4 | ||||
-rw-r--r-- | cc/renderer.h | 2 | ||||
-rw-r--r-- | cc/resource.cc (renamed from cc/texture.cc) | 10 | ||||
-rw-r--r-- | cc/resource.h (renamed from cc/texture.h) | 12 | ||||
-rw-r--r-- | cc/scoped_resource.cc (renamed from cc/scoped_texture.cc) | 12 | ||||
-rw-r--r-- | cc/scoped_resource.h (renamed from cc/scoped_texture.h) | 26 | ||||
-rw-r--r-- | cc/scoped_resource_unittest.cc (renamed from cc/scoped_texture_unittest.cc) | 20 | ||||
-rw-r--r-- | cc/software_renderer.cc | 4 | ||||
-rw-r--r-- | cc/software_renderer.h | 2 | ||||
-rw-r--r-- | cc/texture_uploader.cc | 6 |
22 files changed, 105 insertions, 105 deletions
@@ -151,6 +151,8 @@ 'renderer.cc', 'renderer.h', 'rendering_stats.h', + 'resource.cc', + 'resource.h', 'resource_provider.cc', 'resource_provider.h', 'resource_update.cc', @@ -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', @@ -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', diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp index e02fb95..94e840af 100644 --- a/cc/cc_tests.gyp +++ b/cc/cc_tests.gyp @@ -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', diff --git a/cc/direct_renderer.cc b/cc/direct_renderer.cc index 4c9e2ef..ee0e1c1 100644 --- a/cc/direct_renderer.cc +++ b/cc/direct_renderer.cc @@ -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()) { @@ -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)) @@ -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()); } } @@ -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()); } @@ -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; @@ -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(); } diff --git a/cc/direct_renderer.h b/cc/direct_renderer.h index 47c38bc..25a9e46 100644 --- a/cc/direct_renderer.h +++ b/cc/direct_renderer.h @@ -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 { @@ -38,7 +38,7 @@ protected: const RenderPassIdHashMap* renderPassesById; const RenderPass* rootRenderPass; const RenderPass* currentRenderPass; - const ScopedTexture* currentTexture; + const ScopedResource* currentTexture; gfx::RectF rootDamageRect; @@ -48,19 +48,19 @@ protected: 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) { } @@ -68,7 +68,7 @@ protected: private: bool m_isComplete; - DISALLOW_COPY_AND_ASSIGN(CachedTexture); + DISALLOW_COPY_AND_ASSIGN(CachedResource); }; static gfx::RectF quadVertexRect(); @@ -84,7 +84,7 @@ protected: 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; @@ -93,7 +93,7 @@ protected: 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: diff --git a/cc/gl_renderer.cc b/cc/gl_renderer.cc index e768952..7016d91 100644 --- a/cc/gl_renderer.cc +++ b/cc/gl_renderer.cc @@ -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" @@ -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(); @@ -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(); @@ -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, @@ -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). @@ -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()); @@ -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; @@ -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); @@ -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)); @@ -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; @@ -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()); diff --git a/cc/gl_renderer.h b/cc/gl_renderer.h index ba861bc..184c144 100644 --- a/cc/gl_renderer.h +++ b/cc/gl_renderer.h @@ -23,7 +23,7 @@ class WebGraphicsContext3D; namespace cc { -class ScopedTexture; +class ScopedResource; class StreamVideoDrawQuad; class TextureDrawQuad; class GeometryBinding; @@ -71,11 +71,11 @@ protected: 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; @@ -90,7 +90,7 @@ private: 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); @@ -108,7 +108,7 @@ private: 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(); diff --git a/cc/heads_up_display_layer_impl.cc b/cc/heads_up_display_layer_impl.cc index 1c0c5fe..8aeb51d 100644 --- a/cc/heads_up_display_layer_impl.cc +++ b/cc/heads_up_display_layer_impl.cc @@ -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. diff --git a/cc/heads_up_display_layer_impl.h b/cc/heads_up_display_layer_impl.h index f054147..afe6532 100644 --- a/cc/heads_up_display_layer_impl.h +++ b/cc/heads_up_display_layer_impl.h @@ -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; @@ -54,7 +54,7 @@ private: 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; diff --git a/cc/layer_tree_host.cc b/cc/layer_tree_host.cc index 6a0f825..0d7da692 100644 --- a/cc/layer_tree_host.cc +++ b/cc/layer_tree_host.cc @@ -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()) @@ -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; } diff --git a/cc/prioritized_resource.cc b/cc/prioritized_resource.cc index 280d7b5..86911b1 100644 --- a/cc/prioritized_resource.cc +++ b/cc/prioritized_resource.cc @@ -30,7 +30,7 @@ PrioritizedResource::PrioritizedResource(PrioritizedResourceManager* manager, gf // m_manager is set in registerTexture() so validity can be checked. DCHECK(format || size.IsEmpty()); if (format) - m_bytes = Texture::memorySizeBytes(size, format); + m_bytes = Resource::memorySizeBytes(size, format); if (manager) manager->registerTexture(this); } @@ -57,7 +57,7 @@ void PrioritizedResource::setDimensions(gfx::Size size, GLenum format) m_isAbovePriorityCutoff = false; m_format = format; m_size = size; - m_bytes = Texture::memorySizeBytes(size, format); + m_bytes = Resource::memorySizeBytes(size, format); DCHECK(m_manager || !m_backing); if (m_manager) 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) - : Texture(id, size, format) + : Resource(id, size, format) , m_owner(0) , m_priorityAtLastPriorityUpdate(PriorityCalculator::lowestPriority()) , m_wasAbovePriorityCutoffAtLastPriorityUpdate(false) diff --git a/cc/prioritized_resource.h b/cc/prioritized_resource.h index 8197e57..2f8cac8 100644 --- a/cc/prioritized_resource.h +++ b/cc/prioritized_resource.h @@ -10,12 +10,12 @@ #include "base/memory/scoped_ptr.h" #include "cc/cc_export.h" #include "cc/priority_calculator.h" +#include "cc/resource.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/size.h" #include "ui/gfx/vector2d.h" -#include "third_party/khronos/GLES2/gl2.h" namespace cc { @@ -92,7 +92,7 @@ private: friend class PrioritizedResourceManager; friend class PrioritizedResourceTest; - class Backing : public Texture { + class Backing : public Resource { public: Backing(unsigned id, ResourceProvider*, gfx::Size, GLenum format); ~Backing(); diff --git a/cc/prioritized_resource_manager.h b/cc/prioritized_resource_manager.h index 13676ae..7f98c16 100644 --- a/cc/prioritized_resource_manager.h +++ b/cc/prioritized_resource_manager.h @@ -15,7 +15,7 @@ #include "cc/proxy.h" #include "cc/prioritized_resource.h" #include "cc/priority_calculator.h" -#include "cc/texture.h" +#include "cc/resource.h" #include "third_party/khronos/GLES2/gl2.h" #include "ui/gfx/size.h" diff --git a/cc/prioritized_resource_unittest.cc b/cc/prioritized_resource_unittest.cc index 6255202..c542395 100644 --- a/cc/prioritized_resource_unittest.cc +++ b/cc/prioritized_resource_unittest.cc @@ -7,11 +7,11 @@ #include "cc/prioritized_resource.h" #include "cc/prioritized_resource_manager.h" +#include "cc/resource.h" #include "cc/single_thread_proxy.h" // For DebugScopedSetImplThread #include "cc/test/fake_graphics_context.h" #include "cc/test/fake_proxy.h" #include "cc/test/tiled_layer_test_common.h" -#include "cc/texture.h" #include "testing/gtest/include/gtest/gtest.h" using namespace cc; @@ -39,7 +39,7 @@ public: 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) diff --git a/cc/renderer.h b/cc/renderer.h index f5d0fc6..9e8e877 100644 --- a/cc/renderer.h +++ b/cc/renderer.h @@ -13,7 +13,7 @@ namespace cc { -class ScopedTexture; +class ScopedResource; class CC_EXPORT RendererClient { public: diff --git a/cc/texture.cc b/cc/resource.cc index af74f31..0995793 100644 --- a/cc/texture.cc +++ b/cc/resource.cc @@ -4,18 +4,18 @@ #include "config.h" -#include "cc/texture.h" +#include "cc/resource.h" #include "third_party/khronos/GLES2/gl2ext.h" namespace cc { -void Texture::setDimensions(const gfx::Size& size, GLenum format) +void Resource::setDimensions(const gfx::Size& size, GLenum format) { m_size = size; m_format = format; } -size_t Texture::bytes() const +size_t Resource::bytes() const { if (m_size.IsEmpty()) return 0u; @@ -23,7 +23,7 @@ size_t Texture::bytes() const return memorySizeBytes(m_size, m_format); } -size_t Texture::bytesPerPixel(GLenum format) +size_t Resource::bytesPerPixel(GLenum format) { unsigned int componentsPerPixel = 0; unsigned int bytesPerComponent = 1; @@ -41,7 +41,7 @@ size_t Texture::bytesPerPixel(GLenum format) 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(); } diff --git a/cc/texture.h b/cc/resource.h index cd9df1d..773b7a3 100644 --- a/cc/texture.h +++ b/cc/resource.h @@ -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_TEXTURE_H_ -#define CC_TEXTURE_H_ +#ifndef CC_RESOURCE_H_ +#define CC_RESOURCE_H_ #include "cc/cc_export.h" #include "cc/resource_provider.h" @@ -12,10 +12,10 @@ namespace cc { -class CC_EXPORT Texture { +class CC_EXPORT Resource { public: - Texture() : m_id(0) { } - Texture(unsigned id, gfx::Size size, GLenum format) + Resource() : m_id(0) { } + Resource(unsigned id, gfx::Size size, GLenum format) : m_id(id) , m_size(size) , m_format(format) { } @@ -40,4 +40,4 @@ private: } -#endif // CC_TEXTURE_H_ +#endif // CC_RESOURCE_H_ diff --git a/cc/scoped_texture.cc b/cc/scoped_resource.cc index 38fb797..5729718 100644 --- a/cc/scoped_texture.cc +++ b/cc/scoped_resource.cc @@ -4,22 +4,22 @@ #include "config.h" -#include "cc/scoped_texture.h" +#include "cc/scoped_resource.h" namespace cc { -ScopedTexture::ScopedTexture(ResourceProvider* resourceProvider) +ScopedResource::ScopedResource(ResourceProvider* resourceProvider) : m_resourceProvider(resourceProvider) { DCHECK(m_resourceProvider); } -ScopedTexture::~ScopedTexture() +ScopedResource::~ScopedResource() { 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(!size.IsEmpty()); @@ -34,7 +34,7 @@ bool ScopedTexture::allocate(int pool, const gfx::Size& size, GLenum format, Res return id(); } -void ScopedTexture::free() +void ScopedResource::free() { if (id()) { #ifndef NDEBUG @@ -45,7 +45,7 @@ void ScopedTexture::free() setId(0); } -void ScopedTexture::leak() +void ScopedResource::leak() { setId(0); } diff --git a/cc/scoped_texture.h b/cc/scoped_resource.h index 4fe1394..1ad5cc7 100644 --- a/cc/scoped_texture.h +++ b/cc/scoped_resource.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CC_SCOPED_TEXTURE_H_ -#define CC_SCOPED_TEXTURE_H_ +#ifndef CC_SCOPED_RESOURCE_H_ +#define CC_SCOPED_RESOURCE_H_ #include "base/basictypes.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "cc/cc_export.h" -#include "cc/texture.h" +#include "cc/resource.h" #ifndef NDEBUG #include "base/threading/platform_thread.h" @@ -17,22 +17,22 @@ namespace cc { -class CC_EXPORT ScopedTexture : protected Texture { +class CC_EXPORT ScopedResource : protected Resource { public: - static scoped_ptr<ScopedTexture> create(ResourceProvider* resourceProvider) { return make_scoped_ptr(new ScopedTexture(resourceProvider)); } - virtual ~ScopedTexture(); + static scoped_ptr<ScopedResource> create(ResourceProvider* resourceProvider) { return make_scoped_ptr(new ScopedResource(resourceProvider)); } + virtual ~ScopedResource(); - using Texture::id; - using Texture::size; - using Texture::format; - using Texture::bytes; + using Resource::id; + using Resource::size; + using Resource::format; + using Resource::bytes; bool allocate(int pool, const gfx::Size&, GLenum format, ResourceProvider::TextureUsageHint); void free(); void leak(); protected: - explicit ScopedTexture(ResourceProvider*); + explicit ScopedResource(ResourceProvider*); private: ResourceProvider* m_resourceProvider; @@ -41,9 +41,9 @@ private: base::PlatformThreadId m_allocateThreadIdentifier; #endif - DISALLOW_COPY_AND_ASSIGN(ScopedTexture); + DISALLOW_COPY_AND_ASSIGN(ScopedResource); }; } -#endif // CC_SCOPED_TEXTURE_H_ +#endif // CC_SCOPED_RESOURCE_H_ diff --git a/cc/scoped_texture_unittest.cc b/cc/scoped_resource_unittest.cc index 232ec83..612e5a7 100644 --- a/cc/scoped_texture_unittest.cc +++ b/cc/scoped_resource_unittest.cc @@ -4,7 +4,7 @@ #include "config.h" -#include "cc/scoped_texture.h" +#include "cc/scoped_resource.h" #include "cc/renderer.h" #include "cc/test/fake_graphics_context.h" @@ -18,11 +18,11 @@ using namespace WebKitTests; namespace { -TEST(ScopedTextureTest, NewScopedTexture) +TEST(ScopedResourceTest, NewScopedResource) { scoped_ptr<GraphicsContext> context(createFakeGraphicsContext()); 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. EXPECT_EQ(0u, texture->id()); @@ -32,11 +32,11 @@ TEST(ScopedTextureTest, NewScopedTexture) EXPECT_EQ(0u, texture->bytes()); } -TEST(ScopedTextureTest, CreateScopedTexture) +TEST(ScopedResourceTest, CreateScopedResource) { scoped_ptr<GraphicsContext> context(createFakeGraphicsContext()); 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); // The texture has an allocated byte-size now. @@ -48,13 +48,13 @@ TEST(ScopedTextureTest, CreateScopedTexture) EXPECT_EQ(gfx::Size(30, 30), texture->size()); } -TEST(ScopedTextureTest, ScopedTextureIsDeleted) +TEST(ScopedResourceTest, ScopedResourceIsDeleted) { scoped_ptr<GraphicsContext> context(createFakeGraphicsContext()); 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()); texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); @@ -65,7 +65,7 @@ TEST(ScopedTextureTest, ScopedTextureIsDeleted) 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()); texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); 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<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()); texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); diff --git a/cc/software_renderer.cc b/cc/software_renderer.cc index 896bad43..6a64cc8 100644 --- a/cc/software_renderer.cc +++ b/cc/software_renderer.cc @@ -128,7 +128,7 @@ void SoftwareRenderer::bindFramebufferToOutputSurface(DrawingFrame& frame) 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_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) { - CachedTexture* contentTexture = m_renderPassTextures.get(quad->renderPassId()); + CachedResource* contentTexture = m_renderPassTextures.get(quad->renderPassId()); if (!contentTexture || !contentTexture->id()) return; diff --git a/cc/software_renderer.h b/cc/software_renderer.h index ce38abf..02ed749 100644 --- a/cc/software_renderer.h +++ b/cc/software_renderer.h @@ -44,7 +44,7 @@ public: protected: 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; diff --git a/cc/texture_uploader.cc b/cc/texture_uploader.cc index 078c08e..ed02f36 100644 --- a/cc/texture_uploader.cc +++ b/cc/texture_uploader.cc @@ -12,8 +12,8 @@ #include "base/debug/alias.h" #include "base/debug/trace_event.h" #include "base/metrics/histogram.h" -#include "cc/texture.h" #include "cc/prioritized_resource.h" +#include "cc/resource.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.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()); 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()) { pixel_source = &image[bytes_per_pixel * offset.y() * image_rect.width()]; @@ -314,7 +314,7 @@ void TextureUploader::uploadWithMapTexSubImage(const uint8* image, 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()) { memcpy(pixel_dest, |