Home | History | Annotate | Download | only in android
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef GraphicsLayerAndroid_h
     18 #define GraphicsLayerAndroid_h
     19 
     20 #if USE(ACCELERATED_COMPOSITING)
     21 
     22 #include "FloatRect.h"
     23 #include "Frame.h"
     24 #include "GraphicsLayer.h"
     25 #include "GraphicsLayerClient.h"
     26 #include "LayerAndroid.h"
     27 #include "RefPtr.h"
     28 #include "Vector.h"
     29 
     30 class FloatPoint3D;
     31 class Image;
     32 
     33 namespace WebCore {
     34 
     35 class GraphicsLayerAndroid : public GraphicsLayer {
     36 public:
     37 
     38     GraphicsLayerAndroid(GraphicsLayerClient*);
     39     virtual ~GraphicsLayerAndroid();
     40 
     41     virtual void setName(const String&);
     42 
     43     // for hosting this GraphicsLayer in a native layer hierarchy
     44     virtual NativeLayer nativeLayer() const;
     45 
     46     virtual bool setChildren(const Vector<GraphicsLayer*>&);
     47     virtual void addChild(GraphicsLayer*);
     48     virtual void addChildAtIndex(GraphicsLayer*, int index);
     49     virtual void addChildAbove(GraphicsLayer* layer, GraphicsLayer* sibling);
     50     virtual void addChildBelow(GraphicsLayer* layer, GraphicsLayer* sibling);
     51     virtual bool replaceChild(GraphicsLayer* oldChild, GraphicsLayer* newChild);
     52 
     53     virtual void removeFromParent();
     54 
     55     virtual void setPosition(const FloatPoint&);
     56     virtual void setAnchorPoint(const FloatPoint3D&);
     57     virtual void setSize(const FloatSize&);
     58 
     59     virtual void setTransform(const TransformationMatrix&);
     60 
     61     virtual void setChildrenTransform(const TransformationMatrix&);
     62 
     63     virtual void setMaskLayer(GraphicsLayer*);
     64     virtual void setMasksToBounds(bool);
     65     virtual void setDrawsContent(bool);
     66 
     67     virtual void setBackgroundColor(const Color&);
     68     virtual void clearBackgroundColor();
     69 
     70     virtual void setContentsOpaque(bool);
     71 
     72     virtual void setOpacity(float);
     73 
     74     virtual void setNeedsDisplay();
     75     virtual void setNeedsDisplayInRect(const FloatRect&);
     76 
     77     virtual bool addAnimation(const KeyframeValueList& valueList,
     78                               const IntSize& boxSize,
     79                               const Animation* anim,
     80                               const String& keyframesName,
     81                               double beginTime);
     82     bool createTransformAnimationsFromKeyframes(const KeyframeValueList&,
     83                                                 const Animation*,
     84                                                 const String& keyframesName,
     85                                                 double beginTime,
     86                                                 const IntSize& boxSize);
     87     bool createAnimationFromKeyframes(const KeyframeValueList&,
     88                                       const Animation*,
     89                                       const String& keyframesName,
     90                                       double beginTime);
     91 
     92     virtual void removeAnimationsForProperty(AnimatedPropertyID);
     93     virtual void removeAnimationsForKeyframes(const String& keyframesName);
     94     virtual void pauseAnimation(const String& keyframesName);
     95 
     96     virtual void suspendAnimations(double time);
     97     virtual void resumeAnimations();
     98 
     99     virtual void setContentsToImage(Image*);
    100     bool repaintAll();
    101     virtual PlatformLayer* platformLayer() const;
    102 
    103     void pauseDisplay(bool state);
    104 
    105 #ifndef NDEBUG
    106     virtual void setDebugBackgroundColor(const Color&);
    107     virtual void setDebugBorder(const Color&, float borderWidth);
    108 #endif
    109 
    110     virtual void setZPosition(float);
    111 
    112     void askForSync();
    113     void syncPositionState();
    114     void needsSyncChildren();
    115     void syncChildren();
    116     void syncMask();
    117     virtual void syncCompositingState();
    118     void setFrame(Frame*);
    119     void notifyClientAnimationStarted();
    120 
    121     void sendImmediateRepaint();
    122     LayerAndroid* contentLayer() { return m_contentLayer; }
    123 
    124     static int instancesCount();
    125 
    126 private:
    127 
    128     void updateFixedPosition();
    129 
    130     bool repaint(const FloatRect& rect);
    131     void needsNotifyClient();
    132 
    133     bool m_needsSyncChildren;
    134     bool m_needsSyncMask;
    135     bool m_needsRepaint;
    136     bool m_needsDisplay;
    137     bool m_needsNotifyClient;
    138 
    139     bool m_haveContents;
    140     bool m_haveImage;
    141 
    142     float m_translateX;
    143     float m_translateY;
    144     float m_currentTranslateX;
    145     float m_currentTranslateY;
    146 
    147     FloatPoint m_currentPosition;
    148 
    149     RefPtr<Frame> m_frame;
    150 
    151     Vector<FloatRect> m_invalidatedRects;
    152 
    153     LayerAndroid* m_contentLayer;
    154 };
    155 
    156 } // namespace WebCore
    157 
    158 
    159 #endif // USE(ACCELERATED_COMPOSITING)
    160 
    161 #endif // GraphicsLayerAndroid_h
    162