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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 4246001: Saved offscreen textures are allocated GL_RGB when no alpha channel is reques... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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: gpu/command_buffer/service/gles2_cmd_decoder.cc
===================================================================
--- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 64773)
+++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy)
@@ -203,6 +203,10 @@
// destroying this object.
void Destroy();
+ // Invalidate the texture. This can be used when a context is lost and it is
+ // not possible to make it current in order to free the resource.
+ void Invalidate();
+
GLuint id() const {
return id_;
}
@@ -234,6 +238,10 @@
// this object.
void Destroy();
+ // Invalidate the render buffer. This can be used when a context is lost and
+ // it is not possible to make it current in order to free the resource.
+ void Invalidate();
+
GLuint id() const {
return id_;
}
@@ -267,6 +275,10 @@
// this object.
void Destroy();
+ // Invalidate the frame buffer. This can be used when a context is lost and it
+ // is not possible to make it current in order to free the resource.
+ void Invalidate();
+
// See glCheckFramebufferStatusEXT.
GLenum CheckStatus();
@@ -1369,6 +1381,7 @@
// used as the destination for multi-sample resolves.
scoped_ptr<FrameBuffer> offscreen_saved_frame_buffer_;
scoped_ptr<Texture> offscreen_saved_color_texture_;
+ GLenum offscreen_saved_color_format_;
scoped_ptr<Callback0::Type> swap_buffers_callback_;
@@ -1540,6 +1553,10 @@
}
}
+void Texture::Invalidate() {
+ id_ = 0;
+}
+
RenderBuffer::RenderBuffer(GLES2DecoderImpl* decoder)
: decoder_(decoder),
id_(0) {
@@ -1593,6 +1610,10 @@
}
}
+void RenderBuffer::Invalidate() {
+ id_ = 0;
+}
+
FrameBuffer::FrameBuffer(GLES2DecoderImpl* decoder)
: decoder_(decoder),
id_(0) {
@@ -1649,6 +1670,10 @@
}
}
+void FrameBuffer::Invalidate() {
+ id_ = 0;
+}
+
GLenum FrameBuffer::CheckStatus() {
DCHECK_NE(id_, 0u);
ScopedGLErrorSuppressor suppressor(decoder_);
@@ -1688,6 +1713,7 @@
offscreen_target_depth_format_(0),
offscreen_target_stencil_format_(0),
offscreen_target_samples_(0),
+ offscreen_saved_color_format_(0),
current_decoder_error_(error::kNoError),
use_shader_translator_(true),
validators_(group_->feature_info()->validators()),
@@ -1840,6 +1866,9 @@
}
}
+ offscreen_saved_color_format_ = attrib_parser.alpha_size_ > 0 ?
+ GL_RGBA : GL_RGB;
+
// Create the target frame buffer. This is the one that the client renders
// directly to.
offscreen_target_frame_buffer_.reset(new FrameBuffer(this));
@@ -2276,8 +2305,9 @@
}
if (parent_ || IsOffscreenBufferMultisampled()) {
- offscreen_saved_color_texture_->AllocateStorage(pending_offscreen_size_,
- GL_RGBA);
+ DCHECK(offscreen_saved_color_format_);
+ offscreen_saved_color_texture_->AllocateStorage(
+ pending_offscreen_size_, offscreen_saved_color_format_);
offscreen_saved_frame_buffer_->AttachRenderTexture(
offscreen_saved_color_texture_.get());
@@ -2343,7 +2373,10 @@
void GLES2DecoderImpl::Destroy() {
bool have_context = context_.get() && MakeCurrent();
- group_->set_have_context(have_context);
+
+ if (group_.get())
+ group_->set_have_context(have_context);
+
if (have_context) {
if (attrib_0_buffer_id_) {
glDeleteBuffersARB(1, &attrib_0_buffer_id_);
@@ -2364,40 +2397,20 @@
glDeleteFramebuffersEXT(1, &copy_texture_to_parent_texture_fb_);
}
- if (offscreen_target_frame_buffer_.get()) {
+ if (offscreen_target_frame_buffer_.get())
offscreen_target_frame_buffer_->Destroy();
- offscreen_target_frame_buffer_.reset();
- }
-
- if (offscreen_target_color_texture_.get()) {
+ if (offscreen_target_color_texture_.get())
offscreen_target_color_texture_->Destroy();
- offscreen_target_color_texture_.reset();
- }
-
- if (offscreen_target_color_render_buffer_.get()) {
+ if (offscreen_target_color_render_buffer_.get())
offscreen_target_color_render_buffer_->Destroy();
- offscreen_target_color_render_buffer_.reset();
- }
-
- if (offscreen_target_depth_render_buffer_.get()) {
+ if (offscreen_target_depth_render_buffer_.get())
offscreen_target_depth_render_buffer_->Destroy();
- offscreen_target_depth_render_buffer_.reset();
- }
-
- if (offscreen_target_stencil_render_buffer_.get()) {
+ if (offscreen_target_stencil_render_buffer_.get())
offscreen_target_stencil_render_buffer_->Destroy();
- offscreen_target_stencil_render_buffer_.reset();
- }
-
- if (offscreen_saved_frame_buffer_.get()) {
+ if (offscreen_saved_frame_buffer_.get())
offscreen_saved_frame_buffer_->Destroy();
- offscreen_saved_frame_buffer_.reset();
- }
-
- if (offscreen_saved_color_texture_.get()) {
+ if (offscreen_saved_color_texture_.get())
offscreen_saved_color_texture_->Destroy();
- offscreen_saved_color_texture_.reset();
- }
// must release the ContextGroup before destroying the context as its
// destructor uses GL.
@@ -2405,7 +2418,30 @@
context_->Destroy();
context_.reset();
+ } else {
+ if (offscreen_target_frame_buffer_.get())
+ offscreen_target_frame_buffer_->Invalidate();
+ if (offscreen_target_color_texture_.get())
+ offscreen_target_color_texture_->Invalidate();
+ if (offscreen_target_color_render_buffer_.get())
+ offscreen_target_color_render_buffer_->Invalidate();
+ if (offscreen_target_depth_render_buffer_.get())
+ offscreen_target_depth_render_buffer_->Invalidate();
+ if (offscreen_target_stencil_render_buffer_.get())
+ offscreen_target_stencil_render_buffer_->Invalidate();
+ if (offscreen_saved_frame_buffer_.get())
+ offscreen_saved_frame_buffer_->Invalidate();
+ if (offscreen_saved_color_texture_.get())
+ offscreen_saved_color_texture_->Invalidate();
}
+
+ offscreen_target_frame_buffer_.reset();
+ offscreen_target_color_texture_.reset();
+ offscreen_target_color_render_buffer_.reset();
+ offscreen_target_depth_render_buffer_.reset();
+ offscreen_target_stencil_render_buffer_.reset();
+ offscreen_saved_frame_buffer_.reset();
+ offscreen_saved_color_texture_.reset();
}
void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
« 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