Home | History | Annotate | Download | only in layers
      1 // Copyright 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CC_LAYERS_TEXTURE_LAYER_IMPL_H_
      6 #define CC_LAYERS_TEXTURE_LAYER_IMPL_H_
      7 
      8 #include <string>
      9 
     10 #include "base/callback.h"
     11 #include "cc/base/cc_export.h"
     12 #include "cc/layers/layer_impl.h"
     13 
     14 namespace cc {
     15 class SingleReleaseCallback;
     16 class ScopedResource;
     17 
     18 class CC_EXPORT TextureLayerImpl : public LayerImpl {
     19  public:
     20   static scoped_ptr<TextureLayerImpl> Create(LayerTreeImpl* tree_impl, int id) {
     21     return make_scoped_ptr(new TextureLayerImpl(tree_impl, id));
     22   }
     23   virtual ~TextureLayerImpl();
     24 
     25   virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* layer_tree_impl)
     26       OVERRIDE;
     27   virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
     28 
     29   virtual bool WillDraw(DrawMode draw_mode,
     30                         ResourceProvider* resource_provider) OVERRIDE;
     31   virtual void AppendQuads(QuadSink* quad_sink,
     32                            AppendQuadsData* append_quads_data) OVERRIDE;
     33   virtual Region VisibleContentOpaqueRegion() const OVERRIDE;
     34   virtual void ReleaseResources() OVERRIDE;
     35 
     36   // These setter methods don't cause any implicit damage, so the texture client
     37   // must explicitly invalidate if they intend to cause a visible change in the
     38   // layer's output.
     39   void SetTextureId(unsigned id);
     40   void SetPremultipliedAlpha(bool premultiplied_alpha);
     41   void SetBlendBackgroundColor(bool blend);
     42   void SetFlipped(bool flipped);
     43   void SetUVTopLeft(const gfx::PointF top_left);
     44   void SetUVBottomRight(const gfx::PointF bottom_right);
     45 
     46   // 1--2
     47   // |  |
     48   // 0--3
     49   void SetVertexOpacity(const float vertex_opacity[4]);
     50 
     51   void SetTextureMailbox(const TextureMailbox& mailbox,
     52                          scoped_ptr<SingleReleaseCallback> release_callback);
     53 
     54  private:
     55   TextureLayerImpl(LayerTreeImpl* tree_impl, int id);
     56 
     57   virtual const char* LayerTypeAsString() const OVERRIDE;
     58   void FreeTextureMailbox();
     59 
     60   ResourceProvider::ResourceId external_texture_resource_;
     61   bool premultiplied_alpha_;
     62   bool blend_background_color_;
     63   bool flipped_;
     64   gfx::PointF uv_top_left_;
     65   gfx::PointF uv_bottom_right_;
     66   float vertex_opacity_[4];
     67   // This is a resource that's a GL copy of a software texture mailbox.
     68   scoped_ptr<ScopedResource> texture_copy_;
     69 
     70   TextureMailbox texture_mailbox_;
     71   scoped_ptr<SingleReleaseCallback> release_callback_;
     72   bool own_mailbox_;
     73   bool valid_texture_copy_;
     74 
     75   DISALLOW_COPY_AND_ASSIGN(TextureLayerImpl);
     76 };
     77 
     78 }  // namespace cc
     79 
     80 #endif  // CC_LAYERS_TEXTURE_LAYER_IMPL_H_
     81