Chromium Code Reviews| 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 "chrome/browser/android/compositor/layer/layer.h" | |
| 11 #include "ui/gfx/geometry/rect.h" | |
| 12 | |
| 13 namespace cc { | |
| 14 class ContentLayerClient; | |
| 15 class Layer; | |
| 16 class PictureLayer; | |
| 17 } | |
| 18 | |
| 19 namespace chrome { | |
| 20 namespace android { | |
| 21 | |
| 22 // A layer which manages painting source rectangles from a crushed sprite sheet | |
| 23 // into a PictureLayer. The frames in a crushed sprite sheet are represented by | |
| 24 // a set of rectangles. Most frames consist of small rectangles representing the | |
| 25 // change from the previous frame. Typically, the rectangles for the current | |
| 26 // frame get painted on top of the previous frame. | |
| 27 class CrushedSpriteLayer : public Layer, cc::ContentLayerClient { | |
| 28 public: | |
| 29 static scoped_refptr<CrushedSpriteLayer> Create(); | |
| 30 | |
| 31 // Sets the source bitmap and source and destination rectangles. Source | |
| 32 // rectangles from the source bitmap are painted to the destination | |
| 33 // rectangles. |paint_previous_frame| should be true if the current frame's | |
| 34 // rectangles should be painted on top of the previous frame. | |
| 35 void UpdateCrushedSprite( | |
| 36 const SkBitmap& src_bitmap, | |
| 37 const std::vector<std::pair<gfx::Rect, gfx::Rect>>& src_dst_rects, | |
| 38 bool paint_previous_frame); | |
| 39 | |
| 40 // Layer override. | |
| 41 scoped_refptr<cc::Layer> layer() override; | |
| 42 | |
| 43 // ContentLayerClient implementation. | |
| 44 void PaintContents(SkCanvas* canvas, | |
| 45 const gfx::Rect& clip, | |
| 46 PaintingControlSetting painting_control) override; | |
| 47 scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( | |
| 48 const gfx::Rect& clip, | |
| 49 PaintingControlSetting painting_control) override; | |
| 50 bool FillsBoundsCompletely() const override; | |
| 51 size_t GetApproximateUnsharedMemoryUsage() const override; | |
| 52 | |
| 53 protected: | |
| 54 CrushedSpriteLayer(); | |
| 55 ~CrushedSpriteLayer() override; | |
| 56 | |
| 57 private: | |
| 58 scoped_refptr<cc::PictureLayer> layer_; | |
|
pedro (no code reviews)
2015/09/30 16:02:46
Sorry I didn't notice this before, but it feels we
Theresa
2015/10/01 01:57:31
PictureImageLayer's constructor is private, so ext
| |
| 59 bool paint_previous_frame_; | |
| 60 skia::RefPtr<SkPicture> previous_frame_; | |
| 61 SkBitmap src_bitmap_; | |
| 62 std::vector<std::pair<gfx::Rect, gfx::Rect>> src_dst_rects_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(CrushedSpriteLayer); | |
| 65 }; | |
| 66 | |
| 67 } // namespace android | |
| 68 } // namespace chrome | |
| 69 | |
| 70 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_CRUSHED_SPRITE_LAYER_H_ | |
| OLD | NEW |