Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 class LayerTreeHost; |
| 17 class ResourceUpdateQueue; | 16 class ScopedUIResource; |
| 18 | 17 |
| 19 class CC_EXPORT NinePatchLayer : public Layer { | 18 class CC_EXPORT NinePatchLayer : public Layer { |
| 19 private: | |
| 20 class Resource { | |
|
aelias_OOO_until_Jul13
2013/08/28 22:28:29
Rename this UIResourceHolder and put it in the bel
powei
2013/08/30 05:17:15
Renamed it.
Correct me if I'm wrong, but if the
| |
| 21 public: | |
| 22 virtual UIResourceId id() = 0; | |
|
aelias_OOO_until_Jul13
2013/08/28 22:28:29
This should have a virtual destructor as well.
powei
2013/08/30 05:17:15
Done.
| |
| 23 }; | |
| 24 | |
| 25 class ScopedResource : public Resource { | |
|
aelias_OOO_until_Jul13
2013/08/28 22:28:29
These two implementation classes can go in the .cc
powei
2013/08/30 05:17:15
Done.
| |
| 26 public: | |
| 27 static scoped_ptr<ScopedResource> Create(LayerTreeHost* host, | |
| 28 const SkBitmap& skbitmap); | |
| 29 virtual UIResourceId id() OVERRIDE; | |
| 30 | |
| 31 private: | |
| 32 ScopedResource(LayerTreeHost* host, const SkBitmap& skbitmap); | |
| 33 scoped_ptr<ScopedUIResource> resource_; | |
| 34 }; | |
| 35 | |
| 36 class SharedResource : public Resource { | |
| 37 public: | |
| 38 static scoped_ptr<SharedResource> Create(UIResourceId id); | |
| 39 virtual UIResourceId id() OVERRIDE; | |
| 40 | |
| 41 private: | |
| 42 explicit SharedResource(UIResourceId id); | |
| 43 UIResourceId id_; | |
| 44 }; | |
| 45 | |
| 20 public: | 46 public: |
| 21 static scoped_refptr<NinePatchLayer> Create(); | 47 static scoped_refptr<NinePatchLayer> Create(); |
| 22 | 48 |
| 23 virtual bool DrawsContent() const OVERRIDE; | 49 virtual bool DrawsContent() const OVERRIDE; |
| 24 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) | 50 |
| 25 OVERRIDE; | |
| 26 virtual bool Update(ResourceUpdateQueue* queue, | |
| 27 const OcclusionTracker* occlusion) OVERRIDE; | |
| 28 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | 51 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; |
| 29 | 52 |
| 53 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; | |
| 54 | |
| 55 void SetBorder(gfx::Rect border); | |
|
aelias_OOO_until_Jul13
2013/08/28 22:28:29
Please write a comment explaining this.
powei
2013/08/30 05:17:15
Done.
| |
| 30 // aperture is in the pixel space of the bitmap resource and refers to | 56 // 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 | 57 // the center patch of the ninepatch (which is unused in this |
| 32 // implementation). We split off eight rects surrounding it and stick them | 58 // 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 | 59 // 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 | 60 // rects are x-stretched to fit, and the left and right rects are |
| 35 // y-stretched to fit. | 61 // y-stretched to fit. |
| 36 void SetBitmap(const SkBitmap& bitmap, gfx::Rect aperture); | 62 void SetBitmap(const SkBitmap& skbitmap, gfx::Rect aperture); |
| 63 | |
| 64 // An alternative way of setting bitmap to allow for sharing of resources. | |
| 65 void SetSharedBitmap(UIResourceId resource_id, | |
|
aelias_OOO_until_Jul13
2013/08/28 22:28:29
Rename to SetUIResourceId
powei
2013/08/30 05:17:15
Done.
| |
| 66 gfx::Rect aperture, | |
| 67 bool fill_center); | |
| 37 | 68 |
| 38 private: | 69 private: |
| 39 NinePatchLayer(); | 70 NinePatchLayer(); |
| 40 virtual ~NinePatchLayer(); | 71 virtual ~NinePatchLayer(); |
| 41 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 72 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
| 42 OVERRIDE; | 73 OVERRIDE; |
| 43 | 74 |
| 44 void CreateUpdaterIfNeeded(); | 75 gfx::Rect border_; |
| 45 void CreateResource(); | 76 bool fill_center_; |
| 46 | 77 scoped_ptr<Resource> resource_; |
| 47 scoped_refptr<ImageLayerUpdater> updater_; | |
| 48 scoped_ptr<LayerUpdater::Resource> resource_; | |
| 49 | |
| 50 SkBitmap bitmap_; | |
| 51 bool bitmap_dirty_; | |
| 52 | 78 |
| 53 // The transparent center region that shows the parent layer's contents in | 79 // The transparent center region that shows the parent layer's contents in |
| 54 // image space. | 80 // image space. |
| 55 gfx::Rect image_aperture_; | 81 gfx::Rect image_aperture_; |
| 56 | 82 |
| 57 DISALLOW_COPY_AND_ASSIGN(NinePatchLayer); | 83 DISALLOW_COPY_AND_ASSIGN(NinePatchLayer); |
| 58 }; | 84 }; |
| 59 | 85 |
| 60 } // namespace cc | 86 } // namespace cc |
| 61 | 87 |
| 62 #endif // CC_LAYERS_NINE_PATCH_LAYER_H_ | 88 #endif // CC_LAYERS_NINE_PATCH_LAYER_H_ |
| OLD | NEW |