AMM: Add Bitmap model.
Includes a description of the bitmap model and sample loading of a
bitmap in AmmTest.apk.
Bug: 69729799
Test: AmmTest.apk builds and runs on device.
Change-Id: I3e39924c0d8fb77aa9633d09d2d3e0c2a2bb29d0
diff --git a/tools/amm/AmmTest/aahat.png b/tools/amm/AmmTest/aahat.png
new file mode 100644
index 0000000..01b92f4
--- /dev/null
+++ b/tools/amm/AmmTest/aahat.png
Binary files differ
diff --git a/tools/amm/AmmTest/src/com/android/amm/test/BitmapUse.java b/tools/amm/AmmTest/src/com/android/amm/test/BitmapUse.java
new file mode 100644
index 0000000..d8eba2e
--- /dev/null
+++ b/tools/amm/AmmTest/src/com/android/amm/test/BitmapUse.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.amm.test;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+
+/**
+ * Exercise loading of a bitmap.
+ */
+class BitmapUse {
+
+ private Bitmap mBitmap;
+
+ public BitmapUse() {
+ ClassLoader loader = BitmapUse.class.getClassLoader();
+ mBitmap = BitmapFactory.decodeStream(loader.getResourceAsStream("aahat.png"), null, null);
+ }
+}
diff --git a/tools/amm/AmmTest/src/com/android/amm/test/MainActivity.java b/tools/amm/AmmTest/src/com/android/amm/test/MainActivity.java
index 787f90e..895b5f9 100644
--- a/tools/amm/AmmTest/src/com/android/amm/test/MainActivity.java
+++ b/tools/amm/AmmTest/src/com/android/amm/test/MainActivity.java
@@ -21,9 +21,13 @@
public class MainActivity extends Activity {
+ private BitmapUse mBitmapUse;
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+
+ mBitmapUse = new BitmapUse();
}
}
diff --git a/tools/amm/Android.mk b/tools/amm/Android.mk
index dfbb7cf..134e5c1 100644
--- a/tools/amm/Android.mk
+++ b/tools/amm/Android.mk
@@ -19,6 +19,7 @@
LOCAL_PACKAGE_NAME := AmmTest
LOCAL_MODULE_TAGS := samples tests
LOCAL_SRC_FILES := $(call all-java-files-under, AmmTest/src)
+LOCAL_JAVA_RESOURCE_FILES := $(LOCAL_PATH)/AmmTest/aahat.png
LOCAL_MANIFEST_FILE := AmmTest/AndroidManifest.xml
include $(BUILD_PACKAGE)
diff --git a/tools/amm/models/Bitmap.md b/tools/amm/models/Bitmap.md
new file mode 100644
index 0000000..49a0b9d
--- /dev/null
+++ b/tools/amm/models/Bitmap.md
@@ -0,0 +1,15 @@
+# Bitmap Model
+
+The value of the Bitmap model is the sum of bytes used for native pixel data
+of instances of `android.graphics.Bitmap`. It is calculated by summing for
+each instance `x` of `android.graphics.Bitmap`:
+
+ x.getAllocationByteCount()
+
+The actionable breakdown of the Bitmap model is a breakdown by
+`android.graphics.Bitmap` instance, including width, height, and ideally a
+thumbnail image of each bitmap.
+
+For example, an 800 x 600 bitmap instance using the `ARGB_8888` pixel format
+with native pixel data will be shown as an 800 x 600 bitmap instance taking up
+1875 kB.