1/*
2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 *     * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *     * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 *     * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31
32#ifndef ContentLayerChromium_h
33#define ContentLayerChromium_h
34
35#if USE(ACCELERATED_COMPOSITING)
36
37#include "LayerChromium.h"
38#include "LayerTilerChromium.h"
39#include "TextureManager.h"
40
41namespace WebCore {
42
43class LayerTexture;
44
45// A Layer that requires a GraphicsContext to render its contents.
46class ContentLayerChromium : public LayerChromium {
47    friend class LayerRendererChromium;
48public:
49    enum TilingOption { AlwaysTile, NeverTile, AutoTile };
50
51    static PassRefPtr<ContentLayerChromium> create(GraphicsLayerChromium* owner = 0);
52
53    virtual ~ContentLayerChromium();
54
55    virtual void paintContentsIfDirty(const IntRect& targetSurfaceRect);
56    virtual void updateCompositorResources();
57    virtual void setIsMask(bool);
58    virtual void bindContentsTexture();
59
60    virtual void draw(const IntRect& targetSurfaceRect);
61    virtual bool drawsContent() const { return m_owner && m_owner->drawsContent() && (!m_tiler || !m_tiler->skipsDraw()); }
62
63protected:
64    explicit ContentLayerChromium(GraphicsLayerChromium* owner);
65
66    virtual const char* layerTypeAsString() const { return "ContentLayer"; }
67    virtual void dumpLayerProperties(TextStream&, int indent) const;
68
69    virtual void setLayerRenderer(LayerRendererChromium*);
70
71    virtual IntRect layerBounds() const;
72
73    virtual TransformationMatrix tilingTransform();
74
75    // For a given render surface rect that this layer will be transformed and
76    // drawn into, return the layer space rect that is visible in that surface.
77    IntRect visibleLayerRect(const IntRect&);
78
79    void updateLayerSize(const IntSize&);
80    void createTilerIfNeeded();
81    void setTilingOption(TilingOption);
82
83    OwnPtr<LayerTilerChromium> m_tiler;
84    TilingOption m_tilingOption;
85};
86
87}
88#endif // USE(ACCELERATED_COMPOSITING)
89
90#endif
91