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

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

Issue 8678027: Migrate gles2 from {Surface,Context}3D to Graphics3D. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/examples/gles2/gles2.cc
diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc
index f4030005af3ebd9a93adb45aa044a198e97399c0..220a6f4493a3039560085ca020c867b6485ac4e7 100644
--- a/ppapi/examples/gles2/gles2.cc
+++ b/ppapi/examples/gles2/gles2.cc
@@ -14,8 +14,6 @@
#include "ppapi/c/dev/ppb_console_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_opengles2.h"
-#include "ppapi/cpp/dev/context_3d_dev.h"
-#include "ppapi/cpp/dev/surface_3d_dev.h"
#include "ppapi/cpp/dev/video_decoder_client_dev.h"
#include "ppapi/cpp/dev/video_decoder_dev.h"
#include "ppapi/cpp/graphics_3d.h"
@@ -54,7 +52,7 @@ class GLES2DemoInstance : public pp::Instance,
// pp::Graphics3DClient implementation.
virtual void Graphics3DContextLost() {
// TODO(vrk/fischman): Properly reset after a lost graphics context. In
- // particular need to delete context_ & surface_ and re-create textures.
+ // particular need to delete context_ and re-create textures.
// Probably have to recreate the decoder from scratch, because old textures
// can still be outstanding in the decoder!
assert(!"Unexpectedly lost graphics context");
@@ -162,8 +160,7 @@ class GLES2DemoInstance : public pp::Instance,
const struct PPB_OpenGLES2* gles2_if_;
// Owned data.
- pp::Context3D_Dev* context_;
- pp::Surface3D_Dev* surface_;
+ pp::Graphics3D* context_;
typedef std::map<int, DecoderClient*> Decoders;
Decoders video_decoders_;
};
@@ -199,8 +196,7 @@ GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module)
first_frame_delivered_ticks_(-1),
swap_ticks_(0),
callback_factory_(this),
- context_(NULL),
- surface_(NULL) {
+ context_(NULL) {
assert((console_if_ = static_cast<const struct PPB_Console_Dev*>(
module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE))));
assert((core_if_ = static_cast<const struct PPB_Core*>(
@@ -215,7 +211,6 @@ GLES2DemoInstance::~GLES2DemoInstance() {
delete it->second;
}
video_decoders_.clear();
- delete surface_;
delete context_;
}
@@ -387,6 +382,7 @@ void GLES2DemoInstance::PictureReady(PP_Resource decoder,
x = plugin_size_.width() / kNumDecoders;
y = plugin_size_.height() / kNumDecoders;
}
+
gles2_if_->Viewport(context_->pp_resource(), x, y,
plugin_size_.width() / kNumDecoders,
plugin_size_.height() / kNumDecoders);
@@ -398,7 +394,7 @@ void GLES2DemoInstance::PictureReady(PP_Resource decoder,
callback_factory_.NewCallback(
&GLES2DemoInstance::PaintFinished, decoder, buffer.id);
last_swap_request_ticks_ = core_if_->GetTimeTicks();
- assert(surface_->SwapBuffers(cb) == PP_OK_COMPLETIONPENDING);
+ assert(context_->SwapBuffers(cb) == PP_OK_COMPLETIONPENDING);
}
void GLES2DemoInstance::EndOfStream(PP_Resource decoder) {
@@ -426,24 +422,28 @@ void GLES2DemoInstance::InitGL() {
assert(plugin_size_.width() && plugin_size_.height());
is_painting_ = false;
- assert(!context_ && !surface_);
- context_ = new pp::Context3D_Dev(*this, 0, pp::Context3D_Dev(), NULL);
- assert(!context_->is_null());
-
- int32_t surface_attributes[] = {
+ assert(!context_);
+ int32_t context_attributes[] = {
+ PP_GRAPHICS3DATTRIB_ALPHA_SIZE, 8,
+ PP_GRAPHICS3DATTRIB_BLUE_SIZE, 8,
+ PP_GRAPHICS3DATTRIB_GREEN_SIZE, 8,
+ PP_GRAPHICS3DATTRIB_RED_SIZE, 8,
+ PP_GRAPHICS3DATTRIB_DEPTH_SIZE, 0,
+ PP_GRAPHICS3DATTRIB_STENCIL_SIZE, 0,
+ PP_GRAPHICS3DATTRIB_SAMPLES, 0,
+ PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS, 0,
PP_GRAPHICS3DATTRIB_WIDTH, plugin_size_.width(),
PP_GRAPHICS3DATTRIB_HEIGHT, plugin_size_.height(),
- PP_GRAPHICS3DATTRIB_NONE
+ PP_GRAPHICS3DATTRIB_NONE,
};
- surface_ = new pp::Surface3D_Dev(*this, 0, surface_attributes);
- assert(!surface_->is_null());
-
- assert(!context_->BindSurfaces(*surface_, *surface_));
+ context_ = new pp::Graphics3D(this, context_attributes);
+ assert(!context_->is_null());
+ assert(BindGraphics(*context_));
// Clear color bit.
+ gles2_if_->ClearColor(context_->pp_resource(), 1, 0, 0, 1);
gles2_if_->Clear(context_->pp_resource(), GL_COLOR_BUFFER_BIT);
- assert(BindGraphics(*surface_));
assertNoGLError();
CreateGLObjects();
@@ -451,6 +451,7 @@ void GLES2DemoInstance::InitGL() {
void GLES2DemoInstance::PaintFinished(int32_t result, PP_Resource decoder,
int picture_buffer_id) {
+ assert(result == PP_OK);
swap_ticks_ += core_if_->GetTimeTicks() - last_swap_request_ticks_;
is_painting_ = false;
++num_frames_rendered_;
@@ -479,8 +480,7 @@ GLuint GLES2DemoInstance::CreateTexture(int32_t width, int32_t height) {
assertNoGLError();
// Assign parameters.
gles2_if_->ActiveTexture(context_->pp_resource(), GL_TEXTURE0);
- gles2_if_->BindTexture(
- context_->pp_resource(), GL_TEXTURE_2D, texture_id);
+ gles2_if_->BindTexture(context_->pp_resource(), GL_TEXTURE_2D, texture_id);
gles2_if_->TexParameteri(
context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
@@ -494,7 +494,6 @@ GLuint GLES2DemoInstance::CreateTexture(int32_t width, int32_t height) {
context_->pp_resource(), GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
- // Allocate texture.
gles2_if_->TexImage2D(
context_->pp_resource(), GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
@@ -537,7 +536,7 @@ void GLES2DemoInstance::CreateGLObjects() {
gles2_if_->DeleteProgram(context_->pp_resource(), program);
gles2_if_->Uniform1i(
context_->pp_resource(),
- gles2_if_->GetAttribLocation(
+ gles2_if_->GetUniformLocation(
context_->pp_resource(), program, "s_texture"), 0);
assertNoGLError();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698