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

Unified Diff: ppapi/examples/video_decode/video_decode.cc

Issue 354763003: Pepper: Add External_OES texture target to PPB_VideoDecoder docs and example. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months 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
« no previous file with comments | « ppapi/c/pp_codecs.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/examples/video_decode/video_decode.cc
diff --git a/ppapi/examples/video_decode/video_decode.cc b/ppapi/examples/video_decode/video_decode.cc
index 0e0c5197126506f8c1c391be26eb973ee6a5b10d..e104080c96f2311a30bca3cd655c4d2857563b06 100644
--- a/ppapi/examples/video_decode/video_decode.cc
+++ b/ppapi/examples/video_decode/video_decode.cc
@@ -113,6 +113,7 @@ class MyInstance : public pp::Instance, public pp::Graphics3DClient {
void CreateGLObjects();
void Create2DProgramOnce();
void CreateRectangleARBProgramOnce();
+ void CreateExternalOESProgramOnce();
Shader CreateProgram(const char* vertex_shader, const char* fragment_shader);
void CreateShader(GLuint program, GLenum type, const char* source, int size);
void PaintNextPicture();
@@ -145,6 +146,8 @@ class MyInstance : public pp::Instance, public pp::Graphics3DClient {
Shader shader_2d_;
// Shader program to draw GL_TEXTURE_RECTANGLE_ARB target.
Shader shader_rectangle_arb_;
+ // Shader program to draw GL_TEXTURE_EXTERNAL_OES target.
+ Shader shader_external_oes_;
};
class Decoder {
@@ -390,6 +393,8 @@ MyInstance::~MyInstance() {
gles2_if_->DeleteProgram(graphics_3d, shader_2d_.program);
if (shader_rectangle_arb_.program)
gles2_if_->DeleteProgram(graphics_3d, shader_rectangle_arb_.program);
+ if (shader_external_oes_.program)
+ gles2_if_->DeleteProgram(graphics_3d, shader_external_oes_.program);
for (DecoderList::iterator it = video_decoders_.begin();
it != video_decoders_.end();
@@ -478,14 +483,19 @@ void MyInstance::PaintNextPicture() {
gles2_if_->UseProgram(graphics_3d, shader_2d_.program);
gles2_if_->Uniform2f(
graphics_3d, shader_2d_.texcoord_scale_location, 1.0, 1.0);
- } else {
- assert(picture.texture_target == GL_TEXTURE_RECTANGLE_ARB);
+ } else if (picture.texture_target == GL_TEXTURE_RECTANGLE_ARB) {
CreateRectangleARBProgramOnce();
gles2_if_->UseProgram(graphics_3d, shader_rectangle_arb_.program);
gles2_if_->Uniform2f(graphics_3d,
shader_rectangle_arb_.texcoord_scale_location,
picture.texture_size.width,
picture.texture_size.height);
+ } else {
+ assert(picture.texture_target == GL_TEXTURE_EXTERNAL_OES);
+ CreateExternalOESProgramOnce();
+ gles2_if_->UseProgram(graphics_3d, shader_external_oes_.program);
+ gles2_if_->Uniform2f(
+ graphics_3d, shader_external_oes_.texcoord_scale_location, 1.0, 1.0);
}
gles2_if_->Viewport(graphics_3d, x, y, half_width, half_height);
@@ -630,6 +640,23 @@ void MyInstance::CreateRectangleARBProgramOnce() {
"}";
shader_rectangle_arb_ =
CreateProgram(kVertexShader, kFragmentShaderRectangle);
+ assertNoGLError();
+}
+
+void MyInstance::CreateExternalOESProgramOnce() {
+ if (shader_external_oes_.program)
+ return;
+ static const char kFragmentShaderExternal[] =
+ "#extension GL_OES_EGL_image_external : require\n"
+ "precision mediump float; \n"
+ "varying vec2 v_texCoord; \n"
+ "uniform samplerExternalOES s_texture; \n"
+ "void main() \n"
+ "{"
+ " gl_FragColor = texture2D(s_texture, v_texCoord); \n"
+ "}";
+ shader_external_oes_ = CreateProgram(kVertexShader, kFragmentShaderExternal);
+ assertNoGLError();
}
Shader MyInstance::CreateProgram(const char* vertex_shader,
« no previous file with comments | « ppapi/c/pp_codecs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698