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

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

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ccameron's fix for exisiting nine-patch uses Created 7 years, 3 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 "cc/base/cc_export.h" 10 #include "cc/base/cc_export.h"
11 #include "cc/layers/layer_impl.h" 11 #include "cc/layers/layer_impl.h"
12 #include "cc/resources/resource_provider.h" 12 #include "cc/resources/resource_provider.h"
13 #include "cc/resources/ui_resource_client.h"
13 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
14 #include "ui/gfx/size.h" 15 #include "ui/gfx/size.h"
15 16
16 namespace base { 17 namespace base {
17 class DictionaryValue; 18 class DictionaryValue;
18 } 19 }
19 20
20 namespace cc { 21 namespace cc {
21 22
22 class CC_EXPORT NinePatchLayerImpl : public LayerImpl { 23 class CC_EXPORT NinePatchLayerImpl : public LayerImpl {
23 public: 24 public:
24 static scoped_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl, 25 static scoped_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl,
25 int id) { 26 int id) {
26 return make_scoped_ptr(new NinePatchLayerImpl(tree_impl, id)); 27 return make_scoped_ptr(new NinePatchLayerImpl(tree_impl, id));
27 } 28 }
28 virtual ~NinePatchLayerImpl(); 29 virtual ~NinePatchLayerImpl();
29 30
30 void SetResourceId(unsigned id) { resource_id_ = id; } 31
31 void SetLayout(gfx::Size image_bounds, gfx::Rect aperture); 32 void SetUIResourceId(UIResourceId uid);
33
34 // The bitmap stretches out the bounds of the layer. The following picture
35 // illustrates the parameters associated with the dimensions.
36 //
37 // Layer space layout Bitmap space layout
38 //
39 // ------------------------ ~~~~~~~~~~ W ~~~~~~~~~~
40 // | : | : : |
41 // | C | : Y |
42 // | : | : : |
43 // | ------------ | :~~X~~------------ |
44 // | | | | : | : |
45 // | | | | : | : |
46 // |~~A~~| |~~B~~| H | Q |
47 // | | | | : | : |
48 // | ------------ | : ~~~~~P~~~~~ |
49 // | : | : |
50 // | D | : |
51 // | : | : |
52 // ------------------------ ------------------------
53 //
54 // |image_bounds| = (W, H)
55 // |image_aperture| = (X, Y, P, Q)
56 // |border| = (A, C, A + B, C + D)
57 // |fill_center| indicates whether to draw the center quad or not.
58 void SetLayout(gfx::Size image_bounds,
59 gfx::Rect image_aperture,
60 gfx::Rect border,
61 bool fill_center);
32 62
33 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 63 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
34 OVERRIDE; 64 OVERRIDE;
35 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; 65 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
36 66
37 virtual bool WillDraw(DrawMode draw_mode, 67 virtual bool WillDraw(DrawMode draw_mode,
38 ResourceProvider* resource_provider) OVERRIDE; 68 ResourceProvider* resource_provider) OVERRIDE;
39 virtual void AppendQuads(QuadSink* quad_sink, 69 virtual void AppendQuads(QuadSink* quad_sink,
40 AppendQuadsData* append_quads_data) OVERRIDE; 70 AppendQuadsData* append_quads_data) OVERRIDE;
41 virtual ResourceProvider::ResourceId ContentsResourceId() const OVERRIDE; 71 virtual ResourceProvider::ResourceId ContentsResourceId() const OVERRIDE;
42 virtual void DidLoseOutputSurface() OVERRIDE;
43 72
44 virtual base::DictionaryValue* LayerTreeAsJson() const OVERRIDE; 73 virtual base::DictionaryValue* LayerTreeAsJson() const OVERRIDE;
45 74
46 protected: 75 protected:
47 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id); 76 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id);
48 77
49 private: 78 private:
50 virtual const char* LayerTypeAsString() const OVERRIDE; 79 virtual const char* LayerTypeAsString() const OVERRIDE;
51 80
52 // The size of the NinePatch bitmap in pixels. 81 // The size of the NinePatch bitmap in pixels.
53 gfx::Size image_bounds_; 82 gfx::Size image_bounds_;
54 83
55 // The transparent center region that shows the parent layer's contents in 84 // The transparent center region that shows the parent layer's contents in
56 // image space. 85 // image space.
57 gfx::Rect image_aperture_; 86 gfx::Rect image_aperture_;
58 87
59 ResourceProvider::ResourceId resource_id_; 88 // An inset border that the patches will be mapped to.
89 gfx::Rect border_;
90
91 bool fill_center_;
92
93 UIResourceId ui_resource_id_;
60 94
61 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl); 95 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl);
62 }; 96 };
63 97
64 } // namespace cc 98 } // namespace cc
65 99
66 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_ 100 #endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698