Commit 06994467 authored by piman@chromium.org's avatar piman@chromium.org

aura: Change shared context to be offscreen for arm

ARM drivers don't like to have 2 EGLSurface on the same Window. So we need to
make the UI shared context offscren.
This also requires the image transport surface to be an "offscreen" GLSurface (a
pbuffer), however the GLES2Decoder needs to be "onscreen" (i.e. it calls
SwapBuffers on the surface instead managing the offscreen buffers itself).
So this decouples the 2 notions of "offscreen".

BUG=chrome-os-partner:8284
TEST=gpu_unittests. Aura chrome --ui-use-gpu-process with poster circle and webgl on tegra, lumpy, desktop GL. Desktop chrome with poster circle and webgl.


Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=131177

Review URL: http://codereview.chromium.org/10007034

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133975 0039d316-1c4b-4281-b951-d872f2087c98
parent 92e1a00d
...@@ -408,7 +408,7 @@ class GpuProcessTransportFactory : public ui::ContextFactory, ...@@ -408,7 +408,7 @@ class GpuProcessTransportFactory : public ui::ContextFactory,
WebKit::WebGraphicsContext3D::Attributes attrs; WebKit::WebGraphicsContext3D::Attributes attrs;
attrs.shareResources = true; attrs.shareResources = true;
data->shared_context.reset(new WebGraphicsContext3DCommandBufferImpl( data->shared_context.reset(new WebGraphicsContext3DCommandBufferImpl(
data->surface_id, 0,
GURL(), GURL(),
factory, factory,
data->swap_client->AsWeakPtr())); data->swap_client->AsWeakPtr()));
......
...@@ -295,6 +295,7 @@ void GpuCommandBufferStub::OnInitialize( ...@@ -295,6 +295,7 @@ void GpuCommandBufferStub::OnInitialize(
// Initialize the decoder with either the view or pbuffer GLContext. // Initialize the decoder with either the view or pbuffer GLContext.
if (!decoder_->Initialize(surface_.get(), if (!decoder_->Initialize(surface_.get(),
context_.get(), context_.get(),
!surface_id(),
initial_size_, initial_size_,
disallowed_features_, disallowed_features_,
allowed_extensions_.c_str(), allowed_extensions_.c_str(),
......
...@@ -123,7 +123,7 @@ bool TextureImageTransportSurface::Resize(const gfx::Size&) { ...@@ -123,7 +123,7 @@ bool TextureImageTransportSurface::Resize(const gfx::Size&) {
} }
bool TextureImageTransportSurface::IsOffscreen() { bool TextureImageTransportSurface::IsOffscreen() {
return false; return parent_stub_ ? parent_stub_->surface()->IsOffscreen() : true;
} }
bool TextureImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { bool TextureImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
......
...@@ -472,6 +472,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, ...@@ -472,6 +472,7 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
// Overridden from GLES2Decoder. // Overridden from GLES2Decoder.
virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context, const scoped_refptr<gfx::GLContext>& context,
bool offscreen,
const gfx::Size& size, const gfx::Size& size,
const DisallowedFeatures& disallowed_features, const DisallowedFeatures& disallowed_features,
const char* allowed_extensions, const char* allowed_extensions,
...@@ -1947,6 +1948,7 @@ GLES2DecoderImpl::~GLES2DecoderImpl() { ...@@ -1947,6 +1948,7 @@ GLES2DecoderImpl::~GLES2DecoderImpl() {
bool GLES2DecoderImpl::Initialize( bool GLES2DecoderImpl::Initialize(
const scoped_refptr<gfx::GLSurface>& surface, const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context, const scoped_refptr<gfx::GLContext>& context,
bool offscreen,
const gfx::Size& size, const gfx::Size& size,
const DisallowedFeatures& disallowed_features, const DisallowedFeatures& disallowed_features,
const char* allowed_extensions, const char* allowed_extensions,
...@@ -2069,7 +2071,7 @@ bool GLES2DecoderImpl::Initialize( ...@@ -2069,7 +2071,7 @@ bool GLES2DecoderImpl::Initialize(
glGetIntegerv(GL_STENCIL_BITS, &v); glGetIntegerv(GL_STENCIL_BITS, &v);
back_buffer_has_stencil_ = attrib_parser.stencil_size_ != 0 && v > 0; 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 && if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 &&
(context_->HasExtension("GL_EXT_framebuffer_multisample") || (context_->HasExtension("GL_EXT_framebuffer_multisample") ||
context_->HasExtension("GL_ANGLE_framebuffer_multisample"))) { context_->HasExtension("GL_ANGLE_framebuffer_multisample"))) {
...@@ -7710,32 +7712,30 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers( ...@@ -7710,32 +7712,30 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers(
ScopedResolvedFrameBufferBinder binder(this, true, false); ScopedResolvedFrameBufferBinder binder(this, true, false);
return error::kNoError; return error::kNoError;
} else { } else {
if (surface_->IsOffscreen()) { ScopedFrameBufferBinder binder(this,
ScopedFrameBufferBinder binder(this, offscreen_target_frame_buffer_->id());
offscreen_target_frame_buffer_->id());
if (offscreen_target_buffer_preserved_) {
if (offscreen_target_buffer_preserved_) { // Copy the target frame buffer to the saved offscreen texture.
// Copy the target frame buffer to the saved offscreen texture. offscreen_saved_color_texture_->Copy(
offscreen_saved_color_texture_->Copy( offscreen_saved_color_texture_->size(),
offscreen_saved_color_texture_->size(), offscreen_saved_color_format_);
offscreen_saved_color_format_); } else {
} else { // Flip the textures in the parent context via the texture manager.
// Flip the textures in the parent context via the texture manager. if (!!offscreen_saved_color_texture_info_.get())
if (!!offscreen_saved_color_texture_info_.get()) offscreen_saved_color_texture_info_->
offscreen_saved_color_texture_info_-> SetServiceId(offscreen_target_color_texture_->id());
SetServiceId(offscreen_target_color_texture_->id());
offscreen_saved_color_texture_.swap(offscreen_target_color_texture_);
offscreen_saved_color_texture_.swap(offscreen_target_color_texture_); offscreen_target_frame_buffer_->AttachRenderTexture(
offscreen_target_frame_buffer_->AttachRenderTexture( offscreen_target_color_texture_.get());
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();
} }
// 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; return error::kNoError;
} }
} else { } else {
......
...@@ -87,6 +87,9 @@ class GPU_EXPORT GLES2Decoder : public CommonDecoder { ...@@ -87,6 +87,9 @@ class GPU_EXPORT GLES2Decoder : public CommonDecoder {
// Parameters: // Parameters:
// surface: the GL surface to render to. // surface: the GL surface to render to.
// context: the GL context 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. // size: the size if the GL context is offscreen.
// allowed_extensions: A string in the same format as // allowed_extensions: A string in the same format as
// glGetString(GL_EXTENSIONS) that lists the extensions this context // glGetString(GL_EXTENSIONS) that lists the extensions this context
...@@ -95,6 +98,7 @@ class GPU_EXPORT GLES2Decoder : public CommonDecoder { ...@@ -95,6 +98,7 @@ class GPU_EXPORT GLES2Decoder : public CommonDecoder {
// true if successful. // true if successful.
virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface, virtual bool Initialize(const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context, const scoped_refptr<gfx::GLContext>& context,
bool offscreen,
const gfx::Size& size, const gfx::Size& size,
const DisallowedFeatures& disallowed_features, const DisallowedFeatures& disallowed_features,
const char* allowed_extensions, const char* allowed_extensions,
......
...@@ -32,9 +32,10 @@ class MockGLES2Decoder : public GLES2Decoder { ...@@ -32,9 +32,10 @@ class MockGLES2Decoder : public GLES2Decoder {
MockGLES2Decoder(); MockGLES2Decoder();
virtual ~MockGLES2Decoder(); virtual ~MockGLES2Decoder();
MOCK_METHOD6(Initialize, MOCK_METHOD7(Initialize,
bool(const scoped_refptr<gfx::GLSurface>& surface, bool(const scoped_refptr<gfx::GLSurface>& surface,
const scoped_refptr<gfx::GLContext>& context, const scoped_refptr<gfx::GLContext>& context,
bool offscreen,
const gfx::Size& size, const gfx::Size& size,
const DisallowedFeatures& disallowed_features, const DisallowedFeatures& disallowed_features,
const char* allowed_extensions, const char* allowed_extensions,
......
...@@ -341,7 +341,7 @@ void GLES2DecoderTestBase::InitDecoder( ...@@ -341,7 +341,7 @@ void GLES2DecoderTestBase::InitDecoder(
decoder_.reset(GLES2Decoder::Create(group_.get())); decoder_.reset(GLES2Decoder::Create(group_.get()));
decoder_->set_log_synthesized_gl_errors(false); decoder_->set_log_synthesized_gl_errors(false);
decoder_->Initialize( decoder_->Initialize(
surface_, context_, surface_->GetSize(), DisallowedFeatures(), surface_, context_, false, surface_->GetSize(), DisallowedFeatures(),
NULL, attribs); NULL, attribs);
decoder_->set_engine(engine_.get()); decoder_->set_engine(engine_.get());
......
...@@ -79,6 +79,7 @@ void GLManager::Initialize(const gfx::Size& size) { ...@@ -79,6 +79,7 @@ void GLManager::Initialize(const gfx::Size& size) {
ASSERT_TRUE(decoder_->Initialize( ASSERT_TRUE(decoder_->Initialize(
surface_.get(), surface_.get(),
context_.get(), context_.get(),
true,
size, size,
::gpu::gles2::DisallowedFeatures(), ::gpu::gles2::DisallowedFeatures(),
allowed_extensions, allowed_extensions,
......
...@@ -94,6 +94,7 @@ bool Window::CreateRenderContext(gfx::AcceleratedWidget hwnd) { ...@@ -94,6 +94,7 @@ bool Window::CreateRenderContext(gfx::AcceleratedWidget hwnd) {
std::vector<int32> attribs; std::vector<int32> attribs;
if (!decoder_->Initialize(surface_.get(), if (!decoder_->Initialize(surface_.get(),
context_.get(), context_.get(),
surface_->IsOffscreen(),
gfx::Size(), gfx::Size(),
gpu::gles2::DisallowedFeatures(), gpu::gles2::DisallowedFeatures(),
NULL, NULL,
......
...@@ -112,6 +112,7 @@ EGLSurface Display::CreateWindowSurface(EGLConfig config, ...@@ -112,6 +112,7 @@ EGLSurface Display::CreateWindowSurface(EGLConfig config,
std::vector<int32> attribs; std::vector<int32> attribs;
if (!decoder_->Initialize(gl_surface_.get(), if (!decoder_->Initialize(gl_surface_.get(),
gl_context_.get(), gl_context_.get(),
gl_surface_->IsOffscreen(),
gfx::Size(), gfx::Size(),
gpu::gles2::DisallowedFeatures(), gpu::gles2::DisallowedFeatures(),
NULL, NULL,
......
...@@ -426,6 +426,7 @@ bool GLInProcessContext::Initialize(const gfx::Size& size, ...@@ -426,6 +426,7 @@ bool GLInProcessContext::Initialize(const gfx::Size& size,
if (!decoder_->Initialize(surface_.get(), if (!decoder_->Initialize(surface_.get(),
context_.get(), context_.get(),
true,
size, size,
::gpu::gles2::DisallowedFeatures(), ::gpu::gles2::DisallowedFeatures(),
allowed_extensions, allowed_extensions,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment