Implement TODO(romainguy)
Bug: 14277445 Change-Id: Id52d6f7fcc023000adcc440bd4da67d9a673536b
This commit is contained in:
@@ -653,6 +653,11 @@ public class GLRenderer extends HardwareRenderer {
|
||||
loadSystemProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
void setOpaque(boolean opaque) {
|
||||
// Not supported
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean loadSystemProperties() {
|
||||
boolean value;
|
||||
|
||||
@@ -490,6 +490,11 @@ public abstract class HardwareRenderer {
|
||||
*/
|
||||
abstract void setName(String name);
|
||||
|
||||
/**
|
||||
* Change the HardwareRenderer's opacity
|
||||
*/
|
||||
abstract void setOpaque(boolean opaque);
|
||||
|
||||
/**
|
||||
* Creates a hardware renderer using OpenGL.
|
||||
*
|
||||
|
||||
@@ -147,6 +147,11 @@ public class ThreadedRenderer extends HardwareRenderer {
|
||||
nSetup(mNativeProxy, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
void setOpaque(boolean opaque) {
|
||||
nSetOpaque(mNativeProxy, opaque);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getWidth() {
|
||||
return mWidth;
|
||||
@@ -312,6 +317,7 @@ public class ThreadedRenderer extends HardwareRenderer {
|
||||
private static native void nUpdateSurface(long nativeProxy, Surface window);
|
||||
private static native void nPauseSurface(long nativeProxy, Surface window);
|
||||
private static native void nSetup(long nativeProxy, int width, int height);
|
||||
private static native void nSetOpaque(long nativeProxy, boolean opaque);
|
||||
private static native void nSetDisplayListData(long nativeProxy, long displayList,
|
||||
long newData);
|
||||
private static native int nSyncAndDrawFrame(long nativeProxy, long frameTimeNanos,
|
||||
|
||||
@@ -6174,8 +6174,10 @@ public final class ViewRootImpl implements ViewParent,
|
||||
}
|
||||
|
||||
void changeCanvasOpacity(boolean opaque) {
|
||||
// TODO(romainguy): recreate Canvas (software or hardware) to reflect the opacity change.
|
||||
Log.d(TAG, "changeCanvasOpacity: opaque=" + opaque);
|
||||
if (mAttachInfo.mHardwareRenderer != null) {
|
||||
mAttachInfo.mHardwareRenderer.setOpaque(opaque);
|
||||
}
|
||||
}
|
||||
|
||||
class TakenSurfaceHolder extends BaseSurfaceHolder {
|
||||
|
||||
@@ -197,6 +197,12 @@ static void android_view_ThreadedRenderer_setup(JNIEnv* env, jobject clazz,
|
||||
proxy->setup(width, height);
|
||||
}
|
||||
|
||||
static void android_view_ThreadedRenderer_setOpaque(JNIEnv* env, jobject clazz,
|
||||
jlong proxyPtr, jboolean opaque) {
|
||||
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
|
||||
proxy->setOpaque(opaque);
|
||||
}
|
||||
|
||||
static int android_view_ThreadedRenderer_syncAndDrawFrame(JNIEnv* env, jobject clazz,
|
||||
jlong proxyPtr, jlong frameTimeNanos, jint dirtyLeft, jint dirtyTop,
|
||||
jint dirtyRight, jint dirtyBottom) {
|
||||
@@ -279,6 +285,7 @@ static JNINativeMethod gMethods[] = {
|
||||
{ "nUpdateSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_updateSurface },
|
||||
{ "nPauseSurface", "(JLandroid/view/Surface;)V", (void*) android_view_ThreadedRenderer_pauseSurface },
|
||||
{ "nSetup", "(JII)V", (void*) android_view_ThreadedRenderer_setup },
|
||||
{ "nSetOpaque", "(JZ)V", (void*) android_view_ThreadedRenderer_setOpaque },
|
||||
{ "nSyncAndDrawFrame", "(JJIIII)I", (void*) android_view_ThreadedRenderer_syncAndDrawFrame },
|
||||
{ "nDestroyCanvasAndSurface", "(J)V", (void*) android_view_ThreadedRenderer_destroyCanvasAndSurface },
|
||||
{ "nInvokeFunctor", "(JJZ)V", (void*) android_view_ThreadedRenderer_invokeFunctor },
|
||||
|
||||
@@ -385,6 +385,10 @@ void CanvasContext::setup(int width, int height) {
|
||||
mCanvas->setViewport(width, height);
|
||||
}
|
||||
|
||||
void CanvasContext::setOpaque(bool opaque) {
|
||||
mOpaque = opaque;
|
||||
}
|
||||
|
||||
void CanvasContext::makeCurrent() {
|
||||
// TODO: Figure out why this workaround is needed, see b/13913604
|
||||
// In the meantime this matches the behavior of GLRenderer, so it is not a regression
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
void updateSurface(EGLNativeWindowType window);
|
||||
void pauseSurface(EGLNativeWindowType window);
|
||||
void setup(int width, int height);
|
||||
void setOpaque(bool opaque);
|
||||
void makeCurrent();
|
||||
void prepareDraw(const Vector<DeferredLayerUpdater*>* layerUpdaters, TreeInfo& info);
|
||||
void draw(Rect* dirty);
|
||||
|
||||
@@ -159,6 +159,18 @@ void RenderProxy::setup(int width, int height) {
|
||||
post(task);
|
||||
}
|
||||
|
||||
CREATE_BRIDGE2(setOpaque, CanvasContext* context, bool opaque) {
|
||||
args->context->setOpaque(args->opaque);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void RenderProxy::setOpaque(bool opaque) {
|
||||
SETUP_TASK(setOpaque);
|
||||
args->context = mContext;
|
||||
args->opaque = opaque;
|
||||
post(task);
|
||||
}
|
||||
|
||||
int RenderProxy::syncAndDrawFrame(nsecs_t frameTimeNanos,
|
||||
int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom) {
|
||||
mDrawFrameTask.setDirty(dirtyLeft, dirtyTop, dirtyRight, dirtyBottom);
|
||||
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
ANDROID_API void updateSurface(const sp<ANativeWindow>& window);
|
||||
ANDROID_API void pauseSurface(const sp<ANativeWindow>& window);
|
||||
ANDROID_API void setup(int width, int height);
|
||||
ANDROID_API void setOpaque(bool opaque);
|
||||
ANDROID_API int syncAndDrawFrame(nsecs_t frameTimeNanos,
|
||||
int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom);
|
||||
ANDROID_API void destroyCanvasAndSurface();
|
||||
|
||||
Reference in New Issue
Block a user