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

Side by Side Diff: ppapi/examples/gles2/gles2.cc

Issue 7737013: Move PPAPI graphics3d and opengles interfaces out of Dev. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/cpp/instance.cc ('k') | ppapi/lib/gl/gles2/gl2ext_ppapi.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dev/ppb_opengles_dev.h"
16 #include "ppapi/c/pp_errors.h" 15 #include "ppapi/c/pp_errors.h"
16 #include "ppapi/c/ppb_opengles.h"
17 #include "ppapi/cpp/dev/context_3d_dev.h" 17 #include "ppapi/cpp/dev/context_3d_dev.h"
18 #include "ppapi/cpp/dev/graphics_3d_client_dev.h"
19 #include "ppapi/cpp/dev/graphics_3d_dev.h"
20 #include "ppapi/cpp/dev/surface_3d_dev.h" 18 #include "ppapi/cpp/dev/surface_3d_dev.h"
21 #include "ppapi/cpp/dev/video_decoder_client_dev.h" 19 #include "ppapi/cpp/dev/video_decoder_client_dev.h"
22 #include "ppapi/cpp/dev/video_decoder_dev.h" 20 #include "ppapi/cpp/dev/video_decoder_dev.h"
21 #include "ppapi/cpp/graphics_3d.h"
22 #include "ppapi/cpp/graphics_3d_client.h"
23 #include "ppapi/cpp/instance.h" 23 #include "ppapi/cpp/instance.h"
24 #include "ppapi/cpp/module.h" 24 #include "ppapi/cpp/module.h"
25 #include "ppapi/cpp/rect.h" 25 #include "ppapi/cpp/rect.h"
26 #include "ppapi/cpp/var.h" 26 #include "ppapi/cpp/var.h"
27 #include "ppapi/examples/gles2/testdata.h" 27 #include "ppapi/examples/gles2/testdata.h"
28 #include "ppapi/lib/gl/include/GLES2/gl2.h" 28 #include "ppapi/lib/gl/include/GLES2/gl2.h"
29 29
30 // Use assert as a poor-man's CHECK, even in non-debug mode. 30 // Use assert as a poor-man's CHECK, even in non-debug mode.
31 // Since <assert.h> redefines assert on every inclusion (it doesn't use 31 // Since <assert.h> redefines assert on every inclusion (it doesn't use
32 // include-guards), make sure this is the last file #include'd in this file. 32 // include-guards), make sure this is the last file #include'd in this file.
33 #undef NDEBUG 33 #undef NDEBUG
34 #include <assert.h> 34 #include <assert.h>
35 35
36 // Assert |context_| isn't holding any GL Errors. Done as a macro instead of a 36 // Assert |context_| isn't holding any GL Errors. Done as a macro instead of a
37 // function to preserve line number information in the failure message. 37 // function to preserve line number information in the failure message.
38 #define assertNoGLError() \ 38 #define assertNoGLError() \
39 assert(!gles2_if_->GetError(context_->pp_resource())); 39 assert(!gles2_if_->GetError(context_->pp_resource()));
40 40
41 namespace { 41 namespace {
42 42
43 class GLES2DemoInstance : public pp::Instance, 43 class GLES2DemoInstance : public pp::Instance,
44 public pp::Graphics3DClient_Dev, 44 public pp::Graphics3DClient,
45 public pp::VideoDecoderClient_Dev { 45 public pp::VideoDecoderClient_Dev {
46 public: 46 public:
47 GLES2DemoInstance(PP_Instance instance, pp::Module* module); 47 GLES2DemoInstance(PP_Instance instance, pp::Module* module);
48 virtual ~GLES2DemoInstance(); 48 virtual ~GLES2DemoInstance();
49 49
50 // pp::Instance implementation (see PPP_Instance). 50 // pp::Instance implementation (see PPP_Instance).
51 virtual void DidChangeView(const pp::Rect& position, 51 virtual void DidChangeView(const pp::Rect& position,
52 const pp::Rect& clip_ignored); 52 const pp::Rect& clip_ignored);
53 53
54 // pp::Graphics3DClient_Dev implementation. 54 // pp::Graphics3DClient implementation.
55 virtual void Graphics3DContextLost() { 55 virtual void Graphics3DContextLost() {
56 // TODO(vrk/fischman): Properly reset after a lost graphics context. In 56 // TODO(vrk/fischman): Properly reset after a lost graphics context. In
57 // particular need to delete context_ & surface_ and re-create textures. 57 // particular need to delete context_ & surface_ and re-create textures.
58 // Probably have to recreate the decoder from scratch, because old textures 58 // Probably have to recreate the decoder from scratch, because old textures
59 // can still be outstanding in the decoder! 59 // can still be outstanding in the decoder!
60 assert(!"Unexpectedly lost graphics context"); 60 assert(!"Unexpectedly lost graphics context");
61 } 61 }
62 62
63 // pp::VideoDecoderClient_Dev implementation. 63 // pp::VideoDecoderClient_Dev implementation.
64 virtual void ProvidePictureBuffers(PP_Resource decoder, 64 virtual void ProvidePictureBuffers(PP_Resource decoder,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 std::list<std::pair<PP_Resource, PP_Picture_Dev> > pictures_pending_paint_; 152 std::list<std::pair<PP_Resource, PP_Picture_Dev> > pictures_pending_paint_;
153 int num_frames_rendered_; 153 int num_frames_rendered_;
154 PP_TimeTicks first_frame_delivered_ticks_; 154 PP_TimeTicks first_frame_delivered_ticks_;
155 PP_TimeTicks last_swap_request_ticks_; 155 PP_TimeTicks last_swap_request_ticks_;
156 PP_TimeTicks swap_ticks_; 156 PP_TimeTicks swap_ticks_;
157 pp::CompletionCallbackFactory<GLES2DemoInstance> callback_factory_; 157 pp::CompletionCallbackFactory<GLES2DemoInstance> callback_factory_;
158 158
159 // Unowned pointers. 159 // Unowned pointers.
160 const struct PPB_Console_Dev* console_if_; 160 const struct PPB_Console_Dev* console_if_;
161 const struct PPB_Core* core_if_; 161 const struct PPB_Core* core_if_;
162 const struct PPB_OpenGLES2_Dev* gles2_if_; 162 const struct PPB_OpenGLES2* gles2_if_;
163 163
164 // Owned data. 164 // Owned data.
165 pp::Context3D_Dev* context_; 165 pp::Context3D_Dev* context_;
166 pp::Surface3D_Dev* surface_; 166 pp::Surface3D_Dev* surface_;
167 typedef std::map<int, DecoderClient*> Decoders; 167 typedef std::map<int, DecoderClient*> Decoders;
168 Decoders video_decoders_; 168 Decoders video_decoders_;
169 }; 169 };
170 170
171 GLES2DemoInstance::DecoderClient::DecoderClient(GLES2DemoInstance* gles2, 171 GLES2DemoInstance::DecoderClient::DecoderClient(GLES2DemoInstance* gles2,
172 pp::VideoDecoder_Dev* decoder) 172 pp::VideoDecoder_Dev* decoder)
(...skipping 13 matching lines...) Expand all
186 bitstream_buffers_by_id_.clear(); 186 bitstream_buffers_by_id_.clear();
187 187
188 for (PictureBufferMap::iterator it = picture_buffers_by_id_.begin(); 188 for (PictureBufferMap::iterator it = picture_buffers_by_id_.begin();
189 it != picture_buffers_by_id_.end(); ++it) { 189 it != picture_buffers_by_id_.end(); ++it) {
190 gles2_->DeleteTexture(it->second.texture_id); 190 gles2_->DeleteTexture(it->second.texture_id);
191 } 191 }
192 picture_buffers_by_id_.clear(); 192 picture_buffers_by_id_.clear();
193 } 193 }
194 194
195 GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module) 195 GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module)
196 : pp::Instance(instance), pp::Graphics3DClient_Dev(this), 196 : pp::Instance(instance), pp::Graphics3DClient(this),
197 pp::VideoDecoderClient_Dev(this), 197 pp::VideoDecoderClient_Dev(this),
198 num_frames_rendered_(0), 198 num_frames_rendered_(0),
199 first_frame_delivered_ticks_(-1), 199 first_frame_delivered_ticks_(-1),
200 swap_ticks_(0), 200 swap_ticks_(0),
201 callback_factory_(this), 201 callback_factory_(this),
202 context_(NULL), 202 context_(NULL),
203 surface_(NULL) { 203 surface_(NULL) {
204 assert((console_if_ = static_cast<const struct PPB_Console_Dev*>( 204 assert((console_if_ = static_cast<const struct PPB_Console_Dev*>(
205 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE)))); 205 module->GetBrowserInterface(PPB_CONSOLE_DEV_INTERFACE))));
206 assert((core_if_ = static_cast<const struct PPB_Core*>( 206 assert((core_if_ = static_cast<const struct PPB_Core*>(
207 module->GetBrowserInterface(PPB_CORE_INTERFACE)))); 207 module->GetBrowserInterface(PPB_CORE_INTERFACE))));
208 assert((gles2_if_ = static_cast<const struct PPB_OpenGLES2_Dev*>( 208 assert((gles2_if_ = static_cast<const struct PPB_OpenGLES2*>(
209 module->GetBrowserInterface(PPB_OPENGLES2_DEV_INTERFACE)))); 209 module->GetBrowserInterface(PPB_OPENGLES2_INTERFACE))));
210 } 210 }
211 211
212 GLES2DemoInstance::~GLES2DemoInstance() { 212 GLES2DemoInstance::~GLES2DemoInstance() {
213 for (Decoders::iterator it = video_decoders_.begin(); 213 for (Decoders::iterator it = video_decoders_.begin();
214 it != video_decoders_.end(); ++it) { 214 it != video_decoders_.end(); ++it) {
215 delete it->second; 215 delete it->second;
216 } 216 }
217 video_decoders_.clear(); 217 video_decoders_.clear();
218 delete surface_; 218 delete surface_;
219 delete context_; 219 delete context_;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 gles2_if_->DeleteShader(context_->pp_resource(), shader); 578 gles2_if_->DeleteShader(context_->pp_resource(), shader);
579 } 579 }
580 } // anonymous namespace 580 } // anonymous namespace
581 581
582 namespace pp { 582 namespace pp {
583 // Factory function for your specialization of the Module object. 583 // Factory function for your specialization of the Module object.
584 Module* CreateModule() { 584 Module* CreateModule() {
585 return new GLES2DemoModule(); 585 return new GLES2DemoModule();
586 } 586 }
587 } // namespace pp 587 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/instance.cc ('k') | ppapi/lib/gl/gles2/gl2ext_ppapi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698