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

Side by Side Diff: cc/layers/nine_patch_layer.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: comments by aelias. added invalidation of ui resources to android-side 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
« no previous file with comments | « no previous file | cc/layers/nine_patch_layer.cc » ('j') | cc/layers/nine_patch_layer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_H_ 5 #ifndef CC_LAYERS_NINE_PATCH_LAYER_H_
6 #define CC_LAYERS_NINE_PATCH_LAYER_H_ 6 #define CC_LAYERS_NINE_PATCH_LAYER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "cc/base/cc_export.h" 9 #include "cc/base/cc_export.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
11 #include "cc/resources/image_layer_updater.h" 11 #include "cc/resources/ui_resource_client.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
13 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
14 13
15 namespace cc { 14 namespace cc {
16 15
17 class ResourceUpdateQueue; 16 class LayerTreeHost;
17 class ScopedUIResource;
18 18
19 class CC_EXPORT NinePatchLayer : public Layer { 19 class CC_EXPORT NinePatchLayer : public Layer {
20 public: 20 public:
21 static scoped_refptr<NinePatchLayer> Create(); 21 static scoped_refptr<NinePatchLayer> Create();
22 22
23 virtual bool DrawsContent() const OVERRIDE; 23 virtual bool DrawsContent() const OVERRIDE;
24 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) 24
25 OVERRIDE;
26 virtual bool Update(ResourceUpdateQueue* queue,
27 const OcclusionTracker* occlusion) OVERRIDE;
28 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; 25 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
29 26
27 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
28
29 // The |border| is the space around the center rectangular region in layer
30 // space (known as aperture in image space). |border.x()| and |border.y()|
31 // are the size of the left and top boundary, respectively.
32 // |border.width()-border.x()| and |border.height()-border.y()| are the size
33 // of the right and bottom boundary, respectively.
34 void SetBorder(gfx::Rect border);
35
30 // aperture is in the pixel space of the bitmap resource and refers to 36 // aperture is in the pixel space of the bitmap resource and refers to
31 // the center patch of the ninepatch (which is unused in this 37 // the center patch of the ninepatch (which is unused in this
32 // implementation). We split off eight rects surrounding it and stick them 38 // implementation). We split off eight rects surrounding it and stick them
33 // on the edges of the layer. The corners are unscaled, the top and bottom 39 // on the edges of the layer. The corners are unscaled, the top and bottom
34 // rects are x-stretched to fit, and the left and right rects are 40 // rects are x-stretched to fit, and the left and right rects are
35 // y-stretched to fit. 41 // y-stretched to fit.
36 void SetBitmap(const SkBitmap& bitmap, gfx::Rect aperture); 42 void SetBitmap(const SkBitmap& skbitmap, gfx::Rect aperture);
43
44 // An alternative way of setting bitmap to allow for sharing of resources.
45 void SetUIResourceId(UIResourceId resource_id,
46 gfx::Rect aperture,
47 bool fill_center);
aelias_OOO_until_Jul13 2013/08/30 06:20:41 Put this in a separate call SetFillCenter(bool); s
powei 2013/09/03 23:36:05 Done.
48
49 class UIResourceHolder {
50 public:
51 virtual UIResourceId id() = 0;
aelias_OOO_until_Jul13 2013/08/30 18:09:54 Thinking about it further I think you're on to som
aelias_OOO_until_Jul13 2013/08/30 19:02:40 Powei pointed out offline that this has problems w
powei 2013/09/03 23:36:05 Left it as is for now.
52 virtual ~UIResourceHolder();
53 };
37 54
38 private: 55 private:
39 NinePatchLayer(); 56 NinePatchLayer();
40 virtual ~NinePatchLayer(); 57 virtual ~NinePatchLayer();
41 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) 58 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
42 OVERRIDE; 59 OVERRIDE;
43 60
44 void CreateUpdaterIfNeeded(); 61 gfx::Rect border_;
45 void CreateResource(); 62 bool fill_center_;
46 63 scoped_ptr<UIResourceHolder> resource_;
aelias_OOO_until_Jul13 2013/08/30 06:20:41 Rename this to ui_resource_holder_
powei 2013/09/03 23:36:05 Done.
47 scoped_refptr<ImageLayerUpdater> updater_;
48 scoped_ptr<LayerUpdater::Resource> resource_;
49
50 SkBitmap bitmap_;
51 bool bitmap_dirty_;
52 64
53 // The transparent center region that shows the parent layer's contents in 65 // The transparent center region that shows the parent layer's contents in
54 // image space. 66 // image space.
55 gfx::Rect image_aperture_; 67 gfx::Rect image_aperture_;
56 68
57 DISALLOW_COPY_AND_ASSIGN(NinePatchLayer); 69 DISALLOW_COPY_AND_ASSIGN(NinePatchLayer);
58 }; 70 };
59 71
60 } // namespace cc 72 } // namespace cc
61 73
62 #endif // CC_LAYERS_NINE_PATCH_LAYER_H_ 74 #endif // CC_LAYERS_NINE_PATCH_LAYER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/layers/nine_patch_layer.cc » ('j') | cc/layers/nine_patch_layer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698