| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_LAYER_HELPER_H_ | 5 #ifndef VIEWS_LAYER_HELPER_H_ |
| 6 #define VIEWS_LAYER_HELPER_H_ | 6 #define VIEWS_LAYER_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 void SetLayer(ui::Layer* layer); | 36 void SetLayer(ui::Layer* layer); |
| 37 ui::Layer* layer() { return layer_.get(); } | 37 ui::Layer* layer() { return layer_.get(); } |
| 38 | 38 |
| 39 // Rectangle that needs to be painted. | 39 // Rectangle that needs to be painted. |
| 40 void set_clip_rect(const gfx::Rect& rect) { | 40 void set_clip_rect(const gfx::Rect& rect) { |
| 41 clip_rect_ = rect; | 41 clip_rect_ = rect; |
| 42 } | 42 } |
| 43 const gfx::Rect& clip_rect() const { return clip_rect_; } | 43 const gfx::Rect& clip_rect() const { return clip_rect_; } |
| 44 | 44 |
| 45 // If true, the layer's bitmap is out of date and needs to be updated. | |
| 46 void set_bitmap_needs_updating(bool value) { | |
| 47 bitmap_needs_updating_ = value; | |
| 48 } | |
| 49 bool bitmap_needs_updating() const { | |
| 50 return bitmap_needs_updating_; | |
| 51 } | |
| 52 | |
| 53 // If true the layer was explicitly turned on. | 45 // If true the layer was explicitly turned on. |
| 54 void set_paint_to_layer(bool value) { paint_to_layer_ = value; } | 46 void set_paint_to_layer(bool value) { paint_to_layer_ = value; } |
| 55 bool paint_to_layer() const { return paint_to_layer_; } | 47 bool paint_to_layer() const { return paint_to_layer_; } |
| 56 | 48 |
| 57 // See description in View for details | 49 // See description in View for details |
| 58 void set_fills_bounds_opaquely(bool fills_bounds_opaquely) { | 50 void set_fills_bounds_opaquely(bool fills_bounds_opaquely) { |
| 59 fills_bounds_opaquely_ = fills_bounds_opaquely; | 51 fills_bounds_opaquely_ = fills_bounds_opaquely; |
| 60 } | 52 } |
| 61 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } | 53 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } |
| 62 | 54 |
| 63 void SetPropertySetter(LayerPropertySetter* setter); | 55 void SetPropertySetter(LayerPropertySetter* setter); |
| 64 LayerPropertySetter* property_setter() { | 56 LayerPropertySetter* property_setter() { |
| 65 return property_setter_.get(); | 57 return property_setter_.get(); |
| 66 } | 58 } |
| 67 | 59 |
| 68 // If true the LayerPropertySetter was explicitly set. | 60 // If true the LayerPropertySetter was explicitly set. |
| 69 void set_property_setter_explicitly_set(bool value) { | 61 void set_property_setter_explicitly_set(bool value) { |
| 70 property_setter_explicitly_set_ = value; | 62 property_setter_explicitly_set_ = value; |
| 71 } | 63 } |
| 72 bool property_setter_explicitly_set() { | 64 bool property_setter_explicitly_set() { |
| 73 return property_setter_explicitly_set_; | 65 return property_setter_explicitly_set_; |
| 74 } | 66 } |
| 75 | 67 |
| 76 // See View::SetExternalTexture for details. | 68 // See View::SetExternalTexture for details. |
| 77 void set_layer_updated_externally(bool value) { | 69 void set_layer_updated_externally(bool value) { |
| 78 layer_updated_externally_ = value; | 70 layer_updated_externally_ = value; |
| 79 } | 71 } |
| 80 bool layer_updated_externally() const { return layer_updated_externally_; } | 72 bool layer_updated_externally() const { return layer_updated_externally_; } |
| 81 | 73 |
| 82 // If true the complete bounds of the view needs to be painted. | |
| 83 void set_needs_paint_all(bool value) { needs_paint_all_ = value; } | |
| 84 bool needs_paint_all() const { return needs_paint_all_; } | |
| 85 | |
| 86 // Returns true if the layer needs to be used. | 74 // Returns true if the layer needs to be used. |
| 87 bool ShouldPaintToLayer() const; | 75 bool ShouldPaintToLayer() const; |
| 88 | 76 |
| 89 private: | 77 private: |
| 90 // The transformation matrix (rotation, translate, scale). If non-null the | 78 // The transformation matrix (rotation, translate, scale). If non-null the |
| 91 // transform is not the identity transform. | 79 // transform is not the identity transform. |
| 92 scoped_ptr<ui::Transform> transform_; | 80 scoped_ptr<ui::Transform> transform_; |
| 93 | 81 |
| 94 scoped_ptr<ui::Layer> layer_; | 82 scoped_ptr<ui::Layer> layer_; |
| 95 | 83 |
| 96 scoped_ptr<LayerPropertySetter> property_setter_; | 84 scoped_ptr<LayerPropertySetter> property_setter_; |
| 97 | 85 |
| 98 // Used during painting. If not empty and View::Paint() is invoked, the canvas | 86 // Used during painting. If not empty and View::Paint() is invoked, the canvas |
| 99 // is created with the specified size. | 87 // is created with the specified size. |
| 100 // TODO(sky): this should be passed into paint. | 88 // TODO(sky): this should be passed into paint. |
| 101 gfx::Rect clip_rect_; | 89 gfx::Rect clip_rect_; |
| 102 | 90 |
| 103 // Is the layers bitmap out of date? | |
| 104 bool bitmap_needs_updating_; | |
| 105 | |
| 106 bool fills_bounds_opaquely_; | 91 bool fills_bounds_opaquely_; |
| 107 | 92 |
| 108 // If true the bitmap is always up to date. | 93 // If true the bitmap is always up to date. |
| 109 bool layer_updated_externally_; | 94 bool layer_updated_externally_; |
| 110 | 95 |
| 111 // Should the View paint to a layer? | 96 // Should the View paint to a layer? |
| 112 bool paint_to_layer_; | 97 bool paint_to_layer_; |
| 113 | 98 |
| 114 bool property_setter_explicitly_set_; | 99 bool property_setter_explicitly_set_; |
| 115 | 100 |
| 116 bool needs_paint_all_; | 101 bool needs_paint_all_; |
| 117 | 102 |
| 118 DISALLOW_COPY_AND_ASSIGN(LayerHelper); | 103 DISALLOW_COPY_AND_ASSIGN(LayerHelper); |
| 119 }; | 104 }; |
| 120 | 105 |
| 121 } // namespace internal | 106 } // namespace internal |
| 122 | 107 |
| 123 } // namespace views | 108 } // namespace views |
| 124 | 109 |
| 125 #endif // VIEWS_LAYER_HELPER_H_ | 110 #endif // VIEWS_LAYER_HELPER_H_ |
| OLD | NEW |