Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: chrome/browser/android/compositor/layer/crushed_sprite_layer.h

Issue 1337703002: [Contextual Search] Add support for crushed sprites and animate the search provider icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes from newt@ review Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698