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 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
|
/*
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.
*/
#ifndef TextureMapperLayer_h
#define TextureMapperLayer_h
#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
#include "FilterOperations.h"
#include "FloatRect.h"
#include "GraphicsLayerAnimation.h"
#include "GraphicsLayerTransform.h"
#include "TextureMapper.h"
#include "TextureMapperBackingStore.h"
namespace WebCore {
class Region;
class TextureMapperPaintOptions;
class TextureMapperPlatformLayer;
class TextureMapperLayer : public GraphicsLayerAnimation::Client {
WTF_MAKE_NONCOPYABLE(TextureMapperLayer);
WTF_MAKE_FAST_ALLOCATED;
public:
class ScrollingClient {
public:
virtual void commitScrollOffset(uint32_t layerID, const IntSize& offset) = 0;
};
TextureMapperLayer()
: m_parent(0)
, m_effectTarget(0)
, m_contentsLayer(0)
, m_currentOpacity(1)
, m_centerZ(0)
, m_textureMapper(0)
, m_fixedToViewport(false)
, m_id(0)
, m_scrollClient(0)
, m_isScrollable(false)
, m_patternTransformDirty(false)
{ }
virtual ~TextureMapperLayer();
void setID(uint32_t id) { m_id = id; }
uint32_t id() { return m_id; }
const Vector<TextureMapperLayer*>& children() const { return m_children; }
TextureMapperLayer* findScrollableContentsLayerAt(const FloatPoint& pos);
void setScrollClient(ScrollingClient* scrollClient) { m_scrollClient = scrollClient; }
void scrollBy(const WebCore::FloatSize&);
void didCommitScrollOffset(const IntSize&);
void setIsScrollable(bool isScrollable) { m_isScrollable = isScrollable; }
bool isScrollable() const { return m_isScrollable; }
TextureMapper* textureMapper() const;
void setTextureMapper(TextureMapper* texmap) { m_textureMapper = texmap; }
void setChildren(const Vector<TextureMapperLayer*>&);
void setMaskLayer(TextureMapperLayer*);
void setReplicaLayer(TextureMapperLayer*);
void setPosition(const FloatPoint&);
void setSize(const FloatSize&);
void setAnchorPoint(const FloatPoint3D&);
void setPreserves3D(bool);
void setTransform(const TransformationMatrix&);
void setChildrenTransform(const TransformationMatrix&);
void setContentsRect(const IntRect&);
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 setContentsTileSize(const IntSize&);
void setContentsTilePhase(const IntPoint&);
#if ENABLE(CSS_FILTERS)
void setFilters(const FilterOperations&);
#endif
bool hasFilters() const
{
#if ENABLE(CSS_FILTERS)
return !m_currentFilters.isEmpty();
#else
return false;
#endif
}
void setDebugVisuals(bool showDebugBorders, const Color& debugBorderColor, float debugBorderWidth, bool showRepaintCounter);
bool isShowingRepaintCounter() const { return m_state.showRepaintCounter; }
void setRepaintCount(int);
void setContentsLayer(TextureMapperPlatformLayer*);
void setAnimations(const GraphicsLayerAnimations&);
void setFixedToViewport(bool);
bool fixedToViewport() const { return m_fixedToViewport; }
void setBackingStore(PassRefPtr<TextureMapperBackingStore>);
void syncAnimations();
bool descendantsOrSelfHaveRunningAnimations() const;
void paint();
void setScrollPositionDeltaIfNeeded(const FloatSize&);
void applyAnimationsRecursively();
void addChild(TextureMapperLayer*);
private:
const TextureMapperLayer* rootLayer() const;
void computeTransformsRecursive();
static int compareGraphicsLayersZValue(const void* a, const void* b);
static void sortByZOrder(Vector<TextureMapperLayer* >& array);
PassRefPtr<BitmapTexture> texture() { return m_backingStore ? m_backingStore->texture() : 0; }
FloatPoint adjustedPosition() const { return m_state.pos + m_scrollPositionDelta - m_userScrollOffset; }
bool isAncestorFixedToViewport() const;
TransformationMatrix replicaTransform();
void removeFromParent();
void removeAllChildren();
enum ResolveSelfOverlapMode {
ResolveSelfOverlapAlways = 0,
ResolveSelfOverlapIfNeeded
};
void computeOverlapRegions(Region& overlapRegion, Region& nonOverlapRegion, ResolveSelfOverlapMode);
void paintRecursive(const TextureMapperPaintOptions&);
void paintUsingOverlapRegions(const TextureMapperPaintOptions&);
PassRefPtr<BitmapTexture> paintIntoSurface(const TextureMapperPaintOptions&, const IntSize&);
void paintWithIntermediateSurface(const TextureMapperPaintOptions&, const IntRect&);
void paintSelf(const TextureMapperPaintOptions&);
void paintSelfAndChildren(const TextureMapperPaintOptions&);
void paintSelfAndChildrenWithReplica(const TextureMapperPaintOptions&);
void applyMask(const TextureMapperPaintOptions&);
void computePatternTransformIfNeeded();
// GraphicsLayerAnimation::Client
virtual void setAnimatedTransform(const TransformationMatrix&) OVERRIDE;
virtual void setAnimatedOpacity(float) OVERRIDE;
#if ENABLE(CSS_FILTERS)
virtual void setAnimatedFilters(const FilterOperations&) OVERRIDE;
#endif
bool isVisible() const;
enum ContentsLayerCount {
NoLayersWithContent,
SingleLayerWithContents,
MultipleLayersWithContents
};
bool shouldBlend() const;
inline FloatRect layerRect() const
{
return FloatRect(FloatPoint::zero(), m_state.size);
}
Vector<TextureMapperLayer*> m_children;
TextureMapperLayer* m_parent;
TextureMapperLayer* m_effectTarget;
RefPtr<TextureMapperBackingStore> m_backingStore;
TextureMapperPlatformLayer* m_contentsLayer;
GraphicsLayerTransform m_currentTransform;
float m_currentOpacity;
#if ENABLE(CSS_FILTERS)
FilterOperations m_currentFilters;
#endif
float m_centerZ;
template<class HitTestCondition> TextureMapperLayer* hitTest(const FloatPoint&, HitTestCondition);
static bool scrollableLayerHitTestCondition(TextureMapperLayer*, const FloatPoint&);
FloatSize mapScrollOffset(const FloatSize&);
void commitScrollOffset(const FloatSize&);
struct State {
FloatPoint pos;
FloatPoint3D anchorPoint;
FloatSize size;
TransformationMatrix transform;
TransformationMatrix childrenTransform;
float opacity;
FloatRect contentsRect;
IntSize contentsTileSize;
IntPoint contentsTilePhase;
TextureMapperLayer* maskLayer;
TextureMapperLayer* replicaLayer;
Color solidColor;
#if ENABLE(CSS_FILTERS)
FilterOperations filters;
#endif
Color debugBorderColor;
float debugBorderWidth;
int repaintCount;
bool preserves3D : 1;
bool masksToBounds : 1;
bool drawsContent : 1;
bool contentsVisible : 1;
bool contentsOpaque : 1;
bool backfaceVisibility : 1;
bool visible : 1;
bool showDebugBorders : 1;
bool showRepaintCounter : 1;
State()
: opacity(1)
, maskLayer(0)
, replicaLayer(0)
, debugBorderWidth(0)
, repaintCount(0)
, preserves3D(false)
, masksToBounds(false)
, drawsContent(false)
, contentsVisible(true)
, contentsOpaque(false)
, backfaceVisibility(true)
, visible(true)
, showDebugBorders(false)
, showRepaintCounter(false)
{
}
};
State m_state;
TextureMapper* m_textureMapper;
GraphicsLayerAnimations m_animations;
FloatSize m_scrollPositionDelta;
bool m_fixedToViewport;
uint32_t m_id;
ScrollingClient* m_scrollClient;
bool m_isScrollable;
FloatSize m_userScrollOffset;
FloatSize m_accumulatedScrollOffsetFractionalPart;
TransformationMatrix m_patternTransform;
bool m_patternTransformDirty;
};
}
#endif
#endif // TextureMapperLayer_h
|