Skip to content

Commit

Permalink
APPARENTLY WORKS! APPARENTLY!
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bowers committed Oct 22, 2013
1 parent b0f9d55 commit 39b4569
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Binary file added libs/renderscript-v8.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
# Project target.
target=android-18
android.library=true
renderscript.target=18
renderscript.support.mode=true
sdk.buildtools=18.1.0
19 changes: 16 additions & 3 deletions src/com/mixpanel/android/mpmetrics/MixpanelAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.support.v8.renderscript.Allocation;
import android.support.v8.renderscript.Element;
import android.support.v8.renderscript.RenderScript;
import android.support.v8.renderscript.ScriptIntrinsicBlur;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;

import com.mixpanel.android.surveys.SurveyActivity;
import com.mixpanel.android.util.Blur;

/**
* Core class for interacting with Mixpanel Analytics.
Expand Down Expand Up @@ -722,8 +726,17 @@ public void showSurvey(final Survey s, final View parent /* TODO not the final i
rootView.setDrawingCacheEnabled(true); // TODO leaks state
final Bitmap background = rootView.getDrawingCache();

// TODO - can't run this here, must be Async
Blur.blur(mContext, background);
/** TODO Must be async **/
RenderScript rs = RenderScript.create(parent.getContext());
Allocation input = Allocation.createFromBitmap(rs, background, Allocation.MipmapControl.MIPMAP_FULL, Allocation.USAGE_SCRIPT);
Allocation output = Allocation.createTyped(rs, input.getType());

// Load up an instance of the specific script that we want to use.
ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4 (rs));
script.setInput(input);
script.setRadius(9); // TODO expensive?
script.forEach(output);
output.copyTo(background);

ByteArrayOutputStream bs = new ByteArrayOutputStream();
background.compress(Bitmap.CompressFormat.JPEG, 20, bs);
Expand Down

0 comments on commit 39b4569

Please sign in to comment.