Skip to content

Commit

Permalink
Remove unused features for in-process GL contexts.
Browse files Browse the repository at this point in the history
These features are not used and need not be supported:
- Global share group
- Context lock

Also cleans up GLInProcessContext to not require tracking lost
context state, so that we can have users of GLES2Implementation
get lost context notifications directly, going past the
GLInProcessContext.

R=piman@chomium.org, sievers@chromium.org
BUG=584497
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel

Review URL: https://codereview.chromium.org/1864373002

Cr-Commit-Position: refs/heads/master@{#385859}
  • Loading branch information
danakj authored and Commit bot committed Apr 7, 2016
1 parent a53caae commit 0792522
Show file tree
Hide file tree
Showing 20 changed files with 109 additions and 181 deletions.
13 changes: 8 additions & 5 deletions android_webview/browser/aw_render_thread_context_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ AwRenderThreadContextProvider::AwRenderThreadContextProvider(
attributes.bind_generates_resource = false;
context_.reset(gpu::GLInProcessContext::Create(
service, surface, surface->IsOffscreen(), gfx::kNullAcceleratedWidget,
surface->GetSize(), nullptr /* share_context */,
false /* share_resources */, attributes, gfx::PreferDiscreteGpu,
gpu::GLInProcessContextSharedMemoryLimits(), nullptr, nullptr));
surface->GetSize(), nullptr /* share_context */, attributes,
gfx::PreferDiscreteGpu, gpu::GLInProcessContextSharedMemoryLimits(),
nullptr, nullptr));

context_->SetContextLostCallback(base::Bind(
&AwRenderThreadContextProvider::OnLostContext, base::Unretained(this)));
Expand Down Expand Up @@ -116,11 +116,14 @@ void AwRenderThreadContextProvider::InvalidateGrContext(uint32_t state) {
}

void AwRenderThreadContextProvider::SetupLock() {
context_->SetLock(&context_lock_);
// This context provider is not used on multiple threads.
NOTREACHED();
}

base::Lock* AwRenderThreadContextProvider::GetLock() {
return &context_lock_;
// This context provider is not used on multiple threads.
NOTREACHED();
return nullptr;
}

void AwRenderThreadContextProvider::DeleteCachedResources() {
Expand Down
3 changes: 0 additions & 3 deletions android_webview/browser/aw_render_thread_context_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <memory>

#include "base/macros.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "cc/output/context_provider.h"
#include "gpu/command_buffer/service/in_process_command_buffer.h"
Expand Down Expand Up @@ -63,8 +62,6 @@ class AwRenderThreadContextProvider : public cc::ContextProvider {

LostContextCallback lost_context_callback_;

base::Lock context_lock_;

DISALLOW_COPY_AND_ASSIGN(AwRenderThreadContextProvider);
};

Expand Down
5 changes: 2 additions & 3 deletions blimp/client/feature/compositor/blimp_context_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ BlimpContextProvider::BlimpContextProvider(

context_.reset(gpu::GLInProcessContext::Create(
nullptr /* service */, nullptr /* surface */, false /* is_offscreen */,
widget, gfx::Size(1, 1), nullptr /* share_context */,
false /* share_resources */, attribs_for_gles2, gfx::PreferDiscreteGpu,
gpu::GLInProcessContextSharedMemoryLimits(),
widget, gfx::Size(1, 1), nullptr /* share_context */, attribs_for_gles2,
gfx::PreferDiscreteGpu, gpu::GLInProcessContextSharedMemoryLimits(),
gpu_memory_buffer_manager, nullptr /* memory_limits */));
context_->SetContextLostCallback(
base::Bind(&BlimpContextProvider::OnLostContext, base::Unretained(this)));
Expand Down
7 changes: 5 additions & 2 deletions cc/test/layer_tree_pixel_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface() {
}
case PIXEL_TEST_GL: {
bool flipped_output_surface = false;
scoped_refptr<TestInProcessContextProvider> compositor(
new TestInProcessContextProvider(nullptr));
scoped_refptr<TestInProcessContextProvider> worker(
new TestInProcessContextProvider(compositor.get()));
output_surface = make_scoped_ptr(new PixelTestOutputSurface(
new TestInProcessContextProvider, new TestInProcessContextProvider,
flipped_output_surface));
std::move(compositor), std::move(worker), flipped_output_surface));
break;
}
}
Expand Down
7 changes: 5 additions & 2 deletions cc/test/pixel_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ void PixelTest::SetUpGLRenderer(bool use_skia_gpu_backend,
bool flipped_output_surface) {
enable_pixel_output_.reset(new gfx::DisableNullDrawGLBindings);

scoped_refptr<TestInProcessContextProvider> compositor(
new TestInProcessContextProvider(nullptr));
scoped_refptr<TestInProcessContextProvider> worker(
new TestInProcessContextProvider(compositor.get()));
output_surface_.reset(new PixelTestOutputSurface(
new TestInProcessContextProvider, new TestInProcessContextProvider,
flipped_output_surface));
std::move(compositor), std::move(worker), flipped_output_surface));
output_surface_->BindToClient(output_surface_client_.get());

shared_bitmap_manager_.reset(new TestSharedBitmapManager);
Expand Down
30 changes: 12 additions & 18 deletions cc/test/test_in_process_context_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace cc {
// static
scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext(
TestGpuMemoryBufferManager* gpu_memory_buffer_manager,
TestImageFactory* image_factory) {
TestImageFactory* image_factory,
gpu::GLInProcessContext* shared_context) {
const bool is_offscreen = true;
const bool share_resources = true;
gpu::gles2::ContextCreationAttribHelper attribs;
attribs.alpha_size = 8;
attribs.blue_size = 8;
Expand All @@ -44,31 +44,25 @@ scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext(

scoped_ptr<gpu::GLInProcessContext> context =
make_scoped_ptr(gpu::GLInProcessContext::Create(
NULL,
NULL,
is_offscreen,
gfx::kNullAcceleratedWidget,
gfx::Size(1, 1),
NULL,
share_resources,
attribs,
gpu_preference,
nullptr, nullptr, is_offscreen, gfx::kNullAcceleratedWidget,
gfx::Size(1, 1), shared_context, attribs, gpu_preference,
gpu::GLInProcessContextSharedMemoryLimits(),
gpu_memory_buffer_manager,
image_factory));
gpu_memory_buffer_manager, image_factory));

DCHECK(context);
return context;
}

scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() {
return CreateTestInProcessContext(nullptr, nullptr);
return CreateTestInProcessContext(nullptr, nullptr, nullptr);
}

TestInProcessContextProvider::TestInProcessContextProvider()
: context_(CreateTestInProcessContext(&gpu_memory_buffer_manager_,
&image_factory_)) {
}
TestInProcessContextProvider::TestInProcessContextProvider(
TestInProcessContextProvider* shared_context)
: context_(CreateTestInProcessContext(
&gpu_memory_buffer_manager_,
&image_factory_,
(shared_context ? shared_context->context_.get() : nullptr))) {}

TestInProcessContextProvider::~TestInProcessContextProvider() {
if (gr_context_)
Expand Down
6 changes: 4 additions & 2 deletions cc/test/test_in_process_context_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ namespace cc {
scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext();
scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext(
TestGpuMemoryBufferManager* gpu_memory_buffer_manager,
TestImageFactory* image_factory);
TestImageFactory* image_factory,
gpu::GLInProcessContext* shared_context);

class TestInProcessContextProvider : public ContextProvider {
public:
TestInProcessContextProvider();
explicit TestInProcessContextProvider(
TestInProcessContextProvider* shared_context);

bool BindToCurrentThread() override;
gpu::gles2::GLES2Interface* ContextGL() override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ ContextHolder CreateContextHolder(
bool is_offscreen = true;
scoped_ptr<gpu::GLInProcessContext> context(gpu::GLInProcessContext::Create(
service, nullptr /* surface */, is_offscreen, gfx::kNullAcceleratedWidget,
gfx::Size(1, 1), nullptr /* share_context */, false /* share_resources */,
attributes, gfx::PreferDiscreteGpu, mem_limits,
gfx::Size(1, 1), nullptr /* share_context */, attributes,
gfx::PreferDiscreteGpu, mem_limits,
BrowserGpuMemoryBufferManager::current(), nullptr));

gpu::GLInProcessContext* context_ptr = context.get();
Expand Down
1 change: 0 additions & 1 deletion content/browser/compositor/gl_helper_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class GLHelperTest : public testing::Test {
gfx::kNullAcceleratedWidget, /* window */
gfx::Size(1, 1), /* size */
nullptr, /* share_context */
true, /* use_global_share_group */
attributes, gfx::PreferDiscreteGpu,
::gpu::GLInProcessContextSharedMemoryLimits(),
nullptr, /* gpu_memory_buffer_manager */
Expand Down
1 change: 0 additions & 1 deletion content/browser/compositor/gl_helper_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class GLHelperTest : public testing::Test {
gfx::kNullAcceleratedWidget, /* window */
gfx::Size(1, 1), /* size */
nullptr, /* share_context */
true, /* use_global_share_group */
attributes, gfx::PreferDiscreteGpu,
::gpu::GLInProcessContextSharedMemoryLimits(),
nullptr, /* gpu_memory_buffer_manager */
Expand Down
1 change: 0 additions & 1 deletion content/common/gpu/client/gpu_in_process_context_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class ContextTestBase : public testing::Test {
gfx::kNullAcceleratedWidget, /* window */
gfx::Size(1, 1), /* size */
nullptr, /* share_context */
true, /* use_global_share_group */
attributes, gfx::PreferDiscreteGpu,
::gpu::GLInProcessContextSharedMemoryLimits(),
nullptr, /* gpu_memory_buffer_manager */
Expand Down
27 changes: 6 additions & 21 deletions gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,30 @@ namespace gpu_blink {
// static
scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
const gpu::gles2::ContextCreationAttribHelper& attributes,
bool share_resources) {
const gpu::gles2::ContextCreationAttribHelper& attributes) {
bool is_offscreen = true;
return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
scoped_ptr<::gpu::GLInProcessContext>(), attributes, share_resources,
is_offscreen, gfx::kNullAcceleratedWidget));
scoped_ptr<::gpu::GLInProcessContext>(), attributes, is_offscreen,
gfx::kNullAcceleratedWidget));
}

scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
WebGraphicsContext3DInProcessCommandBufferImpl::WrapContext(
scoped_ptr<::gpu::GLInProcessContext> context,
const gpu::gles2::ContextCreationAttribHelper& attributes) {
bool is_offscreen = true; // Not used.
bool share_resources = false; // Not used.
gfx::AcceleratedWidget window = gfx::kNullAcceleratedWidget; // Not used.
return make_scoped_ptr(new WebGraphicsContext3DInProcessCommandBufferImpl(
std::move(context), attributes, share_resources, is_offscreen, window));
std::move(context), attributes, is_offscreen, window));
}

WebGraphicsContext3DInProcessCommandBufferImpl::
WebGraphicsContext3DInProcessCommandBufferImpl(
scoped_ptr<::gpu::GLInProcessContext> context,
const gpu::gles2::ContextCreationAttribHelper& attributes,
bool share_resources,
bool is_offscreen,
gfx::AcceleratedWidget window)
: attributes_(attributes),
share_resources_(share_resources),
is_offscreen_(is_offscreen),
window_(window),
context_(std::move(context)) {}
Expand Down Expand Up @@ -92,16 +88,11 @@ bool WebGraphicsContext3DInProcessCommandBufferImpl::MaybeInitializeGL() {
NULL, /* service */
NULL, /* surface */
is_offscreen_, window_, gfx::Size(1, 1), NULL, /* share_context */
share_resources_, attributes_, gpu_preference,
attributes_, gpu_preference,
::gpu::GLInProcessContextSharedMemoryLimits(), nullptr, nullptr));
}

if (context_) {
base::Closure context_lost_callback = base::Bind(
&WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost,
base::Unretained(this));
context_->SetContextLostCallback(context_lost_callback);
} else {
if (!context_) {
initialize_failed_ = true;
return false;
}
Expand Down Expand Up @@ -134,10 +125,4 @@ WebGraphicsContext3DInProcessCommandBufferImpl::GetContextSupport() {
return real_gl_;
}

void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() {
if (context_lost_callback_) {
context_lost_callback_->onContextLost();
}
}

} // namespace gpu_blink
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl

static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>
CreateOffscreenContext(
const gpu::gles2::ContextCreationAttribHelper& attributes,
bool share_resources);
const gpu::gles2::ContextCreationAttribHelper& attributes);

static scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> WrapContext(
scoped_ptr<::gpu::GLInProcessContext> context,
Expand All @@ -64,7 +63,6 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
WebGraphicsContext3DInProcessCommandBufferImpl(
scoped_ptr<::gpu::GLInProcessContext> context,
const gpu::gles2::ContextCreationAttribHelper& attributes,
bool share_resources,
bool is_offscreen,
gfx::AcceleratedWidget window);

Expand All @@ -77,7 +75,6 @@ class GPU_BLINK_EXPORT WebGraphicsContext3DInProcessCommandBufferImpl
void ClearContext();

::gpu::gles2::ContextCreationAttribHelper attributes_;
bool share_resources_;

bool is_offscreen_;
// Only used when not offscreen.
Expand Down
Loading

0 comments on commit 0792522

Please sign in to comment.