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

Unified Diff: ui/android/resources/crushed_sprite_resource.cc

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: Very small changes from last pedrosimonneti@ review Created 5 years, 2 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: ui/android/resources/crushed_sprite_resource.cc
diff --git a/ui/android/resources/crushed_sprite_resource.cc b/ui/android/resources/crushed_sprite_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..becc0db06beaf988caf08dbde4ee301f315c169a
--- /dev/null
+++ b/ui/android/resources/crushed_sprite_resource.cc
@@ -0,0 +1,57 @@
+// 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.
+
+#include "ui/android/resources/crushed_sprite_resource.h"
+
+#include "cc/resources/scoped_ui_resource.h"
+#include "cc/trees/layer_tree_host.h"
+#include "ui/gfx/android/java_bitmap.h"
+
+namespace ui {
+
+CrushedSpriteResource::CrushedSpriteResource(
+ const SkBitmap& bitmap,
+ const SrcDstRects& src_dst_rects,
+ gfx::Size sprite_size)
+ : src_dst_rects_(src_dst_rects),
+ sprite_size_(sprite_size) {
+ SetBitmap(bitmap);
+}
+
+CrushedSpriteResource::~CrushedSpriteResource() {
+}
+
+void CrushedSpriteResource::SetBitmap(const SkBitmap& bitmap) {
+ bitmap_ = bitmap;
+ bitmap_.setImmutable();
+}
+
+const SkBitmap& CrushedSpriteResource::GetBitmap() {
+ DCHECK(!bitmap_.empty());
+ return bitmap_;
+}
+
+void CrushedSpriteResource::EvictBitmapFromMemory() {
+ bitmap_.reset();
+}
+
+bool CrushedSpriteResource::BitmapHasBeenEvictedFromMemory() {
+ return bitmap_.empty();
+}
+
+CrushedSpriteResource::FrameSrcDstRects
+CrushedSpriteResource::GetRectanglesForFrame(int frame) {
+ DCHECK(frame >= 0 && frame < static_cast<int>(src_dst_rects_.size()));
+ return src_dst_rects_[frame];
+}
+
+gfx::Size CrushedSpriteResource::GetSpriteSize() {
+ return sprite_size_;
+}
+
+int CrushedSpriteResource::GetFrameCount() {
+ return src_dst_rects_.size();
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698