Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Unified Diff: media/renderers/skcanvas_video_renderer.cc

Issue 1508903002: Use GrGLTextureInfo for Skia texture handles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ignore_gl_target
Patch Set: Address dcastagna's comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/renderers/skcanvas_video_renderer.cc
diff --git a/media/renderers/skcanvas_video_renderer.cc b/media/renderers/skcanvas_video_renderer.cc
index ec093da0a70feb3702507e4f1831e50cb616fa17..88b4eaeef4a128ff79d19e89a3eb8dfe37e70824 100644
--- a/media/renderers/skcanvas_video_renderer.cc
+++ b/media/renderers/skcanvas_video_renderer.cc
@@ -21,6 +21,7 @@
#include "third_party/skia/include/gpu/GrTexture.h"
#include "third_party/skia/include/gpu/GrTextureProvider.h"
#include "third_party/skia/include/gpu/SkGr.h"
+#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/skia_util.h"
@@ -94,7 +95,7 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameYUVTextures(
gfx::Size uv_tex_size((ya_tex_size.width() + 1) / 2,
(ya_tex_size.height() + 1) / 2);
- unsigned source_textures[3] = {0};
+ GrGLTextureInfo source_textures[] = {{0, 0}, {0, 0}, {0, 0}};
for (size_t i = 0; i < media::VideoFrame::NumPlanes(video_frame->format());
++i) {
// Get the texture from the mailbox and wrap it in a GrTexture.
@@ -103,7 +104,7 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameYUVTextures(
mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES ||
mailbox_holder.texture_target == GL_TEXTURE_RECTANGLE_ARB);
gl->WaitSyncTokenCHROMIUM(mailbox_holder.sync_token.GetConstData());
- source_textures[i] = gl->CreateAndConsumeTextureCHROMIUM(
+ source_textures[i].fID = gl->CreateAndConsumeTextureCHROMIUM(
mailbox_holder.texture_target, mailbox_holder.mailbox.name);
// TODO(dcastagna): avoid this copy once Skia supports native textures
@@ -114,22 +115,19 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameYUVTextures(
gl->GenTextures(1, &texture_copy);
DCHECK(texture_copy);
gl->BindTexture(GL_TEXTURE_2D, texture_copy);
- gl->CopyTextureCHROMIUM(GL_TEXTURE_2D, source_textures[i], texture_copy,
- GL_RGB, GL_UNSIGNED_BYTE, false, true, false);
+ gl->CopyTextureCHROMIUM(GL_TEXTURE_2D, source_textures[i].fID,
+ texture_copy, GL_RGB, GL_UNSIGNED_BYTE, false,
+ true, false);
- gl->DeleteTextures(1, &source_textures[i]);
- source_textures[i] = texture_copy;
+ gl->DeleteTextures(1, &source_textures[i].fID);
+ source_textures[i].fID = texture_copy;
+ source_textures[i].fTarget = GL_TEXTURE_2D;
}
}
- DCHECK_LE(source_textures[0],
- static_cast<unsigned>(std::numeric_limits<int>::max()));
- DCHECK_LE(source_textures[1],
- static_cast<unsigned>(std::numeric_limits<int>::max()));
- DCHECK_LE(source_textures[2],
- static_cast<unsigned>(std::numeric_limits<int>::max()));
- GrBackendObject handles[3] = {static_cast<int>(source_textures[0]),
- static_cast<int>(source_textures[1]),
- static_cast<int>(source_textures[2])};
+ GrBackendObject handles[3] = {
+ reinterpret_cast<GrBackendObject>(&source_textures[0]),
+ reinterpret_cast<GrBackendObject>(&source_textures[1]),
+ reinterpret_cast<GrBackendObject>(&source_textures[2])};
SkISize yuvSizes[] = {
{ya_tex_size.width(), ya_tex_size.height()},
@@ -146,7 +144,10 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameYUVTextures(
SkImage* img = SkImage::NewFromYUVTexturesCopy(context_3d.gr_context,
color_space, handles, yuvSizes,
kTopLeft_GrSurfaceOrigin);
- gl->DeleteTextures(3, source_textures);
+ for (size_t i = 0; i < media::VideoFrame::NumPlanes(video_frame->format());
+ ++i) {
+ gl->DeleteTextures(1, &source_textures[i].fID);
+ }
return skia::AdoptRef(img);
}
@@ -189,9 +190,10 @@ skia::RefPtr<SkImage> NewSkImageFromVideoFrameNative(
desc.fWidth = video_frame->coded_size().width();
desc.fHeight = video_frame->coded_size().height();
desc.fConfig = kRGBA_8888_GrPixelConfig;
- DCHECK_LE(source_texture,
- static_cast<unsigned>(std::numeric_limits<int>::max()));
- desc.fTextureHandle = static_cast<int>(source_texture);
+ GrGLTextureInfo sourceTextureInfo;
Daniele Castagna 2015/12/16 19:30:18 nit: the name should be all lower case, with under
bsalomon 2015/12/16 20:06:36 Done.
+ sourceTextureInfo.fID = source_texture;
+ sourceTextureInfo.fTarget = GL_TEXTURE_2D;
+ desc.fTextureHandle = reinterpret_cast<GrBackendObject>(&sourceTextureInfo);
return skia::AdoptRef(
SkImage::NewFromAdoptedTexture(context_3d.gr_context, desc));
}

Powered by Google App Engine
This is Rietveld 408576698