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/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/android/compositor/layer/layer.h" |
| 11 |
| 12 namespace cc { |
| 13 class UIResourceLayer; |
| 14 } |
| 15 |
| 16 namespace ui { |
| 17 class CrushedSpriteResource; |
| 18 class ResourceManager; |
| 19 } |
| 20 |
| 21 namespace chrome { |
| 22 namespace android { |
| 23 |
| 24 // A layer which manages drawing frames from a CrushedSpriteResource into an |
| 25 // SkCanvas backed by an SkBitmap. The final SkBitmap is passed to a |
| 26 // UIResourceLayer for display. |
| 27 class CrushedSpriteLayer : public Layer { |
| 28 public: |
| 29 static scoped_refptr<CrushedSpriteLayer> Create( |
| 30 ui::ResourceManager* resource_manager); |
| 31 |
| 32 // Draws the rectangles for |sprite_frame| on top of the previous frame and |
| 33 // sends to layer_ for display. |
| 34 void DrawSpriteFrame(scoped_refptr<ui::CrushedSpriteResource> resource, |
| 35 int sprite_frame); |
| 36 |
| 37 // Layer overrides. |
| 38 scoped_refptr<cc::Layer> layer() override; |
| 39 |
| 40 protected: |
| 41 explicit CrushedSpriteLayer(ui::ResourceManager* resource_manager); |
| 42 ~CrushedSpriteLayer() override; |
| 43 |
| 44 private: |
| 45 // Draws the rectangles for |frame| to |canvas|. |
| 46 void DrawRectanglesForFrame( |
| 47 scoped_refptr<ui::CrushedSpriteResource> resource, |
| 48 int frame, |
| 49 skia::RefPtr<SkCanvas> canvas); |
| 50 |
| 51 ui::ResourceManager* resource_manager_; |
| 52 scoped_refptr<cc::UIResourceLayer> layer_; |
| 53 int previous_frame_; |
| 54 SkBitmap previous_frame_bitmap_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(CrushedSpriteLayer); |
| 57 }; |
| 58 |
| 59 } // namespace android |
| 60 } // namespace chrome |
| 61 |
| 62 #endif // CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_CRUSHED_SPRITE_LAYER_H_ |
OLD | NEW |