1 package org.robolectric.shadows; 2 3 import static android.os.Build.VERSION_CODES.LOLLIPOP; 4 import static android.os.Build.VERSION_CODES.O; 5 import static android.os.Build.VERSION_CODES.P; 6 7 import android.graphics.Bitmap; 8 import android.graphics.Bitmap.Config; 9 import android.view.ThreadedRenderer; 10 import org.robolectric.annotation.Implementation; 11 import org.robolectric.annotation.Implements; 12 import org.robolectric.shadow.api.Shadow; 13 14 @Implements(value = ThreadedRenderer.class, isInAndroidSdk = false, minSdk = LOLLIPOP, looseSignatures = true) 15 public class ShadowThreadedRenderer { 16 17 @Implementation(minSdk = O, maxSdk = P) 18 protected static Bitmap createHardwareBitmap(Object rendererNode, Object width, Object height) { 19 int w = (int) width; 20 int h = (int) height; 21 22 Bitmap bitmap = Bitmap.createBitmap(w, h, Config.HARDWARE); 23 ShadowBitmap shadowBitmap = Shadow.extract(bitmap); 24 shadowBitmap.setMutable(false); 25 return bitmap; 26 } 27 } 28