Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: cc/layers/nine_patch_layer_impl.h

Issue 2591863003: Use nine-patch resource for drawing Aura overlay scrollbar thumb. (Closed)
Patch Set: Addressed sadrul@'s feedback Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_NINE_PATCH_LAYER_IMPL_H_ 5 #ifndef CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
6 #define CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ 6 #define CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "cc/base/cc_export.h" 12 #include "cc/base/cc_export.h"
13 #include "cc/layers/layer_impl.h" 13 #include "cc/layers/layer_impl.h"
14 #include "cc/layers/ui_resource_layer_impl.h" 14 #include "cc/layers/ui_resource_layer_impl.h"
15 #include "cc/quads/nine_patch_generator.h"
15 #include "cc/resources/resource_provider.h" 16 #include "cc/resources/resource_provider.h"
16 #include "cc/resources/ui_resource_client.h" 17 #include "cc/resources/ui_resource_client.h"
17 #include "ui/gfx/geometry/rect.h" 18 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/size.h" 19 #include "ui/gfx/geometry/size.h"
19 20
20 namespace base { 21 namespace base {
21 class DictionaryValue; 22 class DictionaryValue;
22 } 23 }
23 24
24 namespace cc { 25 namespace cc {
25 26
26 class CC_EXPORT NinePatchLayerImpl : public UIResourceLayerImpl { 27 class CC_EXPORT NinePatchLayerImpl : public UIResourceLayerImpl {
27 public: 28 public:
28 static std::unique_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl, 29 static std::unique_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl,
29 int id) { 30 int id) {
30 return base::WrapUnique(new NinePatchLayerImpl(tree_impl, id)); 31 return base::WrapUnique(new NinePatchLayerImpl(tree_impl, id));
31 } 32 }
32 ~NinePatchLayerImpl() override; 33 ~NinePatchLayerImpl() override;
33 34
34 // The bitmap stretches out the bounds of the layer. The following picture 35 // For parameter meanings, see the declaration of NinePatchGenerator.
35 // illustrates the parameters associated with the dimensions.
36 //
37 // Layer space layout
38 //
39 // --------------------------------
40 // | : : |
41 // | J C |
42 // | : : |
43 // | ------------------ |
44 // | | : | |
45 // |~~~I~~| ------------ | |
46 // | | | | | |
47 // | | | | | |
48 // |~~~A~~|~~| |~~|~B~~~~|
49 // | | | | | |
50 // | L ------------ | |
51 // | | : | |
52 // | ---K-------------- |
53 // | D |
54 // | : |
55 // | : |
56 // --------------------------------
57 //
58 // Bitmap space layout
59 //
60 // ~~~~~~~~~~ W ~~~~~~~~~~
61 // : : |
62 // : Y |
63 // : : |
64 // :~~X~~------------ |
65 // : | : |
66 // : | : |
67 // H | Q |
68 // : | : |
69 // : ~~~~~P~~~~~ |
70 // : |
71 // : |
72 // : |
73 // ------------------------
74 //
75 // |image_bounds| = (W, H)
76 // |image_aperture| = (X, Y, P, Q)
77 // |border| = (A, C, A + B, C + D)
78 // |occlusion_rectangle| = (I, J, K, L)
79 // |fill_center| indicates whether to draw the center quad or not.
80 void SetLayout(const gfx::Rect& image_aperture, 36 void SetLayout(const gfx::Rect& image_aperture,
81 const gfx::Rect& border, 37 const gfx::Rect& border,
82 const gfx::Rect& layer_occlusion, 38 const gfx::Rect& layer_occlusion,
83 bool fill_center, 39 bool fill_center,
84 bool nearest_neighbor); 40 bool nearest_neighbor);
85 41
86 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; 42 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
87 void PushPropertiesTo(LayerImpl* layer) override; 43 void PushPropertiesTo(LayerImpl* layer) override;
88 44
89 void AppendQuads(RenderPass* render_pass, 45 void AppendQuads(RenderPass* render_pass,
90 AppendQuadsData* append_quads_data) override; 46 AppendQuadsData* append_quads_data) override;
91 47
92 std::unique_ptr<base::DictionaryValue> LayerTreeAsJson() override; 48 std::unique_ptr<base::DictionaryValue> LayerTreeAsJson() override;
93 49
94 protected: 50 protected:
95 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id); 51 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id);
96 52
97 private: 53 private:
98 class Patch {
99 public:
100 Patch(const gfx::RectF& image_rect, const gfx::RectF& layer_rect);
101
102 gfx::RectF image_rect;
103 gfx::RectF layer_rect;
104 };
105
106 const char* LayerTypeAsString() const override; 54 const char* LayerTypeAsString() const override;
107 55
108 void CheckGeometryLimitations(); 56 NinePatchGenerator quad_generator_;
109
110 std::vector<Patch> ComputeQuadsWithOcclusion() const;
111 std::vector<Patch> ComputeQuadsWithoutOcclusion() const;
112
113 // The transparent center region that shows the parent layer's contents in
114 // image space.
115 gfx::Rect image_aperture_;
116
117 // An inset border that the patches will be mapped to.
118 gfx::Rect border_;
119
120 bool fill_center_;
121
122 bool nearest_neighbor_;
123
124 gfx::Rect layer_occlusion_;
125 57
126 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl); 58 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl);
127 }; 59 };
128 60
129 } // namespace cc 61 } // namespace cc
130 62
131 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ 63 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698