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

Unified Diff: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/StateAdapter.java

Issue 2041193004: Implement Raster Backend on Android Viewer App (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Merge Created 4 years, 6 months 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
« no previous file with comments | « no previous file | platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/StateAdapter.java
diff --git a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/StateAdapter.java b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/StateAdapter.java
index d546c7bb3e19d520baff1a61efeaebb0ac85621c..5ee68efc3c672003f9ff271b8b671a5b932b5449 100644
--- a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/StateAdapter.java
+++ b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/StateAdapter.java
@@ -1,6 +1,7 @@
package org.skia.viewer;
import android.view.LayoutInflater;
+import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
@@ -30,6 +31,7 @@ public class StateAdapter extends BaseAdapter implements AdapterView.OnItemSelec
static final String NAME = "name";
static final String VALUE = "value";
static final String OPTIONS = "options";
+ private static final String BACKEND_STATE_NAME = "Backend";
ViewerActivity mViewerActivity;
LinearLayout mLayout;
@@ -146,6 +148,21 @@ public class StateAdapter extends BaseAdapter implements AdapterView.OnItemSelec
stateItem.setTag(null); // Reset the tag to let updateDrawer update this item view.
mViewerActivity.onStateChanged(stateName, stateValue);
}
+
+ // Due to the current Android limitation, we're required to recreate the SurfaceView for
+ // switching to/from the Raster backend.
+ // (Although we can switch between GPU backend without recreating the SurfaceView.)
+ final Object oldValue = stateItem.getTag(R.integer.value_tag_key);
+ if (stateName.equals(BACKEND_STATE_NAME)
+ && oldValue != null && !stateValue.equals(oldValue)) {
+ LinearLayout mainLayout = (LinearLayout) mViewerActivity.findViewById(R.id.mainLayout);
+ mainLayout.removeAllViews();
+ SurfaceView surfaceView = new SurfaceView(mViewerActivity);
+ surfaceView.setId(R.id.surfaceView);
+ surfaceView.getHolder().addCallback(mViewerActivity);
+ surfaceView.setOnTouchListener(mViewerActivity);
+ mainLayout.addView(surfaceView);
+ }
}
@Override
« no previous file with comments | « no previous file | platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698