我有1920x1080显示屏。顺便说一句,它是旋转的。因此,显示分辨率为1080x1920。
DisplayInfo mainDpyInfo;
err = SurfaceComposerClient::getDisplayInfo(mainDpy, &mainDpyInfo);
if (err != NO_ERROR) {
ALOGE("ERROR: unable to get display characteristics");
return false;
}
if (mainDpyInfo.orientation != DISPLAY_ORIENTATION_0 &&
mainDpyInfo.orientation != DISPLAY_ORIENTATION_180) {
// rotated
mWidth = mainDpyInfo.h;
mHeight = mainDpyInfo.w;
} else {
mWidth = mainDpyInfo.w;
mHeight = mainDpyInfo.h;
}
ALOGI("[albert] DpyInfo = %d x %d\n", mainDpyInfo.w, mainDpyInfo.h);
ALOGI("[albert] orientation = %d\n", mainDpyInfo.orientation);
ALOGI("[albert] Actual = %d x %d\n", mWidth, mHeight);
Log如下所示
01-11 08:29:37.320 I/AlbertApp( 5779): [albertc] DpyInfo = 1920 x 1080
01-11 08:29:37.320 I/AlbertApp( 5779): [albertc] orientation = 3
01-11 08:29:37.320 I/AlbertApp( 5779): [albertc] Actual = 1080 x 1920
现在我有一个由Gralloc分配的渲染缓冲区。
Format = RGBA
Dimension = 1080*1920
Stride = 1088
我已将所有纹理渲染到此渲染缓冲区中,并最终渲染到此缓冲区以进行屏幕显示。
...
pGfxBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN, (void**)&tgtPixels);
w = buffer.width;
h = buffer.height;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, mTextureMap);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tgtPixels);
pGfxBuffer->unlock();
在转储tgtPixels并使用原始查看器工具打开它1088x1920后,图像正常而没有损坏。 但是屏幕上显示的图像已损坏。
如何解决此问题?