Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable transparent FlutterViews #6163

Merged
merged 1 commit into from
Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions shell/common/rasterizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool Rasterizer::DrawToSurface(flow::LayerTree& layer_tree) {
surface_->GetContext(), canvas, surface_->GetRootTransformation(), true);

if (canvas) {
canvas->clear(SK_ColorBLACK);
canvas->clear(SK_ColorTRANSPARENT);
}

if (compositor_frame && compositor_frame->Raster(layer_tree, false)) {
Expand Down Expand Up @@ -186,7 +186,7 @@ static sk_sp<SkData> ScreenshotLayerTreeAsImage(

auto frame = compositor_context.AcquireFrame(
surface_context, canvas, root_surface_transformation, false);
canvas->clear(SK_ColorBLACK);
canvas->clear(SK_ColorTRANSPARENT);
frame->Raster(*tree, true);
canvas->flush();

Expand Down
14 changes: 2 additions & 12 deletions shell/platform/android/io/flutter/view/FlutterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,11 @@ public FlutterView(Context context, AttributeSet attrs, FlutterNativeView native
}
mNativeView.attachViewAndActivity(this, activity);

int color = 0xFF000000;
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.colorBackground, typedValue, true);
if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT && typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) {
color = typedValue.data;
}
// TODO(abarth): Consider letting the developer override this color.
final int backgroundColor = color;

mSurfaceCallback = new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
assertAttached();
nativeSurfaceCreated(mNativeView.get(), holder.getSurface(), backgroundColor);
nativeSurfaceCreated(mNativeView.get(), holder.getSurface());
}

@Override
Expand Down Expand Up @@ -651,8 +642,7 @@ public Bitmap getBitmap() {
return nativeGetBitmap(mNativeView.get());
}

private static native void nativeSurfaceCreated(long nativePlatformViewAndroid, Surface surface,
int backgroundColor);
private static native void nativeSurfaceCreated(long nativePlatformViewAndroid, Surface surface);

private static native void nativeSurfaceChanged(long nativePlatformViewAndroid, int width, int height);

Expand Down
5 changes: 2 additions & 3 deletions shell/platform/android/platform_view_android_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ static jstring GetObservatoryUri(JNIEnv* env, jclass clazz) {
static void SurfaceCreated(JNIEnv* env,
jobject jcaller,
jlong shell_holder,
jobject jsurface,
jint backgroundColor) {
jobject jsurface) {
// Note: This frame ensures that any local references used by
// ANativeWindow_fromSurface are released immediately. This is needed as a
// workaround for https://code.google.com/p/android/issues/detail?id=68174
Expand Down Expand Up @@ -638,7 +637,7 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
static const JNINativeMethod view_methods[] = {
{
.name = "nativeSurfaceCreated",
.signature = "(JLandroid/view/Surface;I)V",
.signature = "(JLandroid/view/Surface;)V",
.fnPtr = reinterpret_cast<void*>(&shell::SurfaceCreated),
},
{
Expand Down