OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.ui.resources.sprites; | 5 package org.chromium.ui.resources.sprites; |
6 | 6 |
7 import android.content.res.Resources; | 7 import android.content.res.Resources; |
8 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
9 import android.graphics.BitmapFactory; | 9 import android.graphics.BitmapFactory; |
10 import android.graphics.Rect; | 10 import android.graphics.Rect; |
11 import android.util.JsonReader; | 11 import android.util.JsonReader; |
12 | 12 |
13 import org.chromium.base.TraceEvent; | 13 import org.chromium.base.TraceEvent; |
14 import org.chromium.base.VisibleForTesting; | 14 import org.chromium.base.VisibleForTesting; |
15 import org.chromium.ui.resources.Resource; | 15 import org.chromium.ui.resources.Resource; |
16 | 16 import org.chromium.ui.resources.statics.NinePatchData; |
17 | 17 |
18 import java.io.IOException; | 18 import java.io.IOException; |
19 import java.io.InputStream; | 19 import java.io.InputStream; |
20 import java.io.InputStreamReader; | 20 import java.io.InputStreamReader; |
21 import java.util.ArrayList; | 21 import java.util.ArrayList; |
22 | 22 |
23 /** | 23 /** |
24 * A {@link Resource} that provides an unscaled {@link Bitmap} and corresponding
metadata for a | 24 * A {@link Resource} that provides an unscaled {@link Bitmap} and corresponding
metadata for a |
25 * crushed sprite. A crushed sprite animation is run by drawing rectangles from
a bitmap to a | 25 * crushed sprite. A crushed sprite animation is run by drawing rectangles from
a bitmap to a |
26 * canvas. Each frame in the animation draws its rectangles on top of the previo
us frame. | 26 * canvas. Each frame in the animation draws its rectangles on top of the previo
us frame. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 public Bitmap getBitmap() { | 75 public Bitmap getBitmap() { |
76 return mBitmap; | 76 return mBitmap; |
77 } | 77 } |
78 | 78 |
79 @Override | 79 @Override |
80 public Rect getBitmapSize() { | 80 public Rect getBitmapSize() { |
81 return mBitmapSize; | 81 return mBitmapSize; |
82 } | 82 } |
83 | 83 |
84 @Override | 84 @Override |
85 public Rect getPadding() { | 85 public long createNativeResource() { |
86 return EMPTY_RECT; | 86 // TODO(khushalsagar): See if it makes sense to have the native CrushedS
priteResource |
| 87 // inherit from Resource and create that here. |
| 88 return 0; |
87 } | 89 } |
88 | 90 |
89 @Override | 91 @Override |
90 public Rect getAperture() { | 92 public NinePatchData getNinePatchData() { |
91 return EMPTY_RECT; | 93 return null; |
92 } | 94 } |
93 | 95 |
94 /** | 96 /** |
95 * @return The scaled width of an individual sprite in px. | 97 * @return The scaled width of an individual sprite in px. |
96 */ | 98 */ |
97 public float getScaledSpriteWidth() { | 99 public float getScaledSpriteWidth() { |
98 return mScaledSpriteWidth; | 100 return mScaledSpriteWidth; |
99 } | 101 } |
100 | 102 |
101 /** | 103 /** |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 for (int i = 0; i < frameCount; i++) { | 283 for (int i = 0; i < frameCount; i++) { |
282 ArrayList<Integer> frameRectangles = allFrameRectangles.get(i); | 284 ArrayList<Integer> frameRectangles = allFrameRectangles.get(i); |
283 int[] frameRectanglesArray = new int[frameRectangles.size()]; | 285 int[] frameRectanglesArray = new int[frameRectangles.size()]; |
284 for (int j = 0; j < frameRectangles.size(); j++) { | 286 for (int j = 0; j < frameRectangles.size(); j++) { |
285 frameRectanglesArray[j] = frameRectangles.get(j); | 287 frameRectanglesArray[j] = frameRectangles.get(j); |
286 } | 288 } |
287 mRectangles[i] = frameRectanglesArray; | 289 mRectangles[i] = frameRectanglesArray; |
288 } | 290 } |
289 } | 291 } |
290 } | 292 } |
OLD | NEW |