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