OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 |
| 5 #ifndef CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_CRUSHED_SPRITE_LAYER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_CRUSHED_SPRITE_LAYER_H_ |
| 7 |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "cc/layers/content_layer_client.h" |
| 10 #include "cc/layers/picture_layer.h" |
| 11 #include "ui/gfx/geometry/rect.h" |
| 12 |
| 13 namespace cc { |
| 14 class ContentLayerClient; |
| 15 class PictureLayer; |
| 16 } |
| 17 |
| 18 namespace chrome { |
| 19 namespace android { |
| 20 |
| 21 // A layer which manages painting source rectangles from a crushed sprite sheet |
| 22 // into a PictureLayer. The frames in a crushed sprite sheet are represented by |
| 23 // a set of rectangles. Most frames consist of small rectangles representing the |
| 24 // change from the previous frame. Typically, the rectangles for the current |
| 25 // frame get painted on top of the previous frame. |
| 26 class CrushedSpriteLayer : public cc::PictureLayer, cc::ContentLayerClient { |
| 27 public: |
| 28 static scoped_refptr<CrushedSpriteLayer> Create(); |
| 29 |
| 30 // Sets the source bitmap and source and destination rectangles. Source |
| 31 // rectangles from the source bitmap are painted to the destination |
| 32 // rectangles. |paint_previous_frame| should be true if the current frame's |
| 33 // rectangles should be painted on top of the previous frame. |
| 34 void UpdateCrushedSprite( |
| 35 const SkBitmap& src_bitmap, |
| 36 const std::vector<std::pair<gfx::Rect, gfx::Rect>>& src_dst_rects, |
| 37 bool paint_previous_frame); |
| 38 |
| 39 // ContentLayerClient implementation. |
| 40 void PaintContents(SkCanvas* canvas, |
| 41 const gfx::Rect& clip, |
| 42 PaintingControlSetting painting_control) override; |
| 43 scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( |
| 44 const gfx::Rect& clip, |
| 45 PaintingControlSetting painting_control) override; |
| 46 bool FillsBoundsCompletely() const override; |
| 47 size_t GetApproximateUnsharedMemoryUsage() const override; |
| 48 |
| 49 protected: |
| 50 CrushedSpriteLayer(); |
| 51 ~CrushedSpriteLayer() override; |
| 52 |
| 53 private: |
| 54 bool paint_previous_frame_; |
| 55 skia::RefPtr<SkPicture> previous_frame_; |
| 56 SkBitmap src_bitmap_; |
| 57 std::vector<std::pair<gfx::Rect, gfx::Rect>> src_dst_rects_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(CrushedSpriteLayer); |
| 60 }; |
| 61 |
| 62 } // namespace android |
| 63 } // namespace chrome |
| 64 |
| 65 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_CRUSHED_SPRITE_LAYER_H_ |
OLD | NEW |