summaryrefslogtreecommitdiffstats
path: root/ppapi/examples
diff options
context:
space:
mode:
authorbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-11 20:01:47 +0000
committerbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-11 20:01:47 +0000
commita39616caeccc1ff73ea6b92f606bd979a7a7ff92 (patch)
treeb648414eaa298a6156f1fb6e19608342968ec8eb /ppapi/examples
parent21829851508887625109d3c6904867159ad7d1a3 (diff)
downloadchromium_src-a39616caeccc1ff73ea6b92f606bd979a7a7ff92.zip
chromium_src-a39616caeccc1ff73ea6b92f606bd979a7a7ff92.tar.gz
chromium_src-a39616caeccc1ff73ea6b92f606bd979a7a7ff92.tar.bz2
Pepper: Add GL_TEXTURE_EXTERNAL_OES texture target to PPB_VideoDecoder docs and example.
GL_TEXTURE_2D is used by x86 non-OSX platforms and by software fallback. GL_TEXTURE_RECTANGLE_ARB will be used on OSX hardware. GL_TEXTURE_EXTERNAL_OES is used on ARM ChromeOS. BUG=281689 Review URL: https://codereview.chromium.org/354763003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282674 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/examples')
-rw-r--r--ppapi/examples/video_decode/video_decode.cc31
1 files changed, 29 insertions, 2 deletions
diff --git a/ppapi/examples/video_decode/video_decode.cc b/ppapi/examples/video_decode/video_decode.cc
index 0e0c519..e104080 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,