OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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; | 5 package org.chromium.ui.resources; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.res.Resources; | 8 import android.content.res.Resources; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.graphics.Rect; | |
11 import android.util.SparseArray; | 10 import android.util.SparseArray; |
12 | 11 |
13 import org.chromium.base.annotations.CalledByNative; | 12 import org.chromium.base.annotations.CalledByNative; |
14 import org.chromium.base.annotations.JNINamespace; | 13 import org.chromium.base.annotations.JNINamespace; |
15 import org.chromium.base.annotations.MainDex; | 14 import org.chromium.base.annotations.MainDex; |
16 import org.chromium.ui.base.WindowAndroid; | 15 import org.chromium.ui.base.WindowAndroid; |
17 import org.chromium.ui.display.DisplayAndroid; | 16 import org.chromium.ui.display.DisplayAndroid; |
18 import org.chromium.ui.resources.ResourceLoader.ResourceLoaderCallback; | 17 import org.chromium.ui.resources.ResourceLoader.ResourceLoaderCallback; |
| 18 import org.chromium.ui.resources.dynamics.BitmapDynamicResource; |
19 import org.chromium.ui.resources.dynamics.DynamicResource; | 19 import org.chromium.ui.resources.dynamics.DynamicResource; |
20 import org.chromium.ui.resources.dynamics.DynamicResourceLoader; | 20 import org.chromium.ui.resources.dynamics.DynamicResourceLoader; |
21 import org.chromium.ui.resources.sprites.CrushedSpriteResource; | 21 import org.chromium.ui.resources.sprites.CrushedSpriteResource; |
22 import org.chromium.ui.resources.sprites.CrushedSpriteResourceLoader; | 22 import org.chromium.ui.resources.sprites.CrushedSpriteResourceLoader; |
23 import org.chromium.ui.resources.statics.StaticResourceLoader; | 23 import org.chromium.ui.resources.statics.StaticResourceLoader; |
24 import org.chromium.ui.resources.system.SystemResourceLoader; | 24 import org.chromium.ui.resources.system.SystemResourceLoader; |
25 | 25 |
26 /** | 26 /** |
27 * The Java component of a manager for all static resources to be loaded and use
d by CC layers. | 27 * The Java component of a manager for all static resources to be loaded and use
d by CC layers. |
28 * This class does not hold any resource state, but passes it directly to native
as they are loaded. | 28 * This class does not hold any resource state, but passes it directly to native
as they are loaded. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 nativeOnCrushedSpriteResourceReady(mNativeResourceManagerPtr, re
sId, | 152 nativeOnCrushedSpriteResourceReady(mNativeResourceManagerPtr, re
sId, |
153 crushedResource.getBitmap(), crushedResource.getFrameRec
tangles(), | 153 crushedResource.getBitmap(), crushedResource.getFrameRec
tangles(), |
154 crushedResource.getUnscaledSpriteWidth(), | 154 crushedResource.getUnscaledSpriteWidth(), |
155 crushedResource.getUnscaledSpriteHeight(), | 155 crushedResource.getUnscaledSpriteHeight(), |
156 crushedResource.getScaledSpriteWidth(), | 156 crushedResource.getScaledSpriteWidth(), |
157 crushedResource.getScaledSpriteHeight()); | 157 crushedResource.getScaledSpriteHeight()); |
158 } | 158 } |
159 return; | 159 return; |
160 } | 160 } |
161 | 161 |
162 Rect padding = resource.getPadding(); | |
163 Rect aperture = resource.getAperture(); | |
164 | |
165 nativeOnResourceReady(mNativeResourceManagerPtr, resType, resId, resourc
e.getBitmap(), | 162 nativeOnResourceReady(mNativeResourceManagerPtr, resType, resId, resourc
e.getBitmap(), |
166 padding.left, padding.top, padding.right, padding.bottom, | 163 resource.createNativeResource()); |
167 aperture.left, aperture.top, aperture.right, aperture.bottom); | |
168 } | 164 } |
169 | 165 |
170 @Override | 166 @Override |
171 public void onResourceUnregistered(int resType, int resId) { | 167 public void onResourceUnregistered(int resType, int resId) { |
172 // Only remove dynamic bitmaps that were unregistered. | 168 // Only remove dynamic bitmaps that were unregistered. |
173 if (resType != AndroidResourceType.DYNAMIC_BITMAP) return; | 169 if (resType != AndroidResourceType.DYNAMIC_BITMAP) return; |
174 | 170 |
175 nativeRemoveResource(mNativeResourceManagerPtr, resType, resId); | 171 nativeRemoveResource(mNativeResourceManagerPtr, resType, resId); |
176 } | 172 } |
177 | 173 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 @CalledByNative | 223 @CalledByNative |
228 private long getNativePtr() { | 224 private long getNativePtr() { |
229 return mNativeResourceManagerPtr; | 225 return mNativeResourceManagerPtr; |
230 } | 226 } |
231 | 227 |
232 private void registerResourceLoader(ResourceLoader loader) { | 228 private void registerResourceLoader(ResourceLoader loader) { |
233 mResourceLoaders.put(loader.getResourceType(), loader); | 229 mResourceLoaders.put(loader.getResourceType(), loader); |
234 } | 230 } |
235 | 231 |
236 private native void nativeOnResourceReady(long nativeResourceManagerImpl, in
t resType, | 232 private native void nativeOnResourceReady(long nativeResourceManagerImpl, in
t resType, |
237 int resId, Bitmap bitmap, int paddingLeft, int paddingTop, int paddi
ngRight, | 233 int resId, Bitmap bitmap, long nativeResource); |
238 int paddingBottom, int apertureLeft, int apertureTop, int apertureRi
ght, | |
239 int apertureBottom); | |
240 private native void nativeOnCrushedSpriteResourceReady(long nativeResourceMa
nagerImpl, | 234 private native void nativeOnCrushedSpriteResourceReady(long nativeResourceMa
nagerImpl, |
241 int bitmapResId, Bitmap bitmap, int[][] frameRects, int unscaledSpri
teWidth, | 235 int bitmapResId, Bitmap bitmap, int[][] frameRects, int unscaledSpri
teWidth, |
242 int unscaledSpriteHeight, float scaledSpriteWidth, float scaledSprit
eHeight); | 236 int unscaledSpriteHeight, float scaledSpriteWidth, float scaledSprit
eHeight); |
243 private native void nativeOnCrushedSpriteResourceReloaded(long nativeResourc
eManagerImpl, | 237 private native void nativeOnCrushedSpriteResourceReloaded(long nativeResourc
eManagerImpl, |
244 int bitmapResId, Bitmap bitmap); | 238 int bitmapResId, Bitmap bitmap); |
245 private native void nativeRemoveResource(long nativeResourceManagerImpl, int
resType, | 239 private native void nativeRemoveResource(long nativeResourceManagerImpl, int
resType, |
246 int resId); | 240 int resId); |
247 private native void nativeClearTintedResourceCache(long nativeResourceManage
rImpl); | 241 private native void nativeClearTintedResourceCache(long nativeResourceManage
rImpl); |
248 | |
249 } | 242 } |
OLD | NEW |