1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
/*
Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#pragma once
#include "FilterOperations.h"
#include "FloatRect.h"
#include "NicosiaAnimation.h"
#include "TextureMapper.h"
#include "TextureMapperSolidColorLayer.h"
#include <wtf/WeakPtr.h>
#if USE(COORDINATED_GRAPHICS)
#include "NicosiaAnimatedBackingStoreClient.h"
#endif
namespace WebCore {
class Region;
class TextureMapperPaintOptions;
class TextureMapperPlatformLayer;
class WEBCORE_EXPORT TextureMapperLayer : public CanMakeWeakPtr<TextureMapperLayer> {
WTF_MAKE_NONCOPYABLE(TextureMapperLayer);
WTF_MAKE_FAST_ALLOCATED;
public:
TextureMapperLayer();
virtual ~TextureMapperLayer();
#if USE(COORDINATED_GRAPHICS)
void setID(uint32_t id) { m_id = id; }
uint32_t id() { return m_id; }
#endif
const Vector<TextureMapperLayer*>& children() const { return m_children; }
void setChildren(const Vector<TextureMapperLayer*>&);
void setMaskLayer(TextureMapperLayer*);
void setReplicaLayer(TextureMapperLayer*);
void setBackdropLayer(TextureMapperLayer*);
void setBackdropFiltersRect(const FloatRoundedRect&);
void setPosition(const FloatPoint&);
void setBoundsOrigin(const FloatPoint&);
void setSize(const FloatSize&);
void setAnchorPoint(const FloatPoint3D&);
void setPreserves3D(bool);
void setTransform(const TransformationMatrix&);
void setChildrenTransform(const TransformationMatrix&);
void setContentsRect(const FloatRect&);
void setMasksToBounds(bool);
void setDrawsContent(bool);
bool drawsContent() const { return m_state.drawsContent; }
bool contentsAreVisible() const { return m_state.contentsVisible; }
FloatSize size() const { return m_state.size; }
float opacity() const { return m_state.opacity; }
TransformationMatrix transform() const { return m_state.transform; }
void setContentsVisible(bool);
void setContentsOpaque(bool);
void setBackfaceVisibility(bool);
void setOpacity(float);
void setSolidColor(const Color&);
void setBackgroundColor(const Color&);
void setContentsTileSize(const FloatSize&);
void setContentsTilePhase(const FloatSize&);
void setContentsClippingRect(const FloatRoundedRect&);
void setContentsRectClipsDescendants(bool);
void setFilters(const FilterOperations&);
bool hasFilters() const
{
return !m_currentFilters.isEmpty();
}
void setDebugVisuals(bool showDebugBorders, const Color& debugBorderColor, float debugBorderWidth);
void setRepaintCounter(bool showRepaintCounter, int repaintCount);
void setContentsLayer(TextureMapperPlatformLayer*);
void setAnimations(const Nicosia::Animations&);
void setBackingStore(TextureMapperBackingStore*);
#if USE(COORDINATED_GRAPHICS)
void setAnimatedBackingStoreClient(Nicosia::AnimatedBackingStoreClient*);
#endif
bool applyAnimationsRecursively(MonotonicTime);
bool syncAnimations(MonotonicTime);
bool descendantsOrSelfHaveRunningAnimations() const;
void paint(TextureMapper&);
void addChild(TextureMapperLayer*);
private:
TextureMapperLayer& rootLayer() const
{
if (m_effectTarget)
return m_effectTarget->rootLayer();
if (m_parent)
return m_parent->rootLayer();
return const_cast<TextureMapperLayer&>(*this);
}
struct ComputeTransformData;
void computeTransformsRecursive(ComputeTransformData&);
static void sortByZOrder(Vector<TextureMapperLayer* >& array);
TransformationMatrix replicaTransform();
void removeFromParent();
void removeAllChildren();
enum class ComputeOverlapRegionMode : uint8_t {
Intersection,
Union,
Mask
};
struct ComputeOverlapRegionData {
ComputeOverlapRegionMode mode;
IntRect clipBounds;
Region& overlapRegion;
Region& nonOverlapRegion;
};
void computeOverlapRegions(ComputeOverlapRegionData&, const TransformationMatrix&, bool includesReplica = true);
void paintRecursive(TextureMapperPaintOptions&);
void paintWith3DRenderingContext(TextureMapperPaintOptions&);
void paintSelfChildrenReplicaFilterAndMask(TextureMapperPaintOptions&);
void paintUsingOverlapRegions(TextureMapperPaintOptions&);
void paintIntoSurface(TextureMapperPaintOptions&);
void paintWithIntermediateSurface(TextureMapperPaintOptions&, const IntRect&);
void paintSelfAndChildrenWithIntermediateSurface(TextureMapperPaintOptions&, const IntRect&);
void paintSelfChildrenFilterAndMask(TextureMapperPaintOptions&);
void paintSelf(TextureMapperPaintOptions&);
void paintSelfAndChildren(TextureMapperPaintOptions&);
void paintSelfAndChildrenWithReplica(TextureMapperPaintOptions&);
void applyMask(TextureMapperPaintOptions&);
bool isVisible() const;
bool shouldBlend() const;
inline FloatRect layerRect() const
{
return FloatRect(FloatPoint::zero(), m_state.size);
}
Vector<TextureMapperLayer*> m_children;
TextureMapperLayer* m_parent { nullptr };
WeakPtr<TextureMapperLayer> m_effectTarget;
TextureMapperBackingStore* m_backingStore { nullptr };
TextureMapperPlatformLayer* m_contentsLayer { nullptr };
float m_currentOpacity { 1.0 };
FilterOperations m_currentFilters;
float m_centerZ { 0 };
struct State {
FloatPoint pos;
FloatPoint3D anchorPoint;
FloatPoint boundsOrigin;
FloatSize size;
TransformationMatrix transform;
TransformationMatrix childrenTransform;
float opacity;
FloatRect contentsRect;
FloatSize contentsTileSize;
FloatSize contentsTilePhase;
FloatRoundedRect contentsClippingRect;
WeakPtr<TextureMapperLayer> maskLayer;
WeakPtr<TextureMapperLayer> replicaLayer;
WeakPtr<TextureMapperLayer> backdropLayer;
FloatRoundedRect backdropFiltersRect;
Color solidColor;
Color backgroundColor;
FilterOperations filters;
Color debugBorderColor;
float debugBorderWidth;
int repaintCount;
bool preserves3D : 1;
bool masksToBounds : 1;
bool drawsContent : 1;
bool contentsVisible : 1;
bool contentsOpaque : 1;
bool contentsRectClipsDescendants : 1;
bool backfaceVisibility : 1;
bool visible : 1;
bool showDebugBorders : 1;
bool showRepaintCounter : 1;
State()
: anchorPoint(0.5, 0.5, 0)
, opacity(1)
, debugBorderWidth(0)
, repaintCount(0)
, preserves3D(false)
, masksToBounds(false)
, drawsContent(false)
, contentsVisible(true)
, contentsOpaque(false)
, contentsRectClipsDescendants(false)
, backfaceVisibility(true)
, visible(true)
, showDebugBorders(false)
, showRepaintCounter(false)
{
}
};
State m_state;
Nicosia::Animations m_animations;
#if USE(COORDINATED_GRAPHICS)
uint32_t m_id { 0 };
RefPtr<Nicosia::AnimatedBackingStoreClient> m_animatedBackingStoreClient;
#endif
bool m_isBackdrop { false };
bool m_isReplica { false };
struct {
TransformationMatrix localTransform;
TransformationMatrix combined;
TransformationMatrix combinedForChildren;
#if USE(COORDINATED_GRAPHICS)
TransformationMatrix futureLocalTransform;
TransformationMatrix futureCombined;
TransformationMatrix futureCombinedForChildren;
#endif
} m_layerTransforms;
};
} // namespace WebCore
|