Modified: trunk/Source/WebCore/ChangeLog (269935 => 269936)
--- trunk/Source/WebCore/ChangeLog 2020-11-18 00:42:10 UTC (rev 269935)
+++ trunk/Source/WebCore/ChangeLog 2020-11-18 00:49:46 UTC (rev 269936)
@@ -1,3 +1,28 @@
+2020-11-17 Fujii Hironori <[email protected]>
+
+ Use SetForScope to temporarily change members of TextureMapperPaintOptions instead of copying all members
+ https://bugs.webkit.org/show_bug.cgi?id=219022
+
+ Reviewed by Carlos Garcia Campos.
+
+ All members of TextureMapperPaintOptions don't need to be copied
+ just to change some members. Use WTF::SetForScope to temporarily
+ change members of TextureMapperPaintOptions.
+
+ No behavior changes.
+
+ * platform/graphics/texmap/TextureMapperLayer.cpp:
+ (WebCore::TextureMapperLayer::paintSelf):
+ (WebCore::TextureMapperLayer::paintSelfAndChildren):
+ (WebCore::TextureMapperLayer::paintSelfAndChildrenWithReplica):
+ (WebCore::TextureMapperLayer::paintUsingOverlapRegions):
+ (WebCore::TextureMapperLayer::applyMask):
+ (WebCore::TextureMapperLayer::paintIntoSurface):
+ (WebCore::commitSurface):
+ (WebCore::TextureMapperLayer::paintWithIntermediateSurface):
+ (WebCore::TextureMapperLayer::paintRecursive):
+ * platform/graphics/texmap/TextureMapperLayer.h:
+
2020-11-17 Megan Gardner <[email protected]>
Fix for localizableStrings.string in WebCore
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (269935 => 269936)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp 2020-11-18 00:42:10 UTC (rev 269935)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp 2020-11-18 00:49:46 UTC (rev 269936)
@@ -24,6 +24,7 @@
#include "GraphicsLayerTextureMapper.h"
#include "Region.h"
#include <wtf/MathExtras.h>
+#include <wtf/SetForScope.h>
namespace WebCore {
@@ -151,7 +152,7 @@
return color.colorWithAlphaMultipliedBy(opacity);
}
-void TextureMapperLayer::paintSelf(const TextureMapperPaintOptions& options)
+void TextureMapperLayer::paintSelf(TextureMapperPaintOptions& options)
{
if (!m_state.visible || !m_state.contentsVisible)
return;
@@ -218,7 +219,7 @@
});
}
-void TextureMapperLayer::paintSelfAndChildren(const TextureMapperPaintOptions& options)
+void TextureMapperLayer::paintSelfAndChildren(TextureMapperPaintOptions& options)
{
if (m_state.backdropLayer && m_state.backdropLayer == options.backdropLayer)
return;
@@ -294,12 +295,12 @@
return true;
}
-void TextureMapperLayer::paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions& options)
+void TextureMapperLayer::paintSelfAndChildrenWithReplica(TextureMapperPaintOptions& options)
{
if (m_state.replicaLayer) {
- TextureMapperPaintOptions replicaOptions(options);
- replicaOptions.transform.multiply(replicaTransform());
- paintSelfAndChildren(replicaOptions);
+ SetForScope<TransformationMatrix> scopedTransform(options.transform, options.transform);
+ options.transform.multiply(replicaTransform());
+ paintSelfAndChildren(options);
}
paintSelfAndChildren(options);
@@ -367,7 +368,7 @@
}
}
-void TextureMapperLayer::paintUsingOverlapRegions(const TextureMapperPaintOptions& options)
+void TextureMapperLayer::paintUsingOverlapRegions(TextureMapperPaintOptions& options)
{
Region overlapRegion;
Region nonOverlapRegion;
@@ -421,7 +422,7 @@
}
}
-void TextureMapperLayer::applyMask(const TextureMapperPaintOptions& options)
+void TextureMapperLayer::applyMask(TextureMapperPaintOptions& options)
{
options.textureMapper.setMaskMode(true);
paintSelf(options);
@@ -432,10 +433,9 @@
{
options.textureMapper.bindSurface(options.surface.get());
if (m_isBackdrop) {
- TextureMapperPaintOptions paintOptions(options);
- paintOptions.transform = TransformationMatrix();
- paintOptions.backdropLayer = this;
- rootLayer().paintSelfAndChildren(paintOptions);
+ SetForScope<TransformationMatrix> scopedTransform(options.transform, TransformationMatrix());
+ SetForScope<TextureMapperLayer*> scopedBackdropLayer(options.backdropLayer, this);
+ rootLayer().paintSelfAndChildren(options);
} else
paintSelfAndChildren(options);
if (m_state.maskLayer)
@@ -444,7 +444,7 @@
options.textureMapper.bindSurface(options.surface.get());
}
-static void commitSurface(const TextureMapperPaintOptions& options, BitmapTexture& surface, const IntRect& rect, float opacity)
+static void commitSurface(TextureMapperPaintOptions& options, BitmapTexture& surface, const IntRect& rect, float opacity)
{
IntRect targetRect(rect);
targetRect.move(options.offset);
@@ -452,39 +452,43 @@
options.textureMapper.drawTexture(surface, targetRect, { }, opacity);
}
-void TextureMapperLayer::paintWithIntermediateSurface(const TextureMapperPaintOptions& options, const IntRect& rect)
+void TextureMapperLayer::paintWithIntermediateSurface(TextureMapperPaintOptions& options, const IntRect& rect)
{
- TextureMapperPaintOptions paintOptions(options);
- paintOptions.surface = options.textureMapper.acquireTextureFromPool(rect.size(), BitmapTexture::SupportsAlpha);
- paintOptions.offset = -toIntSize(rect.location());
- paintOptions.opacity = 1;
- if (m_state.replicaLayer) {
- paintOptions.transform.multiply(replicaTransform());
- paintIntoSurface(paintOptions);
- paintOptions.transform = options.transform;
- if (m_state.replicaLayer->m_state.maskLayer)
- m_state.replicaLayer->m_state.maskLayer->applyMask(paintOptions);
+ auto surface = options.textureMapper.acquireTextureFromPool(rect.size(), BitmapTexture::SupportsAlpha);
+ {
+ SetForScope<RefPtr<BitmapTexture>> scopedSurface(options.surface, surface);
+ SetForScope<IntSize> scopedOffset(options.offset, -toIntSize(rect.location()));
+ SetForScope<float> scopedOpacity(options.opacity, 1);
+ if (m_state.replicaLayer) {
+ {
+ SetForScope<TransformationMatrix> scopedTransform(options.transform, options.transform);
+ options.transform.multiply(replicaTransform());
+ paintIntoSurface(options);
+ }
+ if (m_state.replicaLayer->m_state.maskLayer)
+ m_state.replicaLayer->m_state.maskLayer->applyMask(options);
+ }
+
+ paintIntoSurface(options);
+ surface = options.surface;
}
- paintIntoSurface(paintOptions);
-
- commitSurface(options, *paintOptions.surface, rect, options.opacity);
+ commitSurface(options, *surface, rect, options.opacity);
}
-void TextureMapperLayer::paintRecursive(const TextureMapperPaintOptions& options)
+void TextureMapperLayer::paintRecursive(TextureMapperPaintOptions& options)
{
if (!isVisible())
return;
- TextureMapperPaintOptions paintOptions(options);
- paintOptions.opacity *= m_currentOpacity;
+ SetForScope<float> scopedOpacity(options.opacity, options.opacity * m_currentOpacity);
if (!shouldBlend()) {
- paintSelfAndChildrenWithReplica(paintOptions);
+ paintSelfAndChildrenWithReplica(options);
return;
}
- paintUsingOverlapRegions(paintOptions);
+ paintUsingOverlapRegions(options);
}
#if !USE(COORDINATED_GRAPHICS)
Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h (269935 => 269936)
--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h 2020-11-18 00:42:10 UTC (rev 269935)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h 2020-11-18 00:49:46 UTC (rev 269936)
@@ -136,14 +136,14 @@
};
void computeOverlapRegions(ComputeOverlapRegionData&, const TransformationMatrix&, bool includesReplica = true);
- void paintRecursive(const TextureMapperPaintOptions&);
- void paintUsingOverlapRegions(const TextureMapperPaintOptions&);
+ void paintRecursive(TextureMapperPaintOptions&);
+ void paintUsingOverlapRegions(TextureMapperPaintOptions&);
void paintIntoSurface(TextureMapperPaintOptions&);
- void paintWithIntermediateSurface(const TextureMapperPaintOptions&, const IntRect&);
- void paintSelf(const TextureMapperPaintOptions&);
- void paintSelfAndChildren(const TextureMapperPaintOptions&);
- void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&);
- void applyMask(const TextureMapperPaintOptions&);
+ void paintWithIntermediateSurface(TextureMapperPaintOptions&, const IntRect&);
+ void paintSelf(TextureMapperPaintOptions&);
+ void paintSelfAndChildren(TextureMapperPaintOptions&);
+ void paintSelfAndChildrenWithReplica(TextureMapperPaintOptions&);
+ void applyMask(TextureMapperPaintOptions&);
bool isVisible() const;