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

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: Add TODO's for other planned tests 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..840852f9e89d9894e66fca1979a080323acb63ad
--- /dev/null
+++ b/ui/android/resources/crushed_sprite_resource.cc
@@ -0,0 +1,81 @@
+// 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"
+
+namespace ui {
+
+// static
+scoped_refptr<CrushedSpriteResource>
+CrushedSpriteResource::CreateFromJavaBitmap(
+ int bitmap_res_id,
+ const gfx::JavaBitmap& java_bitmap,
+ const SrcDstRects& src_dst_rects,
+ int sprite_size) {
David Trainor- moved to gerrit 2015/10/15 21:04:57 Should this be an int? Shouldn't it be a gfx::Siz
Theresa 2015/10/24 00:06:45 I changed it to gfx::Size. Currently the sprites a
+ SkBitmap bitmap = gfx::CreateSkBitmapFromJavaBitmap(java_bitmap);
+ bitmap.setImmutable();
+
+ return make_scoped_refptr(new CrushedSpriteResource(bitmap_res_id,
+ bitmap,
+ src_dst_rects,
+ sprite_size));
+}
+
+void CrushedSpriteResource::SetBitmapFromJavaBitmap(
+ const gfx::JavaBitmap& java_bitmap) {
+ SkBitmap bitmap = gfx::CreateSkBitmapFromJavaBitmap(java_bitmap);
+ bitmap.setImmutable();
+ bitmap_ = bitmap;
+}
+
+SkBitmap CrushedSpriteResource::GetBitmap() {
+ DCHECK(!bitmap_.empty());
+ return bitmap_;
+}
+
+void CrushedSpriteResource::SetBitmapForLastFrame(SkBitmap last_frame_bitmap) {
+ last_frame_bitmap_ = last_frame_bitmap;
+ bitmap_.reset();
+}
+
+SkBitmap CrushedSpriteResource::GetBitmapForLastFrame() {
+ return last_frame_bitmap_;
+}
+
+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];
+}
+
+int CrushedSpriteResource::GetSpriteSize() {
+ return sprite_size_;
+}
+
+int CrushedSpriteResource::GetFrameCount() {
+ return src_dst_rects_.size();
+}
+
+int CrushedSpriteResource::GetBitmapResourceId() {
+ return bitmap_res_id_;
+}
+
+CrushedSpriteResource::CrushedSpriteResource(
+ int bitmap_res_id,
+ const SkBitmap& bitmap,
+ const SrcDstRects& src_dst_rects,
+ int sprite_size)
+ : bitmap_(bitmap), src_dst_rects_(src_dst_rects),
+ sprite_size_(sprite_size), bitmap_res_id_(bitmap_res_id) {
+}
+
+
+CrushedSpriteResource::~CrushedSpriteResource() {
+}
+
+} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698