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

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

Issue 7467037: Made Destroy() followup more aggressive to test for races. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 5 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
Index: ppapi/examples/gles2/gles2.cc
diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc
index 24a97275dbf61469ae21b206fe7d8a7b9f3aeea0..e46f02dca3a84315e9a9bac3ddcf61d06e779ffc 100644
--- a/ppapi/examples/gles2/gles2.cc
+++ b/ppapi/examples/gles2/gles2.cc
@@ -86,6 +86,7 @@ class GLES2DemoInstance : public pp::Instance,
void DecodeNextNALU();
void GetNextNALUBoundary(size_t start_pos, size_t* end_pos);
void Render(const PP_PictureBuffer_Dev& buffer);
+ void DeleteOutstandingBitstreamBuffers();
// GL-related functions.
void InitGL();
@@ -93,6 +94,7 @@ class GLES2DemoInstance : public pp::Instance,
void CreateGLObjects();
void CreateShader(GLuint program, GLenum type, const char* source, int size);
void DeleteTexture(GLuint id);
+ void DeleteOutstandingTextures();
void PaintFinished(int32_t result, int picture_buffer_id);
// Log an error to the developer console and stderr (though the latter may be
@@ -173,10 +175,28 @@ GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module)
GLES2DemoInstance::~GLES2DemoInstance() {
delete video_decoder_; // May be NULL, which is fine.
+ DeleteOutstandingBitstreamBuffers();
+ DeleteOutstandingTextures();
delete surface_;
delete context_;
}
+void GLES2DemoInstance::DeleteOutstandingTextures() {
+ for (PictureBufferMap::iterator it = buffers_by_id_.begin();
+ it != buffers_by_id_.end(); ++it) {
+ DeleteTexture(it->second.texture_id);
+ }
+ buffers_by_id_.clear();
+}
+
+void GLES2DemoInstance::DeleteOutstandingBitstreamBuffers() {
+ for (BitstreamBufferMap::iterator it = bitstream_buffers_by_id_.begin();
+ it != bitstream_buffers_by_id_.end(); ++it) {
+ delete it->second;
+ }
+ bitstream_buffers_by_id_.clear();
+}
+
void GLES2DemoInstance::DidChangeView(
const pp::Rect& position, const pp::Rect& clip_ignored) {
if (position.width() == 0 || position.height() == 0)
@@ -213,6 +233,7 @@ void GLES2DemoInstance::DecoderBitstreamDone(
bitstream_buffers_by_id_.find(bitstream_buffer_id);
assert(it != bitstream_buffers_by_id_.end());
delete it->second;
+ bitstream_buffers_by_id_.erase(it);
DecodeNextNALUs();
}
@@ -263,7 +284,7 @@ void GLES2DemoInstance::DecodeNextNALU() {
size_t start_pos = encoded_data_next_pos_to_decode_;
size_t end_pos;
GetNextNALUBoundary(start_pos, &end_pos);
- pp::Buffer_Dev* buffer = new pp::Buffer_Dev (this, end_pos - start_pos);
+ pp::Buffer_Dev* buffer = new pp::Buffer_Dev(this, end_pos - start_pos);
PP_VideoBitstreamBuffer_Dev bitstream_buffer;
int id = ++next_bitstream_buffer_id_;
bitstream_buffer.id = id;

Powered by Google App Engine
This is Rietveld 408576698