Skip to content

Commit

Permalink
[TextureMapper] BitmapTexurePool doesn't need to be heap allocated
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=264863

Reviewed by Fujii Hironori.

* Source/WebCore/platform/graphics/texmap/BitmapTexturePool.cpp:
* Source/WebCore/platform/graphics/texmap/BitmapTexturePool.h:
* Source/WebCore/platform/graphics/texmap/TextureMapper.cpp:
(WebCore::TextureMapper::TextureMapper):
(WebCore::TextureMapper::acquireTextureFromPool):
(WebCore::TextureMapper::releaseUnusedTexturesNow):
(WebCore::TextureMapper::drawNumber):
(WebCore::TextureMapper::applyBlurFilter):
(WebCore::TextureMapper::applyDropShadowFilter):
(WebCore::TextureMapper::applySinglePassFilter):
* Source/WebCore/platform/graphics/texmap/TextureMapper.h:

Canonical link: https://commits.webkit.org/270758@main
  • Loading branch information
carlosgcampos committed Nov 15, 2023
1 parent c72b298 commit db648b6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
1 change: 1 addition & 0 deletions Source/WebCore/platform/TextureMapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
platform/graphics/nicosia/NicosiaAnimation.h

platform/graphics/texmap/BitmapTexture.h
platform/graphics/texmap/BitmapTexturePool.h
platform/graphics/texmap/ClipStack.h
platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.h
platform/graphics/texmap/GraphicsLayerTextureMapper.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "BitmapTexturePool.h"

#if USE(TEXTURE_MAPPER)
#include "BitmapTexture.h"

namespace WebCore {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class IntSize;

class BitmapTexturePool {
WTF_MAKE_NONCOPYABLE(BitmapTexturePool);
WTF_MAKE_FAST_ALLOCATED;
public:
BitmapTexturePool();

Expand Down
18 changes: 8 additions & 10 deletions Source/WebCore/platform/graphics/texmap/TextureMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#if USE(TEXTURE_MAPPER)

#include "BitmapTexture.h"
#include "BitmapTexturePool.h"
#include "FilterOperations.h"
#include "FloatQuad.h"
#include "FloatRoundedRect.h"
Expand Down Expand Up @@ -178,14 +177,13 @@ std::unique_ptr<TextureMapper> TextureMapper::create()
}

TextureMapper::TextureMapper()
: m_texturePool(makeUnique<BitmapTexturePool>())
, m_data(new TextureMapperGLData(GLContext::current()->platformContext()))
: m_data(new TextureMapperGLData(GLContext::current()->platformContext()))
{
}

RefPtr<BitmapTexture> TextureMapper::acquireTextureFromPool(const IntSize& size, OptionSet<BitmapTexture::Flags> flags)
{
return m_texturePool->acquireTexture(size, flags);
return m_texturePool.acquireTexture(size, flags);
}

#if USE(GRAPHICS_LAYER_WC)
Expand All @@ -194,7 +192,7 @@ void TextureMapper::releaseUnusedTexturesNow()
// GraphicsLayerWC runs TextureMapper in the OpenGL thread of the
// GPU process that doesn't use RunLoop. RunLoop::Timer doesn't
// work in the thread.
m_texturePool->releaseUnusedTexturesTimerFired();
m_texturePool.releaseUnusedTexturesTimerFired();
}
#endif

Expand Down Expand Up @@ -287,7 +285,7 @@ void TextureMapper::drawNumber(int number, const Color& color, const FloatPoint&
IntRect sourceRect(IntPoint::zero(), size);
IntRect targetRect(roundedIntPoint(targetPoint), size);

RefPtr<BitmapTexture> texture = m_texturePool->acquireTexture(size, { BitmapTexture::Flags::SupportsAlpha });
RefPtr<BitmapTexture> texture = m_texturePool.acquireTexture(size, { BitmapTexture::Flags::SupportsAlpha });
const unsigned char* bits = cairo_image_surface_get_data(surface);
int stride = cairo_image_surface_get_stride(surface);
texture->updateContents(bits, sourceRect, IntPoint::zero(), stride);
Expand Down Expand Up @@ -909,7 +907,7 @@ RefPtr<BitmapTexture> TextureMapper::applyBlurFilter(RefPtr<BitmapTexture>& sour
if (radiusX < MinBlurRadius && radiusY < MinBlurRadius)
return sourceTexture;

RefPtr<BitmapTexture> resultTexture = m_texturePool->acquireTexture(textureSize, { BitmapTexture::Flags::SupportsAlpha });
RefPtr<BitmapTexture> resultTexture = m_texturePool.acquireTexture(textureSize, { BitmapTexture::Flags::SupportsAlpha });
IntSize currentSize = textureSize;
IntSize targetSize = currentSize;
Vector<Direction> blurDirections;
Expand Down Expand Up @@ -985,8 +983,8 @@ RefPtr<BitmapTexture> TextureMapper::applyBlurFilter(RefPtr<BitmapTexture>& sour
RefPtr<BitmapTexture> TextureMapper::applyDropShadowFilter(RefPtr<BitmapTexture>& sourceTexture, const DropShadowFilterOperation& dropShadowFilter)
{
const auto& textureSize = sourceTexture->size();
RefPtr<BitmapTexture> resultTexture = m_texturePool->acquireTexture(textureSize, { BitmapTexture::Flags::SupportsAlpha });
RefPtr<BitmapTexture> contentTexture = m_texturePool->acquireTexture(textureSize, { BitmapTexture::Flags::SupportsAlpha });
RefPtr<BitmapTexture> resultTexture = m_texturePool.acquireTexture(textureSize, { BitmapTexture::Flags::SupportsAlpha });
RefPtr<BitmapTexture> contentTexture = m_texturePool.acquireTexture(textureSize, { BitmapTexture::Flags::SupportsAlpha });
IntSize currentSize = textureSize;
IntSize targetSize = currentSize;
float radius = float(dropShadowFilter.stdDeviation());
Expand Down Expand Up @@ -1111,7 +1109,7 @@ RefPtr<BitmapTexture> TextureMapper::applySinglePassFilter(RefPtr<BitmapTexture>
return sourceTexture;
}

RefPtr<BitmapTexture> resultTexture = m_texturePool->acquireTexture(sourceTexture->size(), { BitmapTexture::Flags::SupportsAlpha });
RefPtr<BitmapTexture> resultTexture = m_texturePool.acquireTexture(sourceTexture->size(), { BitmapTexture::Flags::SupportsAlpha });

bindSurface(resultTexture.get());

Expand Down
6 changes: 2 additions & 4 deletions Source/WebCore/platform/graphics/texmap/TextureMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#if USE(TEXTURE_MAPPER)

#include "BitmapTexture.h"
#include "BitmapTexturePool.h"
#include "ClipStack.h"
#include "Color.h"
#include "FilterOperation.h"
Expand All @@ -38,7 +38,6 @@

namespace WebCore {

class BitmapTexturePool;
class GraphicsLayer;
class TextureMapperGLData;
class TextureMapperShaderProgram;
Expand Down Expand Up @@ -97,8 +96,6 @@ class TextureMapper {
#endif

private:
std::unique_ptr<BitmapTexturePool> m_texturePool;

bool isInMaskMode() const { return m_isMaskMode; }
const TransformationMatrix& patternTransform() const { return m_patternTransform; }

Expand Down Expand Up @@ -126,6 +123,7 @@ class TextureMapper {

void updateProjectionMatrix();

BitmapTexturePool m_texturePool;
bool m_isMaskMode { false };
TransformationMatrix m_patternTransform;
WrapMode m_wrapMode { WrapMode::Stretch };
Expand Down

0 comments on commit db648b6

Please sign in to comment.