blob: 5246ae09ef428e9c0c14138c9dcd1d53f4172d66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef VIEWS_LAYER_HELPER_H_
#define VIEWS_LAYER_HELPER_H_
#pragma once
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/rect.h"
namespace ui {
class Layer;
class Texture;
class Transform;
}
namespace views {
class LayerPropertySetter;
// This is a views-internal API and should not be used externally. View uses
// this class to manage fields related to accelerated painting.
namespace internal {
class LayerHelper {
public:
LayerHelper();
~LayerHelper();
void SetTransform(const ui::Transform& transform);
// Only returns non-null if a non-identity transform has been set.
const ui::Transform* transform() const { return transform_.get(); }
void SetLayer(ui::Layer* layer);
ui::Layer* layer() { return layer_.get(); }
// Passing NULL will cause the layer to get a texture from its compositor.
void SetExternalTexture(ui::Texture* texture);
// Sometimes the Layer is being updated by something other than SetCanvas
// (e.g. the GPU process on TOUCH_UI).
bool layer_updated_externally() const {
return external_texture_.get() != NULL;
}
// Rectangle that needs to be painted.
void set_clip_rect(const gfx::Rect& rect) {
clip_rect_ = rect;
}
const gfx::Rect& clip_rect() const { return clip_rect_; }
// If true the layer was explicitly turned on.
void set_paint_to_layer(bool value) { paint_to_layer_ = value; }
bool paint_to_layer() const { return paint_to_layer_; }
// See description in View for details
void set_fills_bounds_opaquely(bool fills_bounds_opaquely) {
fills_bounds_opaquely_ = fills_bounds_opaquely;
}
bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; }
void SetPropertySetter(LayerPropertySetter* setter);
LayerPropertySetter* property_setter() {
return property_setter_.get();
}
// If true the LayerPropertySetter was explicitly set.
void set_property_setter_explicitly_set(bool value) {
property_setter_explicitly_set_ = value;
}
bool property_setter_explicitly_set() {
return property_setter_explicitly_set_;
}
// Returns true if the layer needs to be used.
bool ShouldPaintToLayer() const;
private:
// The transformation matrix (rotation, translate, scale). If non-null the
// transform is not the identity transform.
scoped_ptr<ui::Transform> transform_;
scoped_ptr<ui::Layer> layer_;
scoped_ptr<LayerPropertySetter> property_setter_;
// Used during painting. If not empty and View::Paint() is invoked, the canvas
// is created with the specified size.
// TODO(sky): this should be passed into paint.
gfx::Rect clip_rect_;
bool fills_bounds_opaquely_;
// Should the View paint to a layer?
bool paint_to_layer_;
bool property_setter_explicitly_set_;
bool needs_paint_all_;
scoped_refptr<ui::Texture> external_texture_;
DISALLOW_COPY_AND_ASSIGN(LayerHelper);
};
} // namespace internal
} // namespace views
#endif // VIEWS_LAYER_HELPER_H_
|