blob: 5320d398c324c91979683a00e8c18bf6705a1a93 [file] [log] [blame]
[email protected]35680c02012-11-06 05:53:001// Copyright 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]cc3cfaa2013-03-18 09:05:525#ifndef CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
6#define CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_
[email protected]35680c02012-11-06 05:53:007
[email protected]bf691c22013-03-26 21:15:068#include <string>
9
[email protected]681ccff2013-03-18 06:13:5210#include "cc/base/cc_export.h"
[email protected]cc3cfaa2013-03-18 09:05:5211#include "cc/layers/layer_impl.h"
[email protected]efbdb3a2013-10-04 00:35:1312#include "cc/layers/ui_resource_layer_impl.h"
[email protected]e12dd0e2013-03-18 08:24:4013#include "cc/resources/resource_provider.h"
[email protected]741fba422013-09-20 03:34:1414#include "cc/resources/ui_resource_client.h"
heejin.r.chungd28506ba2014-10-23 16:36:2015#include "ui/gfx/geometry/rect.h"
16#include "ui/gfx/geometry/size.h"
[email protected]35680c02012-11-06 05:53:0017
[email protected]4a23c374c2012-12-08 08:38:5518namespace base {
19class DictionaryValue;
20}
21
[email protected]35680c02012-11-06 05:53:0022namespace cc {
23
[email protected]efbdb3a2013-10-04 00:35:1324class CC_EXPORT NinePatchLayerImpl : public UIResourceLayerImpl {
[email protected]37adf942013-03-08 04:43:1725 public:
26 static scoped_ptr<NinePatchLayerImpl> Create(LayerTreeImpl* tree_impl,
27 int id) {
28 return make_scoped_ptr(new NinePatchLayerImpl(tree_impl, id));
29 }
dcheng716bedf2014-10-21 09:51:0830 ~NinePatchLayerImpl() override;
[email protected]35680c02012-11-06 05:53:0031
[email protected]741fba422013-09-20 03:34:1432 // The bitmap stretches out the bounds of the layer. The following picture
33 // illustrates the parameters associated with the dimensions.
34 //
35 // Layer space layout Bitmap space layout
36 //
37 // ------------------------ ~~~~~~~~~~ W ~~~~~~~~~~
38 // | : | : : |
39 // | C | : Y |
40 // | : | : : |
41 // | ------------ | :~~X~~------------ |
42 // | | | | : | : |
43 // | | | | : | : |
44 // |~~A~~| |~~B~~| H | Q |
45 // | | | | : | : |
46 // | ------------ | : ~~~~~P~~~~~ |
47 // | : | : |
48 // | D | : |
49 // | : | : |
50 // ------------------------ ------------------------
51 //
52 // |image_bounds| = (W, H)
53 // |image_aperture| = (X, Y, P, Q)
54 // |border| = (A, C, A + B, C + D)
55 // |fill_center| indicates whether to draw the center quad or not.
[email protected]0023fc72014-01-10 20:05:0656 void SetLayout(const gfx::Rect& image_aperture,
57 const gfx::Rect& border,
[email protected]741fba422013-09-20 03:34:1458 bool fill_center);
[email protected]35680c02012-11-06 05:53:0059
dcheng716bedf2014-10-21 09:51:0860 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
61 void PushPropertiesTo(LayerImpl* layer) override;
[email protected]48871fc2013-01-23 07:36:5162
dcheng716bedf2014-10-21 09:51:0863 void AppendQuads(RenderPass* render_pass,
64 const Occlusion& occlusion_in_content_space,
65 AppendQuadsData* append_quads_data) override;
[email protected]35680c02012-11-06 05:53:0066
dcheng716bedf2014-10-21 09:51:0867 base::DictionaryValue* LayerTreeAsJson() const override;
[email protected]4a23c374c2012-12-08 08:38:5568
[email protected]37adf942013-03-08 04:43:1769 protected:
70 NinePatchLayerImpl(LayerTreeImpl* tree_impl, int id);
[email protected]35680c02012-11-06 05:53:0071
[email protected]37adf942013-03-08 04:43:1772 private:
dcheng716bedf2014-10-21 09:51:0873 const char* LayerTypeAsString() const override;
[email protected]35680c02012-11-06 05:53:0074
[email protected]efbdb3a2013-10-04 00:35:1375 void CheckGeometryLimitations();
[email protected]35680c02012-11-06 05:53:0076
[email protected]37adf942013-03-08 04:43:1777 // The transparent center region that shows the parent layer's contents in
78 // image space.
79 gfx::Rect image_aperture_;
[email protected]35680c02012-11-06 05:53:0080
[email protected]741fba422013-09-20 03:34:1481 // An inset border that the patches will be mapped to.
82 gfx::Rect border_;
83
84 bool fill_center_;
85
[email protected]fa2d9a52013-03-27 18:47:0886 DISALLOW_COPY_AND_ASSIGN(NinePatchLayerImpl);
[email protected]35680c02012-11-06 05:53:0087};
88
[email protected]ffaa2a632012-11-11 14:47:5089} // namespace cc
[email protected]35680c02012-11-06 05:53:0090
[email protected]cc3cfaa2013-03-18 09:05:5291#endif // CC_LAYERS_NINE_PATCH_LAYER_IMPL_H_