From f7685bc23afff59c963f9967b162b75b0c3f2580 Mon Sep 17 00:00:00 2001 From: "reveman@google.com" Date: Thu, 8 Nov 2012 17:32:33 +0000 Subject: 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 --- cc/cc.gyp | 8 +-- cc/cc_tests.gyp | 2 +- cc/direct_renderer.cc | 12 ++--- cc/direct_renderer.h | 22 ++++---- cc/gl_renderer.cc | 34 ++++++------ cc/gl_renderer.h | 10 ++-- cc/heads_up_display_layer_impl.cc | 2 +- cc/heads_up_display_layer_impl.h | 4 +- cc/layer_tree_host.cc | 4 +- cc/prioritized_resource.cc | 6 +-- cc/prioritized_resource.h | 6 +-- cc/prioritized_resource_manager.h | 2 +- cc/prioritized_resource_unittest.cc | 4 +- cc/renderer.h | 2 +- cc/resource.cc | 49 +++++++++++++++++ cc/resource.h | 43 +++++++++++++++ cc/scoped_resource.cc | 53 +++++++++++++++++++ cc/scoped_resource.h | 49 +++++++++++++++++ cc/scoped_resource_unittest.cc | 103 ++++++++++++++++++++++++++++++++++++ cc/scoped_texture.cc | 53 ------------------- cc/scoped_texture.h | 49 ----------------- cc/scoped_texture_unittest.cc | 103 ------------------------------------ cc/software_renderer.cc | 4 +- cc/software_renderer.h | 2 +- cc/texture.cc | 49 ----------------- cc/texture.h | 43 --------------- cc/texture_uploader.cc | 6 +-- 27 files changed, 362 insertions(+), 362 deletions(-) create mode 100644 cc/resource.cc create mode 100644 cc/resource.h create mode 100644 cc/scoped_resource.cc create mode 100644 cc/scoped_resource.h create mode 100644 cc/scoped_resource_unittest.cc delete mode 100644 cc/scoped_texture.cc delete mode 100644 cc/scoped_texture.h delete mode 100644 cc/scoped_texture_unittest.cc delete mode 100644 cc/texture.cc delete mode 100644 cc/texture.h diff --git a/cc/cc.gyp b/cc/cc.gyp index b4c0892..900fad3 100644 --- a/cc/cc.gyp +++ b/cc/cc.gyp @@ -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(renderPassesInDrawOrder[i]->id(), renderPassesInDrawOrder[i])); std::vector passesToDelete; - ScopedPtrHashMap::const_iterator passIterator; + ScopedPtrHashMap::const_iterator passIterator; for (passIterator = m_renderPassTextures.begin(); passIterator != m_renderPassTextures.end(); ++passIterator) { base::hash_map::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 texture = CachedTexture::create(m_resourceProvider); + scoped_ptr 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 create(ResourceProvider* resourceProvider) { - return make_scoped_ptr(new CachedTexture(resourceProvider)); + static scoped_ptr 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 m_renderPassTextures; + ScopedPtrHashMap 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 GLRenderer::drawBackgroundFilters( +scoped_ptr GLRenderer::drawBackgroundFilters( DrawingFrame& frame, const RenderPassDrawQuad* quad, const WebKit::WebFilterOperations& filters, const WebTransformationMatrix& contentsDeviceTransform, @@ -451,12 +451,12 @@ scoped_ptr GLRenderer::drawBackgroundFilters( // FIXME: When this algorithm changes, update LayerTreeHost::prioritizeTextures() accordingly. if (filters.isEmpty()) - return scoped_ptr(); + return scoped_ptr(); // 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(); + return scoped_ptr(); 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 GLRenderer::drawBackgroundFilters( deviceRect.Intersect(frame.currentRenderPass->outputRect()); - scoped_ptr deviceBackgroundTexture = ScopedTexture::create(m_resourceProvider); + scoped_ptr deviceBackgroundTexture = ScopedResource::create(m_resourceProvider); if (!getFramebufferTexture(deviceBackgroundTexture.get(), deviceRect)) - return scoped_ptr(); + return scoped_ptr(); SkBitmap filteredDeviceBackground = applyFilters(this, filters, deviceBackgroundTexture.get(), m_client->hasImplThread()); if (!filteredDeviceBackground.getTexture()) - return scoped_ptr(); + return scoped_ptr(); GrTexture* texture = reinterpret_cast(filteredDeviceBackground.getTexture()); int filteredDeviceBackgroundTextureId = texture->getTextureHandle(); - scoped_ptr backgroundTexture = ScopedTexture::create(m_resourceProvider); + scoped_ptr backgroundTexture = ScopedResource::create(m_resourceProvider); if (!backgroundTexture->allocate(Renderer::ImplPool, quad->quadRect().size(), GL_RGBA, ResourceProvider::TextureUsageFramebuffer)) - return scoped_ptr(); + return scoped_ptr(); const RenderPass* targetRenderPass = frame.currentRenderPass; bool usingBackgroundTexture = useScopedTexture(frame, backgroundTexture.get(), quad->quadRect()); @@ -498,13 +498,13 @@ scoped_ptr GLRenderer::drawBackgroundFilters( useRenderPass(frame, targetRenderPass); if (!usingBackgroundTexture) - return scoped_ptr(); + return scoped_ptr(); 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 backgroundTexture = drawBackgroundFilters( + scoped_ptr 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 drawBackgroundFilters( + scoped_ptr 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 m_fontAtlas; - scoped_ptr m_hudTexture; + scoped_ptr m_hudTexture; scoped_ptr 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 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/resource.cc b/cc/resource.cc new file mode 100644 index 0000000..0995793 --- /dev/null +++ b/cc/resource.cc @@ -0,0 +1,49 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/resource.h" +#include "third_party/khronos/GLES2/gl2ext.h" + +namespace cc { + +void Resource::setDimensions(const gfx::Size& size, GLenum format) +{ + m_size = size; + m_format = format; +} + +size_t Resource::bytes() const +{ + if (m_size.IsEmpty()) + return 0u; + + return memorySizeBytes(m_size, m_format); +} + +size_t Resource::bytesPerPixel(GLenum format) +{ + unsigned int componentsPerPixel = 0; + unsigned int bytesPerComponent = 1; + switch (format) { + case GL_RGBA: + case GL_BGRA_EXT: + componentsPerPixel = 4; + break; + case GL_LUMINANCE: + componentsPerPixel = 1; + break; + default: + NOTREACHED(); + } + return componentsPerPixel * bytesPerComponent; +} + +size_t Resource::memorySizeBytes(const gfx::Size& size, GLenum format) +{ + return bytesPerPixel(format) * size.width() * size.height(); +} + +} // namespace cc diff --git a/cc/resource.h b/cc/resource.h new file mode 100644 index 0000000..773b7a3 --- /dev/null +++ b/cc/resource.h @@ -0,0 +1,43 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_RESOURCE_H_ +#define CC_RESOURCE_H_ + +#include "cc/cc_export.h" +#include "cc/resource_provider.h" +#include "third_party/khronos/GLES2/gl2.h" +#include "ui/gfx/size.h" + +namespace cc { + +class CC_EXPORT Resource { +public: + Resource() : m_id(0) { } + Resource(unsigned id, gfx::Size size, GLenum format) + : m_id(id) + , m_size(size) + , m_format(format) { } + + ResourceProvider::ResourceId id() const { return m_id; } + const gfx::Size& size() const { return m_size; } + GLenum format() const { return m_format; } + + void setId(ResourceProvider::ResourceId id) { m_id = id; } + void setDimensions(const gfx::Size&, GLenum format); + + size_t bytes() const; + + static size_t bytesPerPixel(GLenum format); + static size_t memorySizeBytes(const gfx::Size&, GLenum format); + +private: + ResourceProvider::ResourceId m_id; + gfx::Size m_size; + GLenum m_format; +}; + +} + +#endif // CC_RESOURCE_H_ diff --git a/cc/scoped_resource.cc b/cc/scoped_resource.cc new file mode 100644 index 0000000..5729718 --- /dev/null +++ b/cc/scoped_resource.cc @@ -0,0 +1,53 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/scoped_resource.h" + +namespace cc { + +ScopedResource::ScopedResource(ResourceProvider* resourceProvider) + : m_resourceProvider(resourceProvider) +{ + DCHECK(m_resourceProvider); +} + +ScopedResource::~ScopedResource() +{ + free(); +} + +bool ScopedResource::allocate(int pool, const gfx::Size& size, GLenum format, ResourceProvider::TextureUsageHint hint) +{ + DCHECK(!id()); + DCHECK(!size.IsEmpty()); + + setDimensions(size, format); + setId(m_resourceProvider->createResource(pool, size, format, hint)); + +#ifndef NDEBUG + m_allocateThreadIdentifier = base::PlatformThread::CurrentId(); +#endif + + return id(); +} + +void ScopedResource::free() +{ + if (id()) { +#ifndef NDEBUG + DCHECK(m_allocateThreadIdentifier == base::PlatformThread::CurrentId()); +#endif + m_resourceProvider->deleteResource(id()); + } + setId(0); +} + +void ScopedResource::leak() +{ + setId(0); +} + +} // namespace cc diff --git a/cc/scoped_resource.h b/cc/scoped_resource.h new file mode 100644 index 0000000..1ad5cc7 --- /dev/null +++ b/cc/scoped_resource.h @@ -0,0 +1,49 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#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/resource.h" + +#ifndef NDEBUG +#include "base/threading/platform_thread.h" +#endif + +namespace cc { + +class CC_EXPORT ScopedResource : protected Resource { +public: + static scoped_ptr create(ResourceProvider* resourceProvider) { return make_scoped_ptr(new ScopedResource(resourceProvider)); } + virtual ~ScopedResource(); + + 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 ScopedResource(ResourceProvider*); + +private: + ResourceProvider* m_resourceProvider; + +#ifndef NDEBUG + base::PlatformThreadId m_allocateThreadIdentifier; +#endif + + DISALLOW_COPY_AND_ASSIGN(ScopedResource); +}; + +} + +#endif // CC_SCOPED_RESOURCE_H_ diff --git a/cc/scoped_resource_unittest.cc b/cc/scoped_resource_unittest.cc new file mode 100644 index 0000000..612e5a7 --- /dev/null +++ b/cc/scoped_resource_unittest.cc @@ -0,0 +1,103 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "config.h" + +#include "cc/scoped_resource.h" + +#include "cc/renderer.h" +#include "cc/test/fake_graphics_context.h" +#include "cc/test/tiled_layer_test_common.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/khronos/GLES2/gl2.h" + +using namespace cc; +using namespace WebKit; +using namespace WebKitTests; + +namespace { + +TEST(ScopedResourceTest, NewScopedResource) +{ + scoped_ptr context(createFakeGraphicsContext()); + scoped_ptr resourceProvider(ResourceProvider::create(context.get())); + scoped_ptr texture = ScopedResource::create(resourceProvider.get()); + + // New scoped textures do not hold a texture yet. + EXPECT_EQ(0u, texture->id()); + + // New scoped textures do not have a size yet. + EXPECT_EQ(gfx::Size(), texture->size()); + EXPECT_EQ(0u, texture->bytes()); +} + +TEST(ScopedResourceTest, CreateScopedResource) +{ + scoped_ptr context(createFakeGraphicsContext()); + scoped_ptr resourceProvider(ResourceProvider::create(context.get())); + scoped_ptr 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. + size_t expectedBytes = 30 * 30 * 4; + EXPECT_EQ(expectedBytes, texture->bytes()); + + EXPECT_LT(0u, texture->id()); + EXPECT_EQ(GL_RGBA, texture->format()); + EXPECT_EQ(gfx::Size(30, 30), texture->size()); +} + +TEST(ScopedResourceTest, ScopedResourceIsDeleted) +{ + scoped_ptr context(createFakeGraphicsContext()); + scoped_ptr resourceProvider(ResourceProvider::create(context.get())); + + { + scoped_ptr 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()); + EXPECT_EQ(1u, resourceProvider->numResources()); + } + + EXPECT_EQ(0u, resourceProvider->numResources()); + + { + scoped_ptr 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()); + EXPECT_EQ(1u, resourceProvider->numResources()); + texture->free(); + EXPECT_EQ(0u, resourceProvider->numResources()); + } +} + +TEST(ScopedResourceTest, LeakScopedResource) +{ + scoped_ptr context(createFakeGraphicsContext()); + scoped_ptr resourceProvider(ResourceProvider::create(context.get())); + + { + scoped_ptr 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()); + EXPECT_EQ(1u, resourceProvider->numResources()); + + texture->leak(); + EXPECT_EQ(0u, texture->id()); + EXPECT_EQ(1u, resourceProvider->numResources()); + + texture->free(); + EXPECT_EQ(0u, texture->id()); + EXPECT_EQ(1u, resourceProvider->numResources()); + } + + EXPECT_EQ(1u, resourceProvider->numResources()); +} + +} // anonymous namespace diff --git a/cc/scoped_texture.cc b/cc/scoped_texture.cc deleted file mode 100644 index 38fb797..0000000 --- a/cc/scoped_texture.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "cc/scoped_texture.h" - -namespace cc { - -ScopedTexture::ScopedTexture(ResourceProvider* resourceProvider) - : m_resourceProvider(resourceProvider) -{ - DCHECK(m_resourceProvider); -} - -ScopedTexture::~ScopedTexture() -{ - free(); -} - -bool ScopedTexture::allocate(int pool, const gfx::Size& size, GLenum format, ResourceProvider::TextureUsageHint hint) -{ - DCHECK(!id()); - DCHECK(!size.IsEmpty()); - - setDimensions(size, format); - setId(m_resourceProvider->createResource(pool, size, format, hint)); - -#ifndef NDEBUG - m_allocateThreadIdentifier = base::PlatformThread::CurrentId(); -#endif - - return id(); -} - -void ScopedTexture::free() -{ - if (id()) { -#ifndef NDEBUG - DCHECK(m_allocateThreadIdentifier == base::PlatformThread::CurrentId()); -#endif - m_resourceProvider->deleteResource(id()); - } - setId(0); -} - -void ScopedTexture::leak() -{ - setId(0); -} - -} // namespace cc diff --git a/cc/scoped_texture.h b/cc/scoped_texture.h deleted file mode 100644 index 4fe1394..0000000 --- a/cc/scoped_texture.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// 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_ - -#include "base/basictypes.h" -#include "base/logging.h" -#include "base/memory/scoped_ptr.h" -#include "cc/cc_export.h" -#include "cc/texture.h" - -#ifndef NDEBUG -#include "base/threading/platform_thread.h" -#endif - -namespace cc { - -class CC_EXPORT ScopedTexture : protected Texture { -public: - static scoped_ptr create(ResourceProvider* resourceProvider) { return make_scoped_ptr(new ScopedTexture(resourceProvider)); } - virtual ~ScopedTexture(); - - using Texture::id; - using Texture::size; - using Texture::format; - using Texture::bytes; - - bool allocate(int pool, const gfx::Size&, GLenum format, ResourceProvider::TextureUsageHint); - void free(); - void leak(); - -protected: - explicit ScopedTexture(ResourceProvider*); - -private: - ResourceProvider* m_resourceProvider; - -#ifndef NDEBUG - base::PlatformThreadId m_allocateThreadIdentifier; -#endif - - DISALLOW_COPY_AND_ASSIGN(ScopedTexture); -}; - -} - -#endif // CC_SCOPED_TEXTURE_H_ diff --git a/cc/scoped_texture_unittest.cc b/cc/scoped_texture_unittest.cc deleted file mode 100644 index 232ec83..0000000 --- a/cc/scoped_texture_unittest.cc +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "cc/scoped_texture.h" - -#include "cc/renderer.h" -#include "cc/test/fake_graphics_context.h" -#include "cc/test/tiled_layer_test_common.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/khronos/GLES2/gl2.h" - -using namespace cc; -using namespace WebKit; -using namespace WebKitTests; - -namespace { - -TEST(ScopedTextureTest, NewScopedTexture) -{ - scoped_ptr context(createFakeGraphicsContext()); - scoped_ptr resourceProvider(ResourceProvider::create(context.get())); - scoped_ptr texture = ScopedTexture::create(resourceProvider.get()); - - // New scoped textures do not hold a texture yet. - EXPECT_EQ(0u, texture->id()); - - // New scoped textures do not have a size yet. - EXPECT_EQ(gfx::Size(), texture->size()); - EXPECT_EQ(0u, texture->bytes()); -} - -TEST(ScopedTextureTest, CreateScopedTexture) -{ - scoped_ptr context(createFakeGraphicsContext()); - scoped_ptr resourceProvider(ResourceProvider::create(context.get())); - scoped_ptr texture = ScopedTexture::create(resourceProvider.get()); - texture->allocate(Renderer::ImplPool, gfx::Size(30, 30), GL_RGBA, ResourceProvider::TextureUsageAny); - - // The texture has an allocated byte-size now. - size_t expectedBytes = 30 * 30 * 4; - EXPECT_EQ(expectedBytes, texture->bytes()); - - EXPECT_LT(0u, texture->id()); - EXPECT_EQ(GL_RGBA, texture->format()); - EXPECT_EQ(gfx::Size(30, 30), texture->size()); -} - -TEST(ScopedTextureTest, ScopedTextureIsDeleted) -{ - scoped_ptr context(createFakeGraphicsContext()); - scoped_ptr resourceProvider(ResourceProvider::create(context.get())); - - { - scoped_ptr texture = ScopedTexture::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()); - EXPECT_EQ(1u, resourceProvider->numResources()); - } - - EXPECT_EQ(0u, resourceProvider->numResources()); - - { - scoped_ptr texture = ScopedTexture::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()); - EXPECT_EQ(1u, resourceProvider->numResources()); - texture->free(); - EXPECT_EQ(0u, resourceProvider->numResources()); - } -} - -TEST(ScopedTextureTest, LeakScopedTexture) -{ - scoped_ptr context(createFakeGraphicsContext()); - scoped_ptr resourceProvider(ResourceProvider::create(context.get())); - - { - scoped_ptr texture = ScopedTexture::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()); - EXPECT_EQ(1u, resourceProvider->numResources()); - - texture->leak(); - EXPECT_EQ(0u, texture->id()); - EXPECT_EQ(1u, resourceProvider->numResources()); - - texture->free(); - EXPECT_EQ(0u, texture->id()); - EXPECT_EQ(1u, resourceProvider->numResources()); - } - - EXPECT_EQ(1u, resourceProvider->numResources()); -} - -} // anonymous namespace 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.cc b/cc/texture.cc deleted file mode 100644 index af74f31..0000000 --- a/cc/texture.cc +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "config.h" - -#include "cc/texture.h" -#include "third_party/khronos/GLES2/gl2ext.h" - -namespace cc { - -void Texture::setDimensions(const gfx::Size& size, GLenum format) -{ - m_size = size; - m_format = format; -} - -size_t Texture::bytes() const -{ - if (m_size.IsEmpty()) - return 0u; - - return memorySizeBytes(m_size, m_format); -} - -size_t Texture::bytesPerPixel(GLenum format) -{ - unsigned int componentsPerPixel = 0; - unsigned int bytesPerComponent = 1; - switch (format) { - case GL_RGBA: - case GL_BGRA_EXT: - componentsPerPixel = 4; - break; - case GL_LUMINANCE: - componentsPerPixel = 1; - break; - default: - NOTREACHED(); - } - return componentsPerPixel * bytesPerComponent; -} - -size_t Texture::memorySizeBytes(const gfx::Size& size, GLenum format) -{ - return bytesPerPixel(format) * size.width() * size.height(); -} - -} // namespace cc diff --git a/cc/texture.h b/cc/texture.h deleted file mode 100644 index cd9df1d..0000000 --- a/cc/texture.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2012 The Chromium Authors. All rights reserved. -// 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_ - -#include "cc/cc_export.h" -#include "cc/resource_provider.h" -#include "third_party/khronos/GLES2/gl2.h" -#include "ui/gfx/size.h" - -namespace cc { - -class CC_EXPORT Texture { -public: - Texture() : m_id(0) { } - Texture(unsigned id, gfx::Size size, GLenum format) - : m_id(id) - , m_size(size) - , m_format(format) { } - - ResourceProvider::ResourceId id() const { return m_id; } - const gfx::Size& size() const { return m_size; } - GLenum format() const { return m_format; } - - void setId(ResourceProvider::ResourceId id) { m_id = id; } - void setDimensions(const gfx::Size&, GLenum format); - - size_t bytes() const; - - static size_t bytesPerPixel(GLenum format); - static size_t memorySizeBytes(const gfx::Size&, GLenum format); - -private: - ResourceProvider::ResourceId m_id; - gfx::Size m_size; - GLenum m_format; -}; - -} - -#endif // CC_TEXTURE_H_ 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, -- cgit v1.1