Use current context if available in ConvertToImageFrame
If we're already running in a GlContext, there's no need to go back to the producer context, which may be different. PiperOrigin-RevId: 490373829
This commit is contained in:
parent
7ce4aa6592
commit
efa9e737f8
|
@ -363,7 +363,8 @@ static std::shared_ptr<GpuBufferStorageImageFrame> ConvertToImageFrame(
|
||||||
auto output =
|
auto output =
|
||||||
absl::make_unique<ImageFrame>(image_format, buf->width(), buf->height(),
|
absl::make_unique<ImageFrame>(image_format, buf->width(), buf->height(),
|
||||||
ImageFrame::kGlDefaultAlignmentBoundary);
|
ImageFrame::kGlDefaultAlignmentBoundary);
|
||||||
auto ctx = buf->GetProducerContext();
|
auto ctx = GlContext::GetCurrent();
|
||||||
|
if (!ctx) ctx = buf->GetProducerContext();
|
||||||
ctx->Run([buf, &output, &ctx] {
|
ctx->Run([buf, &output, &ctx] {
|
||||||
auto view = buf->GetReadView(internal::types<GlTextureView>{}, /*plane=*/0);
|
auto view = buf->GetReadView(internal::types<GlTextureView>{}, /*plane=*/0);
|
||||||
ReadTexture(*ctx, view, buf->format(), output->MutablePixelData(),
|
ReadTexture(*ctx, view, buf->format(), output->MutablePixelData(),
|
||||||
|
@ -392,7 +393,9 @@ static std::shared_ptr<GpuBufferStorageCvPixelBuffer> ConvertToCvPixelBuffer(
|
||||||
std::shared_ptr<GlTextureBuffer> buf) {
|
std::shared_ptr<GlTextureBuffer> buf) {
|
||||||
auto output = absl::make_unique<GpuBufferStorageCvPixelBuffer>(
|
auto output = absl::make_unique<GpuBufferStorageCvPixelBuffer>(
|
||||||
buf->width(), buf->height(), buf->format());
|
buf->width(), buf->height(), buf->format());
|
||||||
buf->GetProducerContext()->Run([buf, &output] {
|
auto ctx = GlContext::GetCurrent();
|
||||||
|
if (!ctx) ctx = buf->GetProducerContext();
|
||||||
|
ctx->Run([buf, &output] {
|
||||||
TempGlFramebuffer framebuffer;
|
TempGlFramebuffer framebuffer;
|
||||||
auto src = buf->GetReadView(internal::types<GlTextureView>{}, /*plane=*/0);
|
auto src = buf->GetReadView(internal::types<GlTextureView>{}, /*plane=*/0);
|
||||||
auto dst =
|
auto dst =
|
||||||
|
|
Loading…
Reference in New Issue
Block a user