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