admin 管理员组文章数量: 887021
2023年12月17日发(作者:native手办图片)
我们先来看VirtualDisplaySurfaceclass VirtualDisplaySurface : public DisplaySurface, public BnGraphicBufferProducer, private ConsumerBase {厉害了,我的VirtualDisplaySurface,继承了BnGraphicBufferProducer和ConsumerBase。这是即做Producer,也做Consumer。先来看VirtualDisplaySurface的构造函数:
* frameworks/native/services/surfaceflinger/DisplayHardware/tualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId, const sp
private int acquireNextSurfaceImage(SurfaceImage si) { synchronized (mCloseLock) { // A null image will eventually be returned if ImageReader is already closed. int status = ACQUIRE_NO_BUFS; if (mIsReaderValid) { status = nativeImageSetup(si); } switch (status) { case ACQUIRE_SUCCESS: geValid = true; case ACQUIRE_NO_BUFS: case ACQUIRE_MAX_IMAGES: break; default: throw new AssertionError("Unknown nativeImageSetup return code " + status); } // Only keep track the successfully acquired image, as the native buffer is only mapped // for such case. if (status == ACQUIRE_SUCCESS) { (si); } return status; } }这类终于调到关键的了,nativeImageSetup函数。对应的JNI函数为ImageReader_imageSetup。ImageReader_imageSetup函数:static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, jobject image) { ALOGV("%s:", __FUNCTION__); JNIImageReaderContext* ctx = ImageReader_getContext(env, thiz); if (ctx == NULL) { jniThrowException(env, "java/lang/IllegalStateException", "ImageReader is not initialized or was already closed"); return -1; } BufferItemConsumer* bufferConsumer = ctx->getBufferConsumer(); BufferItem* buffer = ctx->getBufferItem(); if (buffer == NULL) { ALOGW("Unable to acquire a buffer item, very likely client tried to acquire more than" " maxImages buffers"); return ACQUIRE_MAX_IMAGES; } status_t res = bufferConsumer->acquireBuffer(buffer, 0); if (res != OK) { ... ... } // Add some extra checks for non-opaque formats. if (!isFormatOpaque(ctx->getBufferFormat())) { ... ... } // Set SurfaceImage instance member variables Image_setBufferItem(env, image, buffer); env->SetLongField(image, tamp, static_cast
版权声明:本文标题:AndroidP图形显示系统(四)AndroidVirtualDisplay解析 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/free/1702753413h429433.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论