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

Unified Diff: content/public/android/java/src/org/chromium/content_public/resources/dynamics/BitmapDynamicResource.java

Issue 731133002: Upstream ResourceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add generated enum class to BUILD.gn Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698