Home | History | Annotate | Download | only in chromium
      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
      6  * are met:
      7  *
      8  * 1.  Redistributions of source code must retain the above copyright
      9  *     notice, this list of conditions and the following disclaimer.
     10  * 2.  Redistributions in binary form must reproduce the above copyright
     11  *     notice, this list of conditions and the following disclaimer in the
     12  *     documentation and/or other materials provided with the distribution.
     13  *
     14  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
     15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     17  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     18  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     19  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     20  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     21  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 
     27 #ifndef RenderSurfaceChromium_h
     28 #define RenderSurfaceChromium_h
     29 
     30 #if USE(ACCELERATED_COMPOSITING)
     31 
     32 #include "FloatRect.h"
     33 #include "IntRect.h"
     34 #include "ProgramBinding.h"
     35 #include "ShaderChromium.h"
     36 #include "TextureManager.h"
     37 #include "TransformationMatrix.h"
     38 #include <wtf/Noncopyable.h>
     39 
     40 namespace WebCore {
     41 
     42 class CCLayerImpl;
     43 class LayerRendererChromium;
     44 class LayerTexture;
     45 
     46 class RenderSurfaceChromium {
     47     WTF_MAKE_NONCOPYABLE(RenderSurfaceChromium);
     48     friend class LayerRendererChromium;
     49 public:
     50     explicit RenderSurfaceChromium(CCLayerImpl*);
     51     ~RenderSurfaceChromium();
     52 
     53     bool prepareContentsTexture();
     54     void cleanupResources();
     55     void draw(const IntRect& targetSurfaceRect);
     56 
     57     String name() const;
     58     void dumpSurface(TextStream&, int indent) const;
     59 
     60     FloatPoint contentRectCenter() const { return FloatRect(m_contentRect).center(); }
     61     IntRect contentRect() const { return m_contentRect; }
     62 
     63     // Returns the rect that encloses the RenderSurface including any reflection.
     64     FloatRect drawableContentRect() const;
     65 
     66     TransformationMatrix drawTransform() const { return m_drawTransform; }
     67 
     68     typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlpha> Program;
     69     typedef ProgramBinding<VertexShaderPosTex, FragmentShaderRGBATexAlphaMask> MaskProgram;
     70 
     71 private:
     72     LayerRendererChromium* layerRenderer();
     73     void drawSurface(CCLayerImpl* maskLayer, const TransformationMatrix& drawTransform);
     74 
     75     CCLayerImpl* m_owningLayer;
     76     CCLayerImpl* m_maskLayer;
     77 
     78     IntRect m_contentRect;
     79     bool m_skipsDraw;
     80 
     81     OwnPtr<LayerTexture> m_contentsTexture;
     82     float m_drawOpacity;
     83     TransformationMatrix m_drawTransform;
     84     TransformationMatrix m_replicaDrawTransform;
     85     TransformationMatrix m_originTransform;
     86     IntRect m_scissorRect;
     87     Vector<RefPtr<CCLayerImpl> > m_layerList;
     88 };
     89 
     90 }
     91 #endif // USE(ACCELERATED_COMPOSITING)
     92 
     93 #endif
     94