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
|
/*
* Copyright (C) 2010, 2011, 2012 Research In Motion Limited. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LayerData_h
#define LayerData_h
#include "Color.h"
#include "FilterOperations.h"
#include "FloatPoint.h"
#include "FloatRect.h"
#include "IntRect.h"
#include "TransformationMatrix.h"
#include <wtf/HashMap.h>
#include <wtf/text/WTFString.h>
#if USE(ACCELERATED_COMPOSITING)
namespace WebCore {
class HTMLCanvasElement;
class PluginView;
#if ENABLE(VIDEO)
class MediaPlayer;
#endif
class LayerData {
public:
enum LayerType { Layer, TransformLayer, WebGLLayer, CanvasLayer, CustomLayer };
enum FilterType { Linear, Nearest, Trilinear, Lanczos };
enum LayerProgram {
LayerProgramRGBA = 0,
LayerProgramBGRA,
NumberOfLayerPrograms
};
#if ENABLE(CSS_FILTERS)
enum CSSFilterShaders {
CSSFilterShaderGrayscale = 0,
CSSFilterShaderSepia,
CSSFilterShaderSaturate,
CSSFilterShaderHueRotate,
CSSFilterShaderInvert,
CSSFilterShaderBrightness,
CSSFilterShaderContrast,
CSSFilterShaderOpacity,
CSSFilterShaderBlurY,
CSSFilterShaderBlurX,
CSSFilterShaderShadow,
CSSFilterShaderPassthrough,
#if ENABLE(CSS_SHADERS)
CSSFilterShaderCustom,
#endif
NumberOfCSSFilterShaders
};
#endif
LayerData(LayerType type)
: m_layerType(type)
, m_anchorPoint(0.5, 0.5)
, m_backgroundColor(0, 0, 0, 0)
, m_borderColor(0, 0, 0, 0)
, m_opacity(1.0)
, m_anchorPointZ(0.0)
, m_borderWidth(0.0)
, m_layerProgram(LayerProgramBGRA)
, m_pluginView(0)
#if ENABLE(VIDEO)
, m_mediaPlayer(0)
#endif
, m_suspendTime(0)
, m_contentsScale(1.0)
, m_doubleSided(true)
, m_masksToBounds(false)
, m_isOpaque(false)
, m_preserves3D(false)
, m_needsDisplayOnBoundsChange(false)
, m_needsTexture(false)
, m_isFixedPosition(false)
, m_hasFixedContainer(false)
, m_hasFixedAncestorInDOMTree(false)
, m_isContainerForFixedPositionLayers(false)
, m_sizeIsScaleInvariant(false)
, m_contentsResolutionIndependent(false)
, m_isVisible(true)
{
}
virtual ~LayerData()
{
}
FloatPoint anchorPoint() const { return m_anchorPoint; }
float anchorPointZ() const { return m_anchorPointZ; }
Color backgroundColor() const { return m_backgroundColor; }
Color borderColor() const { return m_borderColor; }
float borderWidth() const { return m_borderWidth; }
IntSize bounds() const { return m_bounds; }
bool sizeIsScaleInvariant() const { return m_sizeIsScaleInvariant; }
bool contentsResolutionIndependent() const { return m_contentsResolutionIndependent; }
bool doubleSided() const { return m_doubleSided; }
FloatRect frame() const { return m_frame; }
bool masksToBounds() const { return m_masksToBounds; }
float opacity() const { return m_opacity; }
#if ENABLE(CSS_FILTERS)
FilterOperations filters() const { return m_filters; }
#endif
bool isOpaque() const { return m_isOpaque; }
FloatPoint position() const { return m_position; }
// This is currently only used for perspective transform, see GraphicsLayer::setChildrenTransform()
const TransformationMatrix& sublayerTransform() const { return m_sublayerTransform; }
const TransformationMatrix& transform() const { return m_transform; }
bool preserves3D() const { return m_preserves3D; }
bool needsTexture() const { return m_layerType == WebGLLayer || m_layerType == CanvasLayer || m_needsTexture; }
LayerProgram layerProgram() const { return m_layerProgram; }
bool isFixedPosition() const { return m_isFixedPosition; }
bool hasFixedContainer() const { return m_hasFixedContainer; }
bool hasFixedAncestorInDOMTree() const { return m_hasFixedAncestorInDOMTree; }
bool isContainerForFixedPositionLayers() const { return m_isContainerForFixedPositionLayers; }
bool isFixedToTop() const { return m_isFixedToTop; }
bool isFixedToLeft() const { return m_isFixedToLeft; }
IntRect frameVisibleRect() const { return m_frameVisibleRect; }
IntSize frameContentsSize() const { return m_frameContentsSize; }
PluginView* pluginView() const { return m_pluginView; }
IntRect holePunchRect() const { return m_holePunchRect; }
bool hasHolePunchRect() const { return !m_holePunchRect.isEmpty(); }
double contentsScale() const { return m_contentsScale; }
#if ENABLE(VIDEO)
MediaPlayer* mediaPlayer() const { return m_mediaPlayer; }
#endif
void replicate(LayerData *to) const { *to = *this; }
LayerType layerType() const { return m_layerType; }
bool includeVisibility() const
{
if (pluginView())
return true;
#if ENABLE(VIDEO)
if (mediaPlayer())
return true;
#endif
return false;
}
protected:
LayerType m_layerType;
IntSize m_bounds;
FloatPoint m_position;
FloatPoint m_anchorPoint;
Color m_backgroundColor;
Color m_borderColor;
FloatRect m_frame;
TransformationMatrix m_transform;
TransformationMatrix m_sublayerTransform;
float m_opacity;
#if ENABLE(CSS_FILTERS)
FilterOperations m_filters;
#endif
float m_anchorPointZ;
float m_borderWidth;
LayerProgram m_layerProgram;
PluginView* m_pluginView;
#if ENABLE(VIDEO)
MediaPlayer* m_mediaPlayer;
#endif
IntRect m_holePunchRect;
IntRect m_frameVisibleRect;
IntSize m_frameContentsSize;
double m_suspendTime;
double m_contentsScale;
unsigned m_doubleSided : 1;
unsigned m_masksToBounds : 1;
unsigned m_isOpaque : 1;
unsigned m_preserves3D : 1;
unsigned m_needsDisplayOnBoundsChange : 1;
unsigned m_needsTexture : 1;
unsigned m_isFixedPosition : 1;
unsigned m_hasFixedContainer : 1;
unsigned m_hasFixedAncestorInDOMTree : 1;
unsigned m_isContainerForFixedPositionLayers: 1;
unsigned m_isFixedToTop : 1;
unsigned m_isFixedToLeft : 1;
unsigned m_sizeIsScaleInvariant : 1;
unsigned m_contentsResolutionIndependent : 1;
// The following is only available for media (video) and plugin layers.
unsigned m_isVisible : 1;
// CAUTION: all the data members are copied from one instance to another
// i.e. from one thread to another in the replicate method.
// Beware of adding any member data e.g. of type String whose default
// assignment operator doesn't behave properly if the two String instances
// are owned by different threads.
};
} // namespace WebCore
#endif // USE(ACCELERATED_COMPOSITING)
#endif // LayerData_h
|