summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc52
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.h4
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_mock.h3
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc2
-rw-r--r--gpu/demos/framework/window.cc1
-rw-r--r--gpu/gles2_conform_support/egl/display.cc1
6 files changed, 35 insertions, 28 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 955ae6e..baa1102 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -471,6 +471,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
// Overridden from GLES2Decoder.
virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context,
+ bool offscreen,
const gfx::Size& size,
const DisallowedFeatures& disallowed_features,
const char* allowed_extensions,
@@ -1913,6 +1914,7 @@ GLES2DecoderImpl::~GLES2DecoderImpl() {
bool GLES2DecoderImpl::Initialize(
const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context,
+ bool offscreen,
const gfx::Size& size,
const DisallowedFeatures& disallowed_features,
const char* allowed_extensions,
@@ -2031,7 +2033,7 @@ bool GLES2DecoderImpl::Initialize(
glGetIntegerv(GL_STENCIL_BITS, &v);
back_buffer_has_stencil_ = attrib_parser.stencil_size_ != 0 && v > 0;
- if (surface_->IsOffscreen()) {
+ if (offscreen) {
if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 &&
(context_->HasExtension("GL_EXT_framebuffer_multisample") ||
context_->HasExtension("GL_ANGLE_framebuffer_multisample"))) {
@@ -7601,32 +7603,30 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers(
ScopedResolvedFrameBufferBinder binder(this, true, false);
return error::kNoError;
} else {
- if (surface_->IsOffscreen()) {
- ScopedFrameBufferBinder binder(this,
- offscreen_target_frame_buffer_->id());
-
- if (offscreen_target_buffer_preserved_) {
- // Copy the target frame buffer to the saved offscreen texture.
- offscreen_saved_color_texture_->Copy(
- offscreen_saved_color_texture_->size(),
- offscreen_saved_color_format_);
- } else {
- // Flip the textures in the parent context via the texture manager.
- if (!!offscreen_saved_color_texture_info_.get())
- offscreen_saved_color_texture_info_->
- SetServiceId(offscreen_target_color_texture_->id());
-
- offscreen_saved_color_texture_.swap(offscreen_target_color_texture_);
- offscreen_target_frame_buffer_->AttachRenderTexture(
- offscreen_target_color_texture_.get());
- }
-
- // Ensure the side effects of the copy are visible to the parent
- // context. There is no need to do this for ANGLE because it uses a
- // single D3D device for all contexts.
- if (!IsAngle())
- glFlush();
+ ScopedFrameBufferBinder binder(this,
+ offscreen_target_frame_buffer_->id());
+
+ if (offscreen_target_buffer_preserved_) {
+ // Copy the target frame buffer to the saved offscreen texture.
+ offscreen_saved_color_texture_->Copy(
+ offscreen_saved_color_texture_->size(),
+ offscreen_saved_color_format_);
+ } else {
+ // Flip the textures in the parent context via the texture manager.
+ if (!!offscreen_saved_color_texture_info_.get())
+ offscreen_saved_color_texture_info_->
+ SetServiceId(offscreen_target_color_texture_->id());
+
+ offscreen_saved_color_texture_.swap(offscreen_target_color_texture_);
+ offscreen_target_frame_buffer_->AttachRenderTexture(
+ offscreen_target_color_texture_.get());
}
+
+ // Ensure the side effects of the copy are visible to the parent
+ // context. There is no need to do this for ANGLE because it uses a
+ // single D3D device for all contexts.
+ if (!IsAngle())
+ glFlush();
return error::kNoError;
}
} else {
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h
index 1d1277b..69be3ed 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.h
@@ -87,6 +87,9 @@ class GPU_EXPORT GLES2Decoder : public CommonDecoder {
// Parameters:
// surface: the GL surface to render to.
// context: the GL context to render to.
+ // offscreen: whether to make the context offscreen or not. When FBO 0 is
+ // bound, offscreen contexts render to an internal buffer, onscreen ones
+ // to the surface.
// size: the size if the GL context is offscreen.
// allowed_extensions: A string in the same format as
// glGetString(GL_EXTENSIONS) that lists the extensions this context
@@ -95,6 +98,7 @@ class GPU_EXPORT GLES2Decoder : public CommonDecoder {
// true if successful.
virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context,
+ bool offscreen,
const gfx::Size& size,
const DisallowedFeatures& disallowed_features,
const char* allowed_extensions,
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
index 4b2d13d..649cb46 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h
@@ -32,9 +32,10 @@ class MockGLES2Decoder : public GLES2Decoder {
MockGLES2Decoder();
virtual ~MockGLES2Decoder();
- MOCK_METHOD6(Initialize,
+ MOCK_METHOD7(Initialize,
bool(const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context,
+ bool offscreen,
const gfx::Size& size,
const DisallowedFeatures& disallowed_features,
const char* allowed_extensions,
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index 5754406..3fb44a3 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -199,7 +199,7 @@ void GLES2DecoderTestBase::InitDecoder(
decoder_.reset(GLES2Decoder::Create(group_.get()));
decoder_->set_log_synthesized_gl_errors(false);
decoder_->Initialize(
- surface_, context_, surface_->GetSize(), DisallowedFeatures(),
+ surface_, context_, false, surface_->GetSize(), DisallowedFeatures(),
NULL, attribs);
decoder_->set_engine(engine_.get());
diff --git a/gpu/demos/framework/window.cc b/gpu/demos/framework/window.cc
index d5cd3cf..35b6ea9 100644
--- a/gpu/demos/framework/window.cc
+++ b/gpu/demos/framework/window.cc
@@ -94,6 +94,7 @@ bool Window::CreateRenderContext(gfx::AcceleratedWidget hwnd) {
std::vector<int32> attribs;
if (!decoder_->Initialize(surface_.get(),
context_.get(),
+ surface_->IsOffscreen(),
gfx::Size(),
gpu::gles2::DisallowedFeatures(),
NULL,
diff --git a/gpu/gles2_conform_support/egl/display.cc b/gpu/gles2_conform_support/egl/display.cc
index d3dbc08..bc07fae 100644
--- a/gpu/gles2_conform_support/egl/display.cc
+++ b/gpu/gles2_conform_support/egl/display.cc
@@ -112,6 +112,7 @@ EGLSurface Display::CreateWindowSurface(EGLConfig config,
std::vector<int32> attribs;
if (!decoder_->Initialize(gl_surface_.get(),
gl_context_.get(),
+ gl_surface_->IsOffscreen(),
gfx::Size(),
gpu::gles2::DisallowedFeatures(),
NULL,