remove support for glReadPixels screenshot path

this was only needed on some chipset we're not
supporting in KLP.

Change-Id: I2e8fc07f135030bd61d2e241a8e426f1a4316425
This commit is contained in:
Mathias Agopian 2013-08-06 16:07:33 -07:00
parent 126b9c8e95
commit 3ca76f416b
5 changed files with 26 additions and 68 deletions

View File

@ -115,8 +115,7 @@ public:
virtual status_t captureScreen(const sp<IBinder>& display, virtual status_t captureScreen(const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer, const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight, uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ, uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
bool isCpuConsumer) = 0;
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -105,8 +105,7 @@ public:
virtual status_t captureScreen(const sp<IBinder>& display, virtual status_t captureScreen(const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer, const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight, uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ, uint32_t minLayerZ, uint32_t maxLayerZ)
bool isCpuConsumer)
{ {
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
@ -116,7 +115,6 @@ public:
data.writeInt32(reqHeight); data.writeInt32(reqHeight);
data.writeInt32(minLayerZ); data.writeInt32(minLayerZ);
data.writeInt32(maxLayerZ); data.writeInt32(maxLayerZ);
data.writeInt32(isCpuConsumer);
remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply); remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
return reply.readInt32(); return reply.readInt32();
} }
@ -275,10 +273,8 @@ status_t BnSurfaceComposer::onTransact(
uint32_t reqHeight = data.readInt32(); uint32_t reqHeight = data.readInt32();
uint32_t minLayerZ = data.readInt32(); uint32_t minLayerZ = data.readInt32();
uint32_t maxLayerZ = data.readInt32(); uint32_t maxLayerZ = data.readInt32();
bool isCpuConsumer = data.readInt32();
status_t res = captureScreen(display, producer, status_t res = captureScreen(display, producer,
reqWidth, reqHeight, minLayerZ, maxLayerZ, reqWidth, reqHeight, minLayerZ, maxLayerZ);
isCpuConsumer);
reply->writeInt32(res); reply->writeInt32(res);
} break; } break;
case AUTHENTICATE_SURFACE: { case AUTHENTICATE_SURFACE: {

View File

@ -618,8 +618,7 @@ status_t ScreenshotClient::capture(
sp<ISurfaceComposer> s(ComposerService::getComposerService()); sp<ISurfaceComposer> s(ComposerService::getComposerService());
if (s == NULL) return NO_INIT; if (s == NULL) return NO_INIT;
return s->captureScreen(display, producer, return s->captureScreen(display, producer,
reqWidth, reqHeight, minLayerZ, maxLayerZ, reqWidth, reqHeight, minLayerZ, maxLayerZ);
false);
} }
ScreenshotClient::ScreenshotClient() ScreenshotClient::ScreenshotClient()
@ -654,7 +653,7 @@ status_t ScreenshotClient::update(const sp<IBinder>& display,
} }
status_t err = s->captureScreen(display, mBufferQueue, status_t err = s->captureScreen(display, mBufferQueue,
reqWidth, reqHeight, minLayerZ, maxLayerZ, true); reqWidth, reqHeight, minLayerZ, maxLayerZ);
if (err == NO_ERROR) { if (err == NO_ERROR) {
err = mCpuConsumer->lockNextBuffer(&mBuffer); err = mCpuConsumer->lockNextBuffer(&mBuffer);

View File

@ -2631,8 +2631,7 @@ public:
status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer, const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight, uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ, uint32_t minLayerZ, uint32_t maxLayerZ) {
bool useReadPixels) {
if (CC_UNLIKELY(display == 0)) if (CC_UNLIKELY(display == 0))
return BAD_VALUE; return BAD_VALUE;
@ -2646,18 +2645,16 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
sp<IGraphicBufferProducer> producer; sp<IGraphicBufferProducer> producer;
uint32_t reqWidth, reqHeight; uint32_t reqWidth, reqHeight;
uint32_t minLayerZ,maxLayerZ; uint32_t minLayerZ,maxLayerZ;
bool useReadPixels;
status_t result; status_t result;
public: public:
MessageCaptureScreen(SurfaceFlinger* flinger, MessageCaptureScreen(SurfaceFlinger* flinger,
const sp<IBinder>& display, const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer, const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight, uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ, bool useReadPixels) uint32_t minLayerZ, uint32_t maxLayerZ)
: flinger(flinger), display(display), producer(producer), : flinger(flinger), display(display), producer(producer),
reqWidth(reqWidth), reqHeight(reqHeight), reqWidth(reqWidth), reqHeight(reqHeight),
minLayerZ(minLayerZ), maxLayerZ(maxLayerZ), minLayerZ(minLayerZ), maxLayerZ(maxLayerZ),
useReadPixels(useReadPixels),
result(PERMISSION_DENIED) result(PERMISSION_DENIED)
{ {
} }
@ -2667,10 +2664,8 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
virtual bool handler() { virtual bool handler() {
Mutex::Autolock _l(flinger->mStateLock); Mutex::Autolock _l(flinger->mStateLock);
sp<const DisplayDevice> hw(flinger->getDisplayDevice(display)); sp<const DisplayDevice> hw(flinger->getDisplayDevice(display));
bool useReadPixels = this->useReadPixels && !flinger->mGpuToCpuSupported;
result = flinger->captureScreenImplLocked(hw, result = flinger->captureScreenImplLocked(hw,
producer, reqWidth, reqHeight, minLayerZ, maxLayerZ, producer, reqWidth, reqHeight, minLayerZ, maxLayerZ);
useReadPixels);
static_cast<GraphicProducerWrapper*>(producer->asBinder().get())->exit(result); static_cast<GraphicProducerWrapper*>(producer->asBinder().get())->exit(result);
return true; return true;
} }
@ -2692,8 +2687,7 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
// which does the marshaling work forwards to our "fake remote" above. // which does the marshaling work forwards to our "fake remote" above.
sp<MessageBase> msg = new MessageCaptureScreen(this, sp<MessageBase> msg = new MessageCaptureScreen(this,
display, IGraphicBufferProducer::asInterface( wrapper ), display, IGraphicBufferProducer::asInterface( wrapper ),
reqWidth, reqHeight, minLayerZ, maxLayerZ, reqWidth, reqHeight, minLayerZ, maxLayerZ);
useReadPixels);
status_t res = postMessageAsync(msg); status_t res = postMessageAsync(msg);
if (res == NO_ERROR) { if (res == NO_ERROR) {
@ -2761,8 +2755,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(
const sp<const DisplayDevice>& hw, const sp<const DisplayDevice>& hw,
const sp<IGraphicBufferProducer>& producer, const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight, uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ, uint32_t minLayerZ, uint32_t maxLayerZ)
bool useReadPixels)
{ {
ATRACE_CALL(); ATRACE_CALL();
@ -2792,10 +2785,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(
status_t result = NO_ERROR; status_t result = NO_ERROR;
if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) == NO_ERROR) { if (native_window_api_connect(window, NATIVE_WINDOW_API_EGL) == NO_ERROR) {
uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN; uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN |
if (!useReadPixels) { GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
usage = GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
}
int err = 0; int err = 0;
err = native_window_set_buffers_dimensions(window, reqWidth, reqHeight); err = native_window_set_buffers_dimensions(window, reqWidth, reqHeight);
@ -2815,28 +2806,16 @@ status_t SurfaceFlinger::captureScreenImplLocked(
EGL_NATIVE_BUFFER_ANDROID, buffer, NULL); EGL_NATIVE_BUFFER_ANDROID, buffer, NULL);
if (image != EGL_NO_IMAGE_KHR) { if (image != EGL_NO_IMAGE_KHR) {
GLuint tname, name; GLuint tname, name;
if (!useReadPixels) {
// turn our EGLImage into a texture // turn our EGLImage into a texture
glGenTextures(1, &tname); glGenTextures(1, &tname);
glBindTexture(GL_TEXTURE_2D, tname); glBindTexture(GL_TEXTURE_2D, tname);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image); glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image);
// create a Framebuffer Object to render into // create a Framebuffer Object to render into
glGenFramebuffersOES(1, &name); glGenFramebuffersOES(1, &name);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, name); glBindFramebufferOES(GL_FRAMEBUFFER_OES, name);
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES, glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES,
GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tname, 0); GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tname, 0);
} else {
// since we're going to use glReadPixels() anyways,
// use an intermediate renderbuffer instead
glGenRenderbuffersOES(1, &tname);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, tname);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_RGBA8_OES, reqWidth, reqHeight);
// create a FBO to render into
glGenFramebuffersOES(1, &name);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, name);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES,
GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, tname);
}
GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES); GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
if (status == GL_FRAMEBUFFER_COMPLETE_OES) { if (status == GL_FRAMEBUFFER_COMPLETE_OES) {
@ -2846,17 +2825,6 @@ status_t SurfaceFlinger::captureScreenImplLocked(
// dependent on the context's EGLConfig. // dependent on the context's EGLConfig.
renderScreenImplLocked(hw, reqWidth, reqHeight, renderScreenImplLocked(hw, reqWidth, reqHeight,
minLayerZ, maxLayerZ, true); minLayerZ, maxLayerZ, true);
if (useReadPixels) {
sp<GraphicBuffer> buf = static_cast<GraphicBuffer*>(buffer);
void* vaddr;
if (buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, &vaddr) == NO_ERROR) {
glReadPixels(0, 0, buffer->stride, reqHeight,
GL_RGBA, GL_UNSIGNED_BYTE, vaddr);
checkScreenshot(buf, vaddr, hw, minLayerZ, maxLayerZ);
buf->unlock();
}
}
} else { } else {
ALOGE("got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot"); ALOGE("got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot");
result = INVALID_OPERATION; result = INVALID_OPERATION;
@ -2865,11 +2833,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(
// back to main framebuffer // back to main framebuffer
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0); glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
glDeleteFramebuffersOES(1, &name); glDeleteFramebuffersOES(1, &name);
if (!useReadPixels) { glDeleteTextures(1, &tname);
glDeleteTextures(1, &tname);
} else {
glDeleteRenderbuffersOES(1, &tname);
}
// destroy our image // destroy our image
eglDestroyImageKHR(mEGLDisplay, image); eglDestroyImageKHR(mEGLDisplay, image);
} else { } else {

View File

@ -194,7 +194,7 @@ private:
virtual status_t captureScreen(const sp<IBinder>& display, virtual status_t captureScreen(const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer, const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight, uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ, bool isCpuConsumer); uint32_t minLayerZ, uint32_t maxLayerZ);
// called when screen needs to turn off // called when screen needs to turn off
virtual void blank(const sp<IBinder>& display); virtual void blank(const sp<IBinder>& display);
// called when screen is turning back on // called when screen is turning back on
@ -307,8 +307,7 @@ private:
const sp<const DisplayDevice>& hw, const sp<const DisplayDevice>& hw,
const sp<IGraphicBufferProducer>& producer, const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight, uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ, uint32_t minLayerZ, uint32_t maxLayerZ);
bool useReadPixels);
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
* EGL * EGL