Skip to content

Commit 840b8a6

Browse files
committed
Revert "Add a LayerScreenshot"
This reverts commit d6809f4.
1 parent 4fb6416 commit 840b8a6

File tree

9 files changed

+64
-244
lines changed

9 files changed

+64
-244
lines changed

core/java/android/view/Surface.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,6 @@ public OutOfResourcesException(String name) {
194194
*/
195195
public static final int FX_SURFACE_DIM = 0x00020000;
196196

197-
/** @hide */
198-
public static final int FX_SURFACE_SCREENSHOT = 0x00030000;
199-
200197
/** Mask used for FX values above @hide */
201198
public static final int FX_SURFACE_MASK = 0x000F0000;
202199

include/surfaceflinger/ISurfaceComposer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class ISurfaceComposer : public IInterface
5353
eFXSurfaceNormal = 0x00000000,
5454
eFXSurfaceBlur = 0x00010000,
5555
eFXSurfaceDim = 0x00020000,
56-
eFXSurfaceScreenshot= 0x00030000,
5756
eFXSurfaceMask = 0x000F0000,
5857
};
5958

services/java/com/android/server/wm/ScreenRotationAnimation.java

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,17 @@ public ScreenRotationAnimation(Context context, SurfaceSession session,
6464
boolean inTransaction, int originalWidth, int originalHeight, int originalRotation) {
6565
mContext = context;
6666

67+
Bitmap screenshot = Surface.screenshot(0, 0);
68+
69+
if (screenshot == null) {
70+
// Device is not capable of screenshots... we can't do an animation.
71+
return;
72+
}
73+
6774
// Screenshot does NOT include rotation!
6875
mSnapshotRotation = 0;
69-
if (originalRotation == Surface.ROTATION_90
70-
|| originalRotation == Surface.ROTATION_270) {
71-
mWidth = originalHeight;
72-
mHeight = originalWidth;
73-
} else {
74-
mWidth = originalWidth;
75-
mHeight = originalHeight;
76-
}
76+
mWidth = screenshot.getWidth();
77+
mHeight = screenshot.getHeight();
7778

7879
mOriginalRotation = originalRotation;
7980
mOriginalWidth = originalWidth;
@@ -88,12 +89,7 @@ public ScreenRotationAnimation(Context context, SurfaceSession session,
8889
try {
8990
try {
9091
mSurface = new Surface(session, 0, "FreezeSurface",
91-
-1, mWidth, mHeight, PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT);
92-
if (mSurface == null || !mSurface.isValid()) {
93-
// Screenshot failed, punt.
94-
mSurface = null;
95-
return;
96-
}
92+
-1, mWidth, mHeight, PixelFormat.OPAQUE, 0);
9793
mSurface.setLayer(FREEZE_LAYER + 1);
9894
} catch (Surface.OutOfResourcesException e) {
9995
Slog.w(TAG, "Unable to allocate freeze surface", e);
@@ -104,12 +100,38 @@ public ScreenRotationAnimation(Context context, SurfaceSession session,
104100
" FREEZE " + mSurface + ": CREATE");
105101

106102
setRotation(originalRotation);
103+
104+
if (mSurface != null) {
105+
Rect dirty = new Rect(0, 0, mWidth, mHeight);
106+
Canvas c = null;
107+
try {
108+
c = mSurface.lockCanvas(dirty);
109+
} catch (IllegalArgumentException e) {
110+
Slog.w(TAG, "Unable to lock surface", e);
111+
} catch (Surface.OutOfResourcesException e) {
112+
Slog.w(TAG, "Unable to lock surface", e);
113+
}
114+
if (c == null) {
115+
Slog.w(TAG, "Null surface canvas");
116+
mSurface.destroy();
117+
mSurface = null;
118+
return;
119+
}
120+
121+
Paint paint = new Paint(0);
122+
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
123+
c.drawBitmap(screenshot, 0, 0, paint);
124+
125+
mSurface.unlockCanvasAndPost(c);
126+
}
107127
} finally {
108128
if (!inTransaction) {
109129
Surface.closeTransaction();
110130
if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS) Slog.i(WindowManagerService.TAG,
111131
"<<< CLOSE TRANSACTION ScreenRotationAnimation");
112132
}
133+
134+
screenshot.recycle();
113135
}
114136
}
115137

services/surfaceflinger/Android.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ LOCAL_SRC_FILES:= \
55
Layer.cpp \
66
LayerBase.cpp \
77
LayerDim.cpp \
8-
LayerScreenshot.cpp \
98
DdmConnection.cpp \
109
DisplayHardware/DisplayHardware.cpp \
1110
DisplayHardware/DisplayHardwareBase.cpp \

services/surfaceflinger/Layer.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,16 @@ void Layer::onFirstRef()
8888

8989
Layer::~Layer()
9090
{
91-
mFlinger->postMessageAsync(
92-
new SurfaceFlinger::MessageDestroyGLTexture(mTextureName) );
91+
class MessageDestroyGLState : public MessageBase {
92+
GLuint texture;
93+
public:
94+
MessageDestroyGLState(GLuint texture) : texture(texture) { }
95+
virtual bool handler() {
96+
glDeleteTextures(1, &texture);
97+
return true;
98+
}
99+
};
100+
mFlinger->postMessageAsync( new MessageDestroyGLState(mTextureName) );
93101
}
94102

95103
void Layer::onFrameQueued() {

services/surfaceflinger/LayerScreenshot.cpp

Lines changed: 0 additions & 116 deletions
This file was deleted.

services/surfaceflinger/LayerScreenshot.h

Lines changed: 0 additions & 56 deletions
This file was deleted.

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include "DdmConnection.h"
5151
#include "Layer.h"
5252
#include "LayerDim.h"
53-
#include "LayerScreenshot.h"
5453
#include "SurfaceFlinger.h"
5554

5655
#include "DisplayHardware/DisplayHardware.h"
@@ -1352,9 +1351,6 @@ sp<ISurface> SurfaceFlinger::createSurface(
13521351
case eFXSurfaceDim:
13531352
layer = createDimSurface(client, d, w, h, flags);
13541353
break;
1355-
case eFXSurfaceScreenshot:
1356-
layer = createScreenshotSurface(client, d, w, h, flags);
1357-
break;
13581354
}
13591355

13601356
if (layer != 0) {
@@ -1417,19 +1413,7 @@ sp<LayerDim> SurfaceFlinger::createDimSurface(
14171413
uint32_t w, uint32_t h, uint32_t flags)
14181414
{
14191415
sp<LayerDim> layer = new LayerDim(this, display, client);
1420-
return layer;
1421-
}
1422-
1423-
sp<LayerScreenshot> SurfaceFlinger::createScreenshotSurface(
1424-
const sp<Client>& client, DisplayID display,
1425-
uint32_t w, uint32_t h, uint32_t flags)
1426-
{
1427-
sp<LayerScreenshot> layer = new LayerScreenshot(this, display, client);
1428-
status_t err = layer->capture();
1429-
if (err != NO_ERROR) {
1430-
layer.clear();
1431-
LOGW("createScreenshotSurface failed (%s)", strerror(-err));
1432-
}
1416+
layer->initStates(w, h, flags);
14331417
return layer;
14341418
}
14351419

@@ -1792,13 +1776,6 @@ void SurfaceFlinger::repaintEverything() {
17921776

17931777
// ---------------------------------------------------------------------------
17941778

1795-
status_t SurfaceFlinger::renderScreenToTexture(DisplayID dpy,
1796-
GLuint* textureName, GLfloat* uOut, GLfloat* vOut)
1797-
{
1798-
Mutex::Autolock _l(mStateLock);
1799-
return renderScreenToTextureLocked(dpy, textureName, uOut, vOut);
1800-
}
1801-
18021779
status_t SurfaceFlinger::renderScreenToTextureLocked(DisplayID dpy,
18031780
GLuint* textureName, GLfloat* uOut, GLfloat* vOut)
18041781
{
@@ -1862,6 +1839,11 @@ status_t SurfaceFlinger::renderScreenToTextureLocked(DisplayID dpy,
18621839

18631840
status_t SurfaceFlinger::electronBeamOffAnimationImplLocked()
18641841
{
1842+
status_t result = PERMISSION_DENIED;
1843+
1844+
if (!GLExtensions::getInstance().haveFramebufferObject())
1845+
return INVALID_OPERATION;
1846+
18651847
// get screen geometry
18661848
const DisplayHardware& hw(graphicPlane(0).displayHardware());
18671849
const uint32_t hw_w = hw.getWidth();
@@ -1870,7 +1852,7 @@ status_t SurfaceFlinger::electronBeamOffAnimationImplLocked()
18701852

18711853
GLfloat u, v;
18721854
GLuint tname;
1873-
status_t result = renderScreenToTextureLocked(0, &tname, &u, &v);
1855+
result = renderScreenToTextureLocked(0, &tname, &u, &v);
18741856
if (result != NO_ERROR) {
18751857
return result;
18761858
}
@@ -2046,6 +2028,10 @@ status_t SurfaceFlinger::electronBeamOnAnimationImplLocked()
20462028
return result;
20472029
}
20482030

2031+
// back to main framebuffer
2032+
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
2033+
glDisable(GL_SCISSOR_TEST);
2034+
20492035
GLfloat vtx[8];
20502036
const GLfloat texCoords[4][2] = { {0,v}, {0,0}, {u,0}, {u,v} };
20512037
glBindTexture(GL_TEXTURE_2D, tname);

0 commit comments

Comments
 (0)