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,
const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ,
bool isCpuConsumer) = 0;
uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
};
// ----------------------------------------------------------------------------

View File

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

View File

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

View File

@ -2631,8 +2631,7 @@ public:
status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ,
bool useReadPixels) {
uint32_t minLayerZ, uint32_t maxLayerZ) {
if (CC_UNLIKELY(display == 0))
return BAD_VALUE;
@ -2646,18 +2645,16 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
sp<IGraphicBufferProducer> producer;
uint32_t reqWidth, reqHeight;
uint32_t minLayerZ,maxLayerZ;
bool useReadPixels;
status_t result;
public:
MessageCaptureScreen(SurfaceFlinger* flinger,
const sp<IBinder>& display,
const sp<IGraphicBufferProducer>& producer,
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),
reqWidth(reqWidth), reqHeight(reqHeight),
minLayerZ(minLayerZ), maxLayerZ(maxLayerZ),
useReadPixels(useReadPixels),
result(PERMISSION_DENIED)
{
}
@ -2667,10 +2664,8 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display,
virtual bool handler() {
Mutex::Autolock _l(flinger->mStateLock);
sp<const DisplayDevice> hw(flinger->getDisplayDevice(display));
bool useReadPixels = this->useReadPixels && !flinger->mGpuToCpuSupported;
result = flinger->captureScreenImplLocked(hw,
producer, reqWidth, reqHeight, minLayerZ, maxLayerZ,
useReadPixels);
producer, reqWidth, reqHeight, minLayerZ, maxLayerZ);
static_cast<GraphicProducerWrapper*>(producer->asBinder().get())->exit(result);
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.
sp<MessageBase> msg = new MessageCaptureScreen(this,
display, IGraphicBufferProducer::asInterface( wrapper ),
reqWidth, reqHeight, minLayerZ, maxLayerZ,
useReadPixels);
reqWidth, reqHeight, minLayerZ, maxLayerZ);
status_t res = postMessageAsync(msg);
if (res == NO_ERROR) {
@ -2761,8 +2755,7 @@ status_t SurfaceFlinger::captureScreenImplLocked(
const sp<const DisplayDevice>& hw,
const sp<IGraphicBufferProducer>& producer,
uint32_t reqWidth, uint32_t reqHeight,
uint32_t minLayerZ, uint32_t maxLayerZ,
bool useReadPixels)
uint32_t minLayerZ, uint32_t maxLayerZ)
{
ATRACE_CALL();
@ -2792,10 +2785,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(
status_t result = 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;
if (!useReadPixels) {
usage = GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
}
uint32_t usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN |
GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
int err = 0;
err = native_window_set_buffers_dimensions(window, reqWidth, reqHeight);
@ -2815,28 +2806,16 @@ status_t SurfaceFlinger::captureScreenImplLocked(
EGL_NATIVE_BUFFER_ANDROID, buffer, NULL);
if (image != EGL_NO_IMAGE_KHR) {
GLuint tname, name;
if (!useReadPixels) {
// turn our EGLImage into a texture
glGenTextures(1, &tname);
glBindTexture(GL_TEXTURE_2D, tname);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image);
// create a Framebuffer Object to render into
glGenFramebuffersOES(1, &name);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, name);
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES,
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);
}
// turn our EGLImage into a texture
glGenTextures(1, &tname);
glBindTexture(GL_TEXTURE_2D, tname);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image);
// create a Framebuffer Object to render into
glGenFramebuffersOES(1, &name);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, name);
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES,
GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tname, 0);
GLenum status = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
if (status == GL_FRAMEBUFFER_COMPLETE_OES) {
@ -2846,17 +2825,6 @@ status_t SurfaceFlinger::captureScreenImplLocked(
// dependent on the context's EGLConfig.
renderScreenImplLocked(hw, reqWidth, reqHeight,
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 {
ALOGE("got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot");
result = INVALID_OPERATION;
@ -2865,11 +2833,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(
// back to main framebuffer
glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
glDeleteFramebuffersOES(1, &name);
if (!useReadPixels) {
glDeleteTextures(1, &tname);
} else {
glDeleteRenderbuffersOES(1, &tname);
}
glDeleteTextures(1, &tname);
// destroy our image
eglDestroyImageKHR(mEGLDisplay, image);
} else {

View File

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