Chromium Code Reviews| Index: chrome/browser/android/compositor/layer/crushed_sprite_layer.h |
| diff --git a/chrome/browser/android/compositor/layer/crushed_sprite_layer.h b/chrome/browser/android/compositor/layer/crushed_sprite_layer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..88fc9ecddbf37560e86e5b0120716ec90d29e727 |
| --- /dev/null |
| +++ b/chrome/browser/android/compositor/layer/crushed_sprite_layer.h |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_CRUSHED_SPRITE_LAYER_H_ |
| +#define CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_CRUSHED_SPRITE_LAYER_H_ |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "cc/layers/content_layer_client.h" |
| +#include "chrome/browser/android/compositor/layer/layer.h" |
| +#include "ui/gfx/geometry/rect.h" |
| + |
| +namespace cc { |
| +class ContentLayerClient; |
| +class Layer; |
| +class PictureLayer; |
| +} |
| + |
| +namespace chrome { |
| +namespace android { |
| + |
| +// A layer which manages painting source rectangles from a crushed sprite sheet |
| +// into a PictureLayer. The frames in a crushed sprite sheet are represented by |
| +// a set of rectangles. Most frames consist of small rectangles representing the |
| +// change from the previous frame. Typically, the rectangles for the current |
| +// frame get painted on top of the previous frame. |
| +class CrushedSpriteLayer : public Layer, cc::ContentLayerClient { |
| + public: |
| + static scoped_refptr<CrushedSpriteLayer> Create(); |
| + |
| + // Sets the source bitmap and source and destination rectangles. Source |
| + // rectangles from the source bitmap are painted to the destination |
| + // rectangles. |paint_previous_frame| should be true if the current frame's |
| + // rectangles should be painted on top of the previous frame. |
| + void UpdateCrushedSprite( |
| + const SkBitmap& src_bitmap, |
| + const std::vector<std::pair<gfx::Rect, gfx::Rect>>& src_dst_rects, |
| + bool paint_previous_frame); |
| + |
| + // Layer override. |
| + scoped_refptr<cc::Layer> layer() override; |
| + |
| + // ContentLayerClient implementation. |
| + void PaintContents(SkCanvas* canvas, |
| + const gfx::Rect& clip, |
| + PaintingControlSetting painting_control) override; |
| + scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList( |
| + const gfx::Rect& clip, |
| + PaintingControlSetting painting_control) override; |
| + bool FillsBoundsCompletely() const override; |
| + size_t GetApproximateUnsharedMemoryUsage() const override; |
| + |
| + protected: |
| + CrushedSpriteLayer(); |
| + ~CrushedSpriteLayer() override; |
| + |
| + private: |
| + 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
|
| + bool paint_previous_frame_; |
| + skia::RefPtr<SkPicture> previous_frame_; |
| + SkBitmap src_bitmap_; |
| + std::vector<std::pair<gfx::Rect, gfx::Rect>> src_dst_rects_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CrushedSpriteLayer); |
| +}; |
| + |
| +} // namespace android |
| +} // namespace chrome |
| + |
| +#endif // CHROME_BROWSER_ANDROID_COMPOSITOR_LAYER_CRUSHED_SPRITE_LAYER_H_ |