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

Side by Side Diff: ui/android/resources/crushed_sprite_resource.cc

Issue 2798123002: Remove crushed sprite resource and layer (Closed)
Patch Set: Rebase and fix my nits Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « ui/android/resources/crushed_sprite_resource.h ('k') | ui/android/resources/resource_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "ui/android/resources/crushed_sprite_resource.h"
6
7 #include "cc/trees/layer_tree_host.h"
8 #include "ui/gfx/android/java_bitmap.h"
9
10 namespace ui {
11
12 CrushedSpriteResource::CrushedSpriteResource(
13 const SkBitmap& bitmap,
14 const SrcDstRects& src_dst_rects,
15 gfx::Size unscaled_sprite_size,
16 gfx::Size scaled_sprite_size)
17 : src_dst_rects_(src_dst_rects),
18 unscaled_sprite_size_(unscaled_sprite_size),
19 scaled_sprite_size_(scaled_sprite_size) {
20 SetBitmap(bitmap);
21 }
22
23 CrushedSpriteResource::~CrushedSpriteResource() {
24 }
25
26 void CrushedSpriteResource::SetBitmap(const SkBitmap& bitmap) {
27 bitmap_ = bitmap;
28 bitmap_.setImmutable();
29 }
30
31 const SkBitmap& CrushedSpriteResource::GetBitmap() {
32 DCHECK(!bitmap_.empty());
33 return bitmap_;
34 }
35
36 void CrushedSpriteResource::EvictBitmapFromMemory() {
37 bitmap_.reset();
38 }
39
40 bool CrushedSpriteResource::BitmapHasBeenEvictedFromMemory() {
41 return bitmap_.empty();
42 }
43
44 CrushedSpriteResource::FrameSrcDstRects
45 CrushedSpriteResource::GetRectanglesForFrame(int frame) {
46 DCHECK(frame >= 0 && frame < static_cast<int>(src_dst_rects_.size()));
47 return src_dst_rects_[frame];
48 }
49
50 gfx::Size CrushedSpriteResource::GetUnscaledSpriteSize() {
51 return unscaled_sprite_size_;
52 }
53
54 gfx::Size CrushedSpriteResource::GetScaledSpriteSize() {
55 return scaled_sprite_size_;
56 }
57
58 int CrushedSpriteResource::GetFrameCount() {
59 return src_dst_rects_.size();
60 }
61
62 size_t CrushedSpriteResource::EstimateMemoryUsage() const {
63 return bitmap_.getSize();
64 }
65
66 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/resources/crushed_sprite_resource.h ('k') | ui/android/resources/resource_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698