 Chromium Code Reviews
 Chromium Code Reviews 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
    
  
    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| Index: ui/android/java/src/org/chromium/ui/resources/ResourceManager.java | 
| diff --git a/ui/android/java/src/org/chromium/ui/resources/ResourceManager.java b/ui/android/java/src/org/chromium/ui/resources/ResourceManager.java | 
| index d58bddacddde6f35bddbf11b20a3bcb6470034b3..b89e97f7c06613983d2d7547197fd9903de9ea2b 100644 | 
| --- a/ui/android/java/src/org/chromium/ui/resources/ResourceManager.java | 
| +++ b/ui/android/java/src/org/chromium/ui/resources/ResourceManager.java | 
| @@ -15,6 +15,8 @@ import org.chromium.base.annotations.JNINamespace; | 
| import org.chromium.ui.resources.ResourceLoader.ResourceLoaderCallback; | 
| import org.chromium.ui.resources.dynamics.DynamicResource; | 
| import org.chromium.ui.resources.dynamics.DynamicResourceLoader; | 
| +import org.chromium.ui.resources.sprites.CrushedSpriteResource; | 
| +import org.chromium.ui.resources.sprites.CrushedSpriteResourceLoader; | 
| import org.chromium.ui.resources.statics.StaticResourceLoader; | 
| import org.chromium.ui.resources.system.SystemResourceLoader; | 
| @@ -27,6 +29,7 @@ public class ResourceManager implements ResourceLoaderCallback { | 
| private final SparseArray<ResourceLoader> mResourceLoaders = new SparseArray<ResourceLoader>(); | 
| private final SparseArray<SparseArray<LayoutResource>> mLoadedResources = | 
| new SparseArray<SparseArray<LayoutResource>>(); | 
| + private final CrushedSpriteResourceLoader mCrushedSpriteResourceLoader; | 
| private final float mPxToDp; | 
| @@ -45,6 +48,7 @@ public class ResourceManager implements ResourceLoaderCallback { | 
| AndroidResourceType.DYNAMIC_BITMAP, this)); | 
| registerResourceLoader(new SystemResourceLoader( | 
| AndroidResourceType.SYSTEM, this, context)); | 
| + mCrushedSpriteResourceLoader = new CrushedSpriteResourceLoader(this, resources); | 
| mNativeResourceManagerPtr = staticResourceManagerPtr; | 
| } | 
| @@ -110,9 +114,19 @@ public class ResourceManager implements ResourceLoaderCallback { | 
| return bucket != null ? bucket.get(resId) : null; | 
| } | 
| + @SuppressWarnings("cast") | 
| @Override | 
| public void onResourceLoaded(int resType, int resId, Resource resource) { | 
| if (resource == null) return; | 
| + if (resType == AndroidResourceType.CRUSHED_SPRITE) { | 
| 
David Trainor- moved to gerrit
2015/10/15 21:04:57
Put this down below the if (mNativeResourceManager
 
Theresa
2015/10/24 00:06:45
Done.
 | 
| + if (resource.getBitmap() != null) { | 
| + CrushedSpriteResource crushedResource = (CrushedSpriteResource) resource; | 
| + nativeOnCrushedSpriteResourceReady(mNativeResourceManagerPtr, resId, | 
| + crushedResource.getBitmap(), crushedResource.getFrameRectangles(), | 
| + crushedResource.getSpriteSize()); | 
| + } | 
| + return; | 
| + } | 
| saveMetadataForLoadedResource(resType, resId, resource); | 
| @@ -153,6 +167,19 @@ public class ResourceManager implements ResourceLoaderCallback { | 
| } | 
| @CalledByNative | 
| + private void crushedSpriteResourceRequested(int bitmapResId, int metatadataResId) { | 
| + mCrushedSpriteResourceLoader.loadResource(bitmapResId, metatadataResId); | 
| + } | 
| + | 
| + @CalledByNative | 
| + private void reloadCrushedSpriteResource(int bitmapResId) { | 
| 
David Trainor- moved to gerrit
2015/10/15 21:04:57
Can we just do crushedSpriteResourceRequested()?
 
Theresa
2015/10/24 00:06:45
The implementation is completely different. reload
 
David Trainor- moved to gerrit
2015/10/27 15:14:47
I was hoping we could hide the difference internal
 
Theresa
2015/10/27 19:48:02
I dropped this method and added a boolean to crush
 | 
| + Bitmap bitmap = mCrushedSpriteResourceLoader.reloadResource(bitmapResId); | 
| + if (bitmap != null) { | 
| + nativeOnCrushedSpriteResourceReloaded(mNativeResourceManagerPtr, bitmapResId, bitmap); | 
| + } | 
| + } | 
| + | 
| + @CalledByNative | 
| private long getNativePtr() { | 
| return mNativeResourceManagerPtr; | 
| } | 
| @@ -165,5 +192,9 @@ public class ResourceManager implements ResourceLoaderCallback { | 
| int resId, Bitmap bitmap, int paddingLeft, int paddingTop, int paddingRight, | 
| int paddingBottom, int apertureLeft, int apertureTop, int apertureRight, | 
| int apertureBottom); | 
| + private native void nativeOnCrushedSpriteResourceReady(long nativeResourceManagerImpl, | 
| + int bitmapResId, Bitmap bitmap, int[][] frameRects, int spriteSize); | 
| + private native void nativeOnCrushedSpriteResourceReloaded(long nativeResourceManagerImpl, | 
| + int bitmapResId, Bitmap bitmap); | 
| } |