2 * Copyright (C) 2009 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef LayerAndroid_h
18 #define LayerAndroid_h
20 #if USE(ACCELERATED_COMPOSITING)
22 #include "FloatPoint.h"
26 #include "StringHash.h"
27 #include <wtf/HashMap.h>
36 class AndroidAnimation;
38 class LayerAndroid : public SkLayer {
41 LayerAndroid(bool isRootLayer);
42 LayerAndroid(const LayerAndroid& layer);
43 virtual ~LayerAndroid();
45 static int instancesCount();
47 void setHaveContents(bool haveContents) { m_haveContents = haveContents; }
48 void setHaveImage(bool haveImage) { m_haveImage = haveImage; }
49 void setDrawsContent(bool drawsContent);
50 void setFindOnPage(FindOnPage* findOnPage);
51 void setMaskLayer(LayerAndroid*);
52 void setMasksToBounds(bool);
53 virtual void setBackgroundColor(SkColor color);
54 void setIsRootLayer(bool isRootLayer) { m_isRootLayer = isRootLayer; }
56 virtual void draw(SkCanvas*, const SkRect* viewPort);
57 // GraphicsContext* paintContext();
58 bool prepareContext(bool force = false);
59 void startRecording();
61 SkPicture* recordContext();
62 void setClip(SkCanvas* clip);
64 void addAnimation(PassRefPtr<AndroidAnimation> anim);
65 void removeAnimation(const String& name);
66 bool evaluateAnimations() const;
67 bool evaluateAnimations(double time) const;
68 bool hasAnimations() const;
70 SkPicture* picture() const { return m_recordingPicture; }
72 void dumpLayers(FILE*, int indentLevel) const;
74 void bounds(SkRect* ) const;
75 bool calcPosition(const SkRect* viewPort, SkMatrix*);
76 void clipArea(SkTDArray<SkRect>* region) const;
77 const LayerAndroid* find(FloatPoint position) const;
78 const LayerAndroid* findById(int uniqueID) const;
79 LayerAndroid* getChild(int index) const { return
80 static_cast<LayerAndroid*>(m_children[index]); }
81 bool haveClip() const { return m_haveClip; }
82 int uniqueId() const { return m_uniqueId; }
84 bool boundsIsUnique(SkTDArray<SkRect>* region, const SkRect& local) const;
85 void clipInner(SkTDArray<SkRect>* region, const SkRect& local) const;
86 void paintChildren(const SkRect* viewPort, SkCanvas* canvas, float opacity);
87 void paintMe(const SkRect* viewPort, SkCanvas* canvas,
96 SkPicture* m_recordingPicture;
98 typedef HashMap<String, RefPtr<AndroidAnimation> > KeyframesMap;
99 KeyframesMap m_animations;
100 FindOnPage* m_findOnPage;
106 #endif // USE(ACCELERATED_COMPOSITING)
108 #endif // LayerAndroid_h