| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "ppapi/c/dev/ppb_console_dev.h" | 14 #include "ppapi/c/dev/ppb_console_dev.h" |
| 15 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
| 16 #include "ppapi/c/ppb_opengles2.h" | 16 #include "ppapi/c/ppb_opengles2.h" |
| 17 #include "ppapi/cpp/dev/context_3d_dev.h" | |
| 18 #include "ppapi/cpp/dev/surface_3d_dev.h" | |
| 19 #include "ppapi/cpp/dev/video_decoder_client_dev.h" | 17 #include "ppapi/cpp/dev/video_decoder_client_dev.h" |
| 20 #include "ppapi/cpp/dev/video_decoder_dev.h" | 18 #include "ppapi/cpp/dev/video_decoder_dev.h" |
| 21 #include "ppapi/cpp/graphics_3d.h" | 19 #include "ppapi/cpp/graphics_3d.h" |
| 22 #include "ppapi/cpp/graphics_3d_client.h" | 20 #include "ppapi/cpp/graphics_3d_client.h" |
| 23 #include "ppapi/cpp/instance.h" | 21 #include "ppapi/cpp/instance.h" |
| 24 #include "ppapi/cpp/module.h" | 22 #include "ppapi/cpp/module.h" |
| 25 #include "ppapi/cpp/rect.h" | 23 #include "ppapi/cpp/rect.h" |
| 26 #include "ppapi/cpp/var.h" | 24 #include "ppapi/cpp/var.h" |
| 27 #include "ppapi/examples/gles2/testdata.h" | 25 #include "ppapi/examples/gles2/testdata.h" |
| 28 #include "ppapi/lib/gl/include/GLES2/gl2.h" | 26 #include "ppapi/lib/gl/include/GLES2/gl2.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 47 GLES2DemoInstance(PP_Instance instance, pp::Module* module); | 45 GLES2DemoInstance(PP_Instance instance, pp::Module* module); |
| 48 virtual ~GLES2DemoInstance(); | 46 virtual ~GLES2DemoInstance(); |
| 49 | 47 |
| 50 // pp::Instance implementation (see PPP_Instance). | 48 // pp::Instance implementation (see PPP_Instance). |
| 51 virtual void DidChangeView(const pp::Rect& position, | 49 virtual void DidChangeView(const pp::Rect& position, |
| 52 const pp::Rect& clip_ignored); | 50 const pp::Rect& clip_ignored); |
| 53 | 51 |
| 54 // pp::Graphics3DClient implementation. | 52 // pp::Graphics3DClient implementation. |
| 55 virtual void Graphics3DContextLost() { | 53 virtual void Graphics3DContextLost() { |
| 56 // TODO(vrk/fischman): Properly reset after a lost graphics context. In | 54 // TODO(vrk/fischman): Properly reset after a lost graphics context. In |
| 57 // particular need to delete context_ & surface_ and re-create textures. | 55 // particular need to delete context_ and re-create textures. |
| 58 // Probably have to recreate the decoder from scratch, because old textures | 56 // Probably have to recreate the decoder from scratch, because old textures |
| 59 // can still be outstanding in the decoder! | 57 // can still be outstanding in the decoder! |
| 60 assert(!"Unexpectedly lost graphics context"); | 58 assert(!"Unexpectedly lost graphics context"); |
| 61 } | 59 } |
| 62 | 60 |
| 63 // pp::VideoDecoderClient_Dev implementation. | 61 // pp::VideoDecoderClient_Dev implementation. |
| 64 virtual void ProvidePictureBuffers(PP_Resource decoder, | 62 virtual void ProvidePictureBuffers(PP_Resource decoder, |
| 65 uint32_t req_num_of_bufs, | 63 uint32_t req_num_of_bufs, |
| 66 const PP_Size& dimensions); | 64 const PP_Size& dimensions); |
| 67 virtual void DismissPictureBuffer(PP_Resource decoder, | 65 virtual void DismissPictureBuffer(PP_Resource decoder, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 PP_TimeTicks last_swap_request_ticks_; | 153 PP_TimeTicks last_swap_request_ticks_; |
| 156 PP_TimeTicks swap_ticks_; | 154 PP_TimeTicks swap_ticks_; |
| 157 pp::CompletionCallbackFactory<GLES2DemoInstance> callback_factory_; | 155 pp::CompletionCallbackFactory<GLES2DemoInstance> callback_factory_; |
| 158 | 156 |
| 159 // Unowned pointers. | 157 // Unowned pointers. |
| 160 const struct PPB_Console_Dev* console_if_; | 158 const struct PPB_Console_Dev* console_if_; |
| 161 const struct PPB_Core* core_if_; | 159 const struct PPB_Core* core_if_; |
| 162 const struct PPB_OpenGLES2* gles2_if_; | 160 const struct PPB_OpenGLES2* gles2_if_; |
| 163 | 161 |
| 164 // Owned data. | 162 // Owned data. |
| 165 pp::Context3D_Dev* context_; | 163 pp::Graphics3D* context_; |
| 166 pp::Surface3D_Dev* surface_; | |
| 167 typedef std::map<int, DecoderClient*> Decoders; | 164 typedef std::map<int, DecoderClient*> Decoders; |
| 168 Decoders video_decoders_; | 165 Decoders video_decoders_; |
| 169 }; | 166 }; |
| 170 | 167 |
| 171 GLES2DemoInstance::DecoderClient::DecoderClient(GLES2DemoInstance* gles2, | 168 GLES2DemoInstance::DecoderClient::DecoderClient(GLES2DemoInstance* gles2, |
| 172 pp::VideoDecoder_Dev* decoder) | 169 pp::VideoDecoder_Dev* decoder) |
| 173 : gles2_(gles2), decoder_(decoder), callback_factory_(this), | 170 : gles2_(gles2), decoder_(decoder), callback_factory_(this), |
| 174 next_picture_buffer_id_(0), | 171 next_picture_buffer_id_(0), |
| 175 next_bitstream_buffer_id_(0), encoded_data_next_pos_to_decode_(0) { | 172 next_bitstream_buffer_id_(0), encoded_data_next_pos_to_decode_(0) { |
| 176 }; | 173 }; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 192 picture_buffers_by_id_.clear(); | 189 picture_buffers_by_id_.clear(); |
| 193 } | 190 } |
| 194 | 191 |
| 195 GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module) | 192 GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module) |
| 196 : pp::Instance(instance), pp::Graphics3DClient(this), | 193 : pp::Instance(instance), pp::Graphics3DClient(this), |
| 197 pp::VideoDecoderClient_Dev(this), | 194 pp::VideoDecoderClient_Dev(this), |
| 198 num_frames_rendered_(0), | 195 num_frames_rendered_(0), |
| 199 first_frame_delivered_ticks_(-1), | 196 first_frame_delivered_ticks_(-1), |
| 200 swap_ticks_(0), | 197 swap_ticks_(0), |
| 201 callback_factory_(this), | 198 callback_factory_(this), |
| 202 context_(NULL), | 199 context_(NULL) { |
| 203 surface_(NULL) { | |
| 204 assert((console_if_ = static_cast<const struct PPB_Console_Dev*>( | 200 assert((console_if_ = static_cast<const struct PPB_Console_Dev*>( |
| 205 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)))); | 201 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)))); |
| 206 assert((core_if_ = static_cast<const struct PPB_Core*>( | 202 assert((core_if_ = static_cast<const struct PPB_Core*>( |
| 207 module->GetBrowserInterface(PPB_CORE_INTERFACE)))); | 203 module->GetBrowserInterface(PPB_CORE_INTERFACE)))); |
| 208 assert((gles2_if_ = static_cast<const struct PPB_OpenGLES2*>( | 204 assert((gles2_if_ = static_cast<const struct PPB_OpenGLES2*>( |
| 209 module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE)))); | 205 module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE)))); |
| 210 } | 206 } |
| 211 | 207 |
| 212 GLES2DemoInstance::~GLES2DemoInstance() { | 208 GLES2DemoInstance::~GLES2DemoInstance() { |
| 213 for (Decoders::iterator it = video_decoders_.begin(); | 209 for (Decoders::iterator it = video_decoders_.begin(); |
| 214 it != video_decoders_.end(); ++it) { | 210 it != video_decoders_.end(); ++it) { |
| 215 delete it->second; | 211 delete it->second; |
| 216 } | 212 } |
| 217 video_decoders_.clear(); | 213 video_decoders_.clear(); |
| 218 delete surface_; | |
| 219 delete context_; | 214 delete context_; |
| 220 } | 215 } |
| 221 | 216 |
| 222 void GLES2DemoInstance::DidChangeView( | 217 void GLES2DemoInstance::DidChangeView( |
| 223 const pp::Rect& position, const pp::Rect& clip_ignored) { | 218 const pp::Rect& position, const pp::Rect& clip_ignored) { |
| 224 if (position.width() == 0 || position.height() == 0) | 219 if (position.width() == 0 || position.height() == 0) |
| 225 return; | 220 return; |
| 226 if (plugin_size_.width()) { | 221 if (plugin_size_.width()) { |
| 227 assert(position.size() == plugin_size_); | 222 assert(position.size() == plugin_size_); |
| 228 return; | 223 return; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 const PP_PictureBuffer_Dev& buffer = | 375 const PP_PictureBuffer_Dev& buffer = |
| 381 client->GetPictureBufferById(picture.picture_buffer_id); | 376 client->GetPictureBufferById(picture.picture_buffer_id); |
| 382 assert(!is_painting_); | 377 assert(!is_painting_); |
| 383 is_painting_ = true; | 378 is_painting_ = true; |
| 384 int x = 0; | 379 int x = 0; |
| 385 int y = 0; | 380 int y = 0; |
| 386 if (client != video_decoders_.begin()->second) { | 381 if (client != video_decoders_.begin()->second) { |
| 387 x = plugin_size_.width() / kNumDecoders; | 382 x = plugin_size_.width() / kNumDecoders; |
| 388 y = plugin_size_.height() / kNumDecoders; | 383 y = plugin_size_.height() / kNumDecoders; |
| 389 } | 384 } |
| 385 |
| 390 gles2_if_->Viewport(context_->pp_resource(), x, y, | 386 gles2_if_->Viewport(context_->pp_resource(), x, y, |
| 391 plugin_size_.width() / kNumDecoders, | 387 plugin_size_.width() / kNumDecoders, |
| 392 plugin_size_.height() / kNumDecoders); | 388 plugin_size_.height() / kNumDecoders); |
| 393 gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); | 389 gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); |
| 394 gles2_if_->BindTexture( | 390 gles2_if_->BindTexture( |
| 395 context_->pp_resource(), GL_TEXTURE_2D, buffer.texture_id); | 391 context_->pp_resource(), GL_TEXTURE_2D, buffer.texture_id); |
| 396 gles2_if_->DrawArrays(context_->pp_resource(), GL_TRIANGLE_STRIP, 0, 4); | 392 gles2_if_->DrawArrays(context_->pp_resource(), GL_TRIANGLE_STRIP, 0, 4); |
| 397 pp::CompletionCallback cb = | 393 pp::CompletionCallback cb = |
| 398 callback_factory_.NewCallback( | 394 callback_factory_.NewCallback( |
| 399 &GLES2DemoInstance::PaintFinished, decoder, buffer.id); | 395 &GLES2DemoInstance::PaintFinished, decoder, buffer.id); |
| 400 last_swap_request_ticks_ = core_if_->GetTimeTicks(); | 396 last_swap_request_ticks_ = core_if_->GetTimeTicks(); |
| 401 assert(surface_->SwapBuffers(cb) == PP_OK_COMPLETIONPENDING); | 397 assert(context_->SwapBuffers(cb) == PP_OK_COMPLETIONPENDING); |
| 402 } | 398 } |
| 403 | 399 |
| 404 void GLES2DemoInstance::EndOfStream(PP_Resource decoder) { | 400 void GLES2DemoInstance::EndOfStream(PP_Resource decoder) { |
| 405 } | 401 } |
| 406 | 402 |
| 407 void GLES2DemoInstance::NotifyError(PP_Resource decoder, | 403 void GLES2DemoInstance::NotifyError(PP_Resource decoder, |
| 408 PP_VideoDecodeError_Dev error) { | 404 PP_VideoDecodeError_Dev error) { |
| 409 LogError(this).s() << "Received error: " << error; | 405 LogError(this).s() << "Received error: " << error; |
| 410 assert(!"Unexpected error; see stderr for details"); | 406 assert(!"Unexpected error; see stderr for details"); |
| 411 } | 407 } |
| 412 | 408 |
| 413 // This object is the global object representing this plugin library as long | 409 // This object is the global object representing this plugin library as long |
| 414 // as it is loaded. | 410 // as it is loaded. |
| 415 class GLES2DemoModule : public pp::Module { | 411 class GLES2DemoModule : public pp::Module { |
| 416 public: | 412 public: |
| 417 GLES2DemoModule() : pp::Module() {} | 413 GLES2DemoModule() : pp::Module() {} |
| 418 virtual ~GLES2DemoModule() {} | 414 virtual ~GLES2DemoModule() {} |
| 419 | 415 |
| 420 virtual pp::Instance* CreateInstance(PP_Instance instance) { | 416 virtual pp::Instance* CreateInstance(PP_Instance instance) { |
| 421 return new GLES2DemoInstance(instance, this); | 417 return new GLES2DemoInstance(instance, this); |
| 422 } | 418 } |
| 423 }; | 419 }; |
| 424 | 420 |
| 425 void GLES2DemoInstance::InitGL() { | 421 void GLES2DemoInstance::InitGL() { |
| 426 assert(plugin_size_.width() && plugin_size_.height()); | 422 assert(plugin_size_.width() && plugin_size_.height()); |
| 427 is_painting_ = false; | 423 is_painting_ = false; |
| 428 | 424 |
| 429 assert(!context_ && !surface_); | 425 assert(!context_); |
| 430 context_ = new pp::Context3D_Dev(*this, 0, pp::Context3D_Dev(), NULL); | 426 int32_t context_attributes[] = { |
| 431 assert(!context_->is_null()); | 427 PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8, |
| 432 | 428 PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8, |
| 433 int32_t surface_attributes[] = { | 429 PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8, |
| 430 PP_GRAPHICS3DATTRIB_RED_SIZE, 8, |
| 431 PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 0, |
| 432 PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0, |
| 433 PP_GRAPHICS3DATTRIB_SAMPLES, 0, |
| 434 PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0, |
| 434 PP_GRAPHICS3DATTRIB_WIDTH, plugin_size_.width(), | 435 PP_GRAPHICS3DATTRIB_WIDTH, plugin_size_.width(), |
| 435 PP_GRAPHICS3DATTRIB_HEIGHT, plugin_size_.height(), | 436 PP_GRAPHICS3DATTRIB_HEIGHT, plugin_size_.height(), |
| 436 PP_GRAPHICS3DATTRIB_NONE | 437 PP_GRAPHICS3DATTRIB_NONE, |
| 437 }; | 438 }; |
| 438 surface_ = new pp::Surface3D_Dev(*this, 0, surface_attributes); | 439 context_ = new pp::Graphics3D(this, context_attributes); |
| 439 assert(!surface_->is_null()); | 440 assert(!context_->is_null()); |
| 440 | 441 assert(BindGraphics(*context_)); |
| 441 assert(!context_->BindSurfaces(*surface_, *surface_)); | |
| 442 | 442 |
| 443 // Clear color bit. | 443 // Clear color bit. |
| 444 gles2_if_->ClearColor(context_->pp_resource(), 1, 0, 0, 1); |
| 444 gles2_if_->Clear(context_->pp_resource(), GL_COLOR_BUFFER_BIT); | 445 gles2_if_->Clear(context_->pp_resource(), GL_COLOR_BUFFER_BIT); |
| 445 | 446 |
| 446 assert(BindGraphics(*surface_)); | |
| 447 assertNoGLError(); | 447 assertNoGLError(); |
| 448 | 448 |
| 449 CreateGLObjects(); | 449 CreateGLObjects(); |
| 450 } | 450 } |
| 451 | 451 |
| 452 void GLES2DemoInstance::PaintFinished(int32_t result, PP_Resource decoder, | 452 void GLES2DemoInstance::PaintFinished(int32_t result, PP_Resource decoder, |
| 453 int picture_buffer_id) { | 453 int picture_buffer_id) { |
| 454 assert(result == PP_OK); |
| 454 swap_ticks_ += core_if_->GetTimeTicks() - last_swap_request_ticks_; | 455 swap_ticks_ += core_if_->GetTimeTicks() - last_swap_request_ticks_; |
| 455 is_painting_ = false; | 456 is_painting_ = false; |
| 456 ++num_frames_rendered_; | 457 ++num_frames_rendered_; |
| 457 if (num_frames_rendered_ % 50 == 0) { | 458 if (num_frames_rendered_ % 50 == 0) { |
| 458 double elapsed = core_if_->GetTimeTicks() - first_frame_delivered_ticks_; | 459 double elapsed = core_if_->GetTimeTicks() - first_frame_delivered_ticks_; |
| 459 double fps = (elapsed > 0) ? num_frames_rendered_ / elapsed : 1000; | 460 double fps = (elapsed > 0) ? num_frames_rendered_ / elapsed : 1000; |
| 460 double ms_per_swap = (swap_ticks_ * 1e3) / num_frames_rendered_; | 461 double ms_per_swap = (swap_ticks_ * 1e3) / num_frames_rendered_; |
| 461 LogError(this).s() << "Rendered frames: " << num_frames_rendered_ | 462 LogError(this).s() << "Rendered frames: " << num_frames_rendered_ |
| 462 << ", fps: " << fps << ", with average ms/swap of: " | 463 << ", fps: " << fps << ", with average ms/swap of: " |
| 463 << ms_per_swap; | 464 << ms_per_swap; |
| 464 } | 465 } |
| 465 DecoderClient* client = video_decoders_[decoder]; | 466 DecoderClient* client = video_decoders_[decoder]; |
| 466 if (client && client->decoder()) | 467 if (client && client->decoder()) |
| 467 client->decoder()->ReusePictureBuffer(picture_buffer_id); | 468 client->decoder()->ReusePictureBuffer(picture_buffer_id); |
| 468 if (!pictures_pending_paint_.empty()) { | 469 if (!pictures_pending_paint_.empty()) { |
| 469 std::pair<PP_Resource, PP_Picture_Dev> decoder_picture = | 470 std::pair<PP_Resource, PP_Picture_Dev> decoder_picture = |
| 470 pictures_pending_paint_.front(); | 471 pictures_pending_paint_.front(); |
| 471 pictures_pending_paint_.pop_front(); | 472 pictures_pending_paint_.pop_front(); |
| 472 PictureReady(decoder_picture.first, decoder_picture.second); | 473 PictureReady(decoder_picture.first, decoder_picture.second); |
| 473 } | 474 } |
| 474 } | 475 } |
| 475 | 476 |
| 476 GLuint GLES2DemoInstance::CreateTexture(int32_t width, int32_t height) { | 477 GLuint GLES2DemoInstance::CreateTexture(int32_t width, int32_t height) { |
| 477 GLuint texture_id; | 478 GLuint texture_id; |
| 478 gles2_if_->GenTextures(context_->pp_resource(), 1, &texture_id); | 479 gles2_if_->GenTextures(context_->pp_resource(), 1, &texture_id); |
| 479 assertNoGLError(); | 480 assertNoGLError(); |
| 480 // Assign parameters. | 481 // Assign parameters. |
| 481 gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); | 482 gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0); |
| 482 gles2_if_->BindTexture( | 483 gles2_if_->BindTexture(context_->pp_resource(), GL_TEXTURE_2D, texture_id); |
| 483 context_->pp_resource(), GL_TEXTURE_2D, texture_id); | |
| 484 gles2_if_->TexParameteri( | 484 gles2_if_->TexParameteri( |
| 485 context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, | 485 context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, |
| 486 GL_NEAREST); | 486 GL_NEAREST); |
| 487 gles2_if_->TexParameteri( | 487 gles2_if_->TexParameteri( |
| 488 context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, | 488 context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, |
| 489 GL_NEAREST); | 489 GL_NEAREST); |
| 490 gles2_if_->TexParameterf( | 490 gles2_if_->TexParameterf( |
| 491 context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, | 491 context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, |
| 492 GL_CLAMP_TO_EDGE); | 492 GL_CLAMP_TO_EDGE); |
| 493 gles2_if_->TexParameterf( | 493 gles2_if_->TexParameterf( |
| 494 context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, | 494 context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, |
| 495 GL_CLAMP_TO_EDGE); | 495 GL_CLAMP_TO_EDGE); |
| 496 | 496 |
| 497 // Allocate texture. | |
| 498 gles2_if_->TexImage2D( | 497 gles2_if_->TexImage2D( |
| 499 context_->pp_resource(), GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, | 498 context_->pp_resource(), GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, |
| 500 GL_RGBA, GL_UNSIGNED_BYTE, NULL); | 499 GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
| 501 assertNoGLError(); | 500 assertNoGLError(); |
| 502 return texture_id; | 501 return texture_id; |
| 503 } | 502 } |
| 504 | 503 |
| 505 void GLES2DemoInstance::DeleteTexture(GLuint id) { | 504 void GLES2DemoInstance::DeleteTexture(GLuint id) { |
| 506 gles2_if_->DeleteTextures(context_->pp_resource(), 1, &id); | 505 gles2_if_->DeleteTextures(context_->pp_resource(), 1, &id); |
| 507 } | 506 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 530 // Create shader program. | 529 // Create shader program. |
| 531 GLuint program = gles2_if_->CreateProgram(context_->pp_resource()); | 530 GLuint program = gles2_if_->CreateProgram(context_->pp_resource()); |
| 532 CreateShader(program, GL_VERTEX_SHADER, kVertexShader, sizeof(kVertexShader)); | 531 CreateShader(program, GL_VERTEX_SHADER, kVertexShader, sizeof(kVertexShader)); |
| 533 CreateShader( | 532 CreateShader( |
| 534 program, GL_FRAGMENT_SHADER, kFragmentShader, sizeof(kFragmentShader)); | 533 program, GL_FRAGMENT_SHADER, kFragmentShader, sizeof(kFragmentShader)); |
| 535 gles2_if_->LinkProgram(context_->pp_resource(), program); | 534 gles2_if_->LinkProgram(context_->pp_resource(), program); |
| 536 gles2_if_->UseProgram(context_->pp_resource(), program); | 535 gles2_if_->UseProgram(context_->pp_resource(), program); |
| 537 gles2_if_->DeleteProgram(context_->pp_resource(), program); | 536 gles2_if_->DeleteProgram(context_->pp_resource(), program); |
| 538 gles2_if_->Uniform1i( | 537 gles2_if_->Uniform1i( |
| 539 context_->pp_resource(), | 538 context_->pp_resource(), |
| 540 gles2_if_->GetAttribLocation( | 539 gles2_if_->GetUniformLocation( |
| 541 context_->pp_resource(), program, "s_texture"), 0); | 540 context_->pp_resource(), program, "s_texture"), 0); |
| 542 assertNoGLError(); | 541 assertNoGLError(); |
| 543 | 542 |
| 544 // Assign vertex positions and texture coordinates to buffers for use in | 543 // Assign vertex positions and texture coordinates to buffers for use in |
| 545 // shader program. | 544 // shader program. |
| 546 static const float kVertices[] = { | 545 static const float kVertices[] = { |
| 547 -1, 1, -1, -1, 1, 1, 1, -1, // Position coordinates. | 546 -1, 1, -1, -1, 1, 1, 1, -1, // Position coordinates. |
| 548 0, 1, 0, 0, 1, 1, 1, 0, // Texture coordinates. | 547 0, 1, 0, 0, 1, 1, 1, 0, // Texture coordinates. |
| 549 }; | 548 }; |
| 550 | 549 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 578 gles2_if_->DeleteShader(context_->pp_resource(), shader); | 577 gles2_if_->DeleteShader(context_->pp_resource(), shader); |
| 579 } | 578 } |
| 580 } // anonymous namespace | 579 } // anonymous namespace |
| 581 | 580 |
| 582 namespace pp { | 581 namespace pp { |
| 583 // Factory function for your specialization of the Module object. | 582 // Factory function for your specialization of the Module object. |
| 584 Module* CreateModule() { | 583 Module* CreateModule() { |
| 585 return new GLES2DemoModule(); | 584 return new GLES2DemoModule(); |
| 586 } | 585 } |
| 587 } // namespace pp | 586 } // namespace pp |
| OLD | NEW |