Index: content/public/android/java/src/org/chromium/content_public/resources/dynamics/BitmapDynamicResource.java |
diff --git a/content/public/android/java/src/org/chromium/content_public/resources/dynamics/BitmapDynamicResource.java b/content/public/android/java/src/org/chromium/content_public/resources/dynamics/BitmapDynamicResource.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c5fe2d0689075d620e5e6cd0f5045c7f0c3892c2 |
--- /dev/null |
+++ b/content/public/android/java/src/org/chromium/content_public/resources/dynamics/BitmapDynamicResource.java |
@@ -0,0 +1,65 @@ |
+// Copyright 2014 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. |
+ |
+package org.chromium.content_public.resources.dynamics; |
+ |
+import android.graphics.Bitmap; |
+import android.graphics.Rect; |
+ |
+/** |
+ * A basic implementation of {@link DynamicResource} to handle updatable bitmaps. |
+ */ |
+public class BitmapDynamicResource implements DynamicResource { |
+ private final int mResId; |
David Trainor- moved to gerrit
2014/11/18 18:53:53
Storing the resId feels implementation specific (i
Jaekyun Seok (inactive)
2014/11/18 23:34:02
I will do that later.
|
+ private Bitmap mBitmap; |
+ private Rect mSize = new Rect(); |
David Trainor- moved to gerrit
2014/11/18 18:53:53
This should be final so we can't call new again an
Jaekyun Seok (inactive)
2014/11/18 23:34:02
Done.
|
+ private static final Rect EMPTY_RECT = new Rect(); |
David Trainor- moved to gerrit
2014/11/18 18:53:53
Static should go up top (sorry I missed that downs
Jaekyun Seok (inactive)
2014/11/18 23:34:02
Done.
|
+ private boolean mIsDirty = true; |
+ |
+ public BitmapDynamicResource(int resourceId) { |
+ mResId = resourceId; |
+ } |
+ |
+ /** |
+ * @return A unique id for this resource. |
+ */ |
+ public int getResId() { |
+ return mResId; |
+ } |
+ |
+ /** |
+ * @param bitmap A bitmap to update this resource. |
+ */ |
+ public void setBitmap(Bitmap bitmap) { |
+ mIsDirty = true; |
+ mBitmap = bitmap; |
+ mSize.set(0, 0, mBitmap.getWidth(), mBitmap.getHeight()); |
+ } |
+ |
+ @Override |
+ public Bitmap getBitmap() { |
+ mIsDirty = false; |
+ return mBitmap; |
+ } |
+ |
+ @Override |
+ public Rect getBitmapSize() { |
+ return mSize; |
+ } |
+ |
+ @Override |
+ public Rect getPadding() { |
+ return EMPTY_RECT; |
+ } |
+ |
+ @Override |
+ public Rect getAperture() { |
+ return EMPTY_RECT; |
+ } |
+ |
+ @Override |
+ public boolean isDirty() { |
+ return mIsDirty; |
+ } |
+} |