Skip to content

Commit

Permalink
Use the GL in process bindings directly in cc_unittests
Browse files Browse the repository at this point in the history
This binds cc_unittests to the GL in process command buffer bindings directly
instead of relying on the setup in webkit/common/gpu.

BUG=181120

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242005 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
jamesr@chromium.org committed Dec 20, 2013
1 parent 108949c commit 3831ae4
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 141 deletions.
6 changes: 5 additions & 1 deletion cc/cc_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@
'test/fake_web_graphics_context_3d.h',
'test/geometry_test_utils.cc',
'test/geometry_test_utils.h',
'test/test_in_process_context_provider.cc',
'test/test_in_process_context_provider.h',
'test/impl_side_painting_settings.h',
'test/layer_test_common.cc',
'test/layer_test_common.h',
Expand Down Expand Up @@ -225,7 +227,6 @@
'../ui/events/events.gyp:events_base',
'../ui/gfx/gfx.gyp:gfx',
'../ui/gfx/gfx.gyp:gfx_geometry',
'../webkit/common/gpu/webkit_gpu.gyp:webkit_gpu',
'cc.gyp:cc',
'cc_test_support',
],
Expand Down Expand Up @@ -327,7 +328,10 @@
'dependencies': [
'../base/base.gyp:base',
'../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
'../gpu/gpu.gyp:gles2_c_lib',
'../gpu/gpu.gyp:gles2_implementation',
'../gpu/gpu.gyp:gpu_unittest_utils',
'../gpu/skia_bindings/skia_bindings.gyp:gpu_skia_bindings',
'../skia/skia.gyp:skia',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
Expand Down
6 changes: 3 additions & 3 deletions cc/output/gl_renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ GLRenderer::GLRenderer(RendererClient* client,
highp_threshold_min_(highp_threshold_min),
highp_threshold_cache_(0),
on_demand_tile_raster_resource_id_(0) {
DCHECK(context_);
DCHECK(gl_);
DCHECK(context_support_);

ContextProvider::Capabilities context_caps =
Expand Down Expand Up @@ -525,7 +525,7 @@ static SkBitmap ApplyImageFilter(GLRenderer* renderer,

// Flush the GL context so rendering results from this context are
// visible in the compositor's context.
offscreen_contexts->Context3d()->flush();
offscreen_contexts->ContextGL()->Flush();

return device.accessBitmap(false);
}
Expand Down Expand Up @@ -650,7 +650,7 @@ static SkBitmap ApplyBlendModeWithBackdrop(

// Flush the GL context so rendering results from this context are
// visible in the compositor's context.
offscreen_contexts->Context3d()->flush();
offscreen_contexts->ContextGL()->Flush();

return device.accessBitmap(false);
}
Expand Down
20 changes: 10 additions & 10 deletions cc/output/gl_renderer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1842,23 +1842,23 @@ class GLRendererTestSyncPoint : public GLRendererPixelTest {
TEST_F(GLRendererTestSyncPoint, SignalSyncPointOnLostContext) {
int sync_point_callback_count = 0;
int other_callback_count = 0;
blink::WebGraphicsContext3D* context3d =
output_surface_->context_provider()->Context3d();
gpu::gles2::GLES2Interface* gl =
output_surface_->context_provider()->ContextGL();
gpu::ContextSupport* context_support =
output_surface_->context_provider()->ContextSupport();

uint32 sync_point = context3d->insertSyncPoint();
uint32 sync_point = gl->InsertSyncPointCHROMIUM();

context3d->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
GL_INNOCENT_CONTEXT_RESET_ARB);
gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
GL_INNOCENT_CONTEXT_RESET_ARB);

context_support->SignalSyncPoint(
sync_point, base::Bind(&SyncPointCallback, &sync_point_callback_count));
EXPECT_EQ(0, sync_point_callback_count);
EXPECT_EQ(0, other_callback_count);

// Make the sync point happen.
context3d->finish();
gl->Finish();
// Post a task after the sync point.
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&OtherCallback, &other_callback_count));
Expand All @@ -1874,20 +1874,20 @@ TEST_F(GLRendererTestSyncPoint, SignalSyncPoint) {
int sync_point_callback_count = 0;
int other_callback_count = 0;

blink::WebGraphicsContext3D* context3d =
output_surface_->context_provider()->Context3d();
gpu::gles2::GLES2Interface* gl =
output_surface_->context_provider()->ContextGL();
gpu::ContextSupport* context_support =
output_surface_->context_provider()->ContextSupport();

uint32 sync_point = context3d->insertSyncPoint();
uint32 sync_point = gl->InsertSyncPointCHROMIUM();

context_support->SignalSyncPoint(
sync_point, base::Bind(&SyncPointCallback, &sync_point_callback_count));
EXPECT_EQ(0, sync_point_callback_count);
EXPECT_EQ(0, other_callback_count);

// Make the sync point happen.
context3d->finish();
gl->Finish();
// Post a task after the sync point.
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&OtherCallback, &other_callback_count));
Expand Down
19 changes: 9 additions & 10 deletions cc/output/output_surface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/context_support.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
#include "ui/gfx/frame_time.h"
Expand Down Expand Up @@ -327,12 +326,12 @@ void OutputSurface::ResetContext3d() {
while (!pending_gpu_latency_query_ids_.empty()) {
unsigned query_id = pending_gpu_latency_query_ids_.front();
pending_gpu_latency_query_ids_.pop_front();
context_provider_->Context3d()->deleteQueryEXT(query_id);
context_provider_->ContextGL()->DeleteQueriesEXT(1, &query_id);
}
while (!available_gpu_latency_query_ids_.empty()) {
unsigned query_id = available_gpu_latency_query_ids_.front();
available_gpu_latency_query_ids_.pop_front();
context_provider_->Context3d()->deleteQueryEXT(query_id);
context_provider_->ContextGL()->DeleteQueriesEXT(1, &query_id);
}
context_provider_->SetLostContextCallback(
ContextProvider::LostContextCallback());
Expand Down Expand Up @@ -363,7 +362,7 @@ void OutputSurface::Reshape(gfx::Size size, float scale_factor) {
surface_size_ = size;
device_scale_factor_ = scale_factor;
if (context_provider_) {
context_provider_->Context3d()->reshapeWithScaleFactor(
context_provider_->ContextGL()->ResizeCHROMIUM(
size.width(), size.height(), scale_factor);
}
if (software_device_)
Expand All @@ -376,7 +375,7 @@ gfx::Size OutputSurface::SurfaceSize() const {

void OutputSurface::BindFramebuffer() {
DCHECK(context_provider_);
context_provider_->Context3d()->bindFramebuffer(GL_FRAMEBUFFER, 0);
context_provider_->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0);
}

void OutputSurface::SwapBuffers(CompositorFrame* frame) {
Expand Down Expand Up @@ -421,13 +420,13 @@ void OutputSurface::UpdateAndMeasureGpuLatency() {
while (pending_gpu_latency_query_ids_.size()) {
unsigned query_id = pending_gpu_latency_query_ids_.front();
unsigned query_complete = 1;
context_provider_->Context3d()->getQueryObjectuivEXT(
context_provider_->ContextGL()->GetQueryObjectuivEXT(
query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &query_complete);
if (!query_complete)
break;

unsigned value = 0;
context_provider_->Context3d()->getQueryObjectuivEXT(
context_provider_->ContextGL()->GetQueryObjectuivEXT(
query_id, GL_QUERY_RESULT_EXT, &value);
pending_gpu_latency_query_ids_.pop_front();
available_gpu_latency_query_ids_.push_back(query_id);
Expand Down Expand Up @@ -464,12 +463,12 @@ void OutputSurface::UpdateAndMeasureGpuLatency() {
gpu_latency_query_id = available_gpu_latency_query_ids_.front();
available_gpu_latency_query_ids_.pop_front();
} else {
gpu_latency_query_id = context_provider_->Context3d()->createQueryEXT();
context_provider_->ContextGL()->GenQueriesEXT(1, &gpu_latency_query_id);
}

context_provider_->Context3d()->beginQueryEXT(GL_LATENCY_QUERY_CHROMIUM,
context_provider_->ContextGL()->BeginQueryEXT(GL_LATENCY_QUERY_CHROMIUM,
gpu_latency_query_id);
context_provider_->Context3d()->endQueryEXT(GL_LATENCY_QUERY_CHROMIUM);
context_provider_->ContextGL()->EndQueryEXT(GL_LATENCY_QUERY_CHROMIUM);
pending_gpu_latency_query_ids_.push_back(gpu_latency_query_id);
}

Expand Down
43 changes: 21 additions & 22 deletions cc/output/renderer_pixeltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
#include "cc/test/fake_picture_pile_impl.h"
#include "cc/test/pixel_test.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/effects/SkColorFilterImageFilter.h"
#include "third_party/skia/include/effects/SkColorMatrixFilter.h"
#include "ui/gfx/rect_conversions.h"

using gpu::gles2::GLES2Interface;

namespace cc {
namespace {

Expand Down Expand Up @@ -1277,35 +1279,32 @@ TEST_F(GLRendererPixelTestWithBackgroundFilter, InvertFilter) {
class ExternalStencilPixelTest : public GLRendererPixelTest {
protected:
void ClearBackgroundToGreen() {
blink::WebGraphicsContext3D* context3d =
output_surface_->context_provider()->Context3d();
GLES2Interface* gl = output_surface_->context_provider()->ContextGL();
output_surface_->EnsureBackbuffer();
output_surface_->Reshape(device_viewport_size_, 1);
context3d->clearColor(0.f, 1.f, 0.f, 1.f);
context3d->clear(GL_COLOR_BUFFER_BIT);
gl->ClearColor(0.f, 1.f, 0.f, 1.f);
gl->Clear(GL_COLOR_BUFFER_BIT);
}

void PopulateStencilBuffer() {
// Set two quadrants of the stencil buffer to 1.
blink::WebGraphicsContext3D* context3d =
output_surface_->context_provider()->Context3d();
ASSERT_TRUE(context3d->getContextAttributes().stencil);
GLES2Interface* gl = output_surface_->context_provider()->ContextGL();
output_surface_->EnsureBackbuffer();
output_surface_->Reshape(device_viewport_size_, 1);
context3d->clearStencil(0);
context3d->clear(GL_STENCIL_BUFFER_BIT);
context3d->enable(GL_SCISSOR_TEST);
context3d->clearStencil(1);
context3d->scissor(0,
0,
device_viewport_size_.width() / 2,
device_viewport_size_.height() / 2);
context3d->clear(GL_STENCIL_BUFFER_BIT);
context3d->scissor(device_viewport_size_.width() / 2,
device_viewport_size_.height() / 2,
device_viewport_size_.width(),
device_viewport_size_.height());
context3d->clear(GL_STENCIL_BUFFER_BIT);
gl->ClearStencil(0);
gl->Clear(GL_STENCIL_BUFFER_BIT);
gl->Enable(GL_SCISSOR_TEST);
gl->ClearStencil(1);
gl->Scissor(0,
0,
device_viewport_size_.width() / 2,
device_viewport_size_.height() / 2);
gl->Clear(GL_STENCIL_BUFFER_BIT);
gl->Scissor(device_viewport_size_.width() / 2,
device_viewport_size_.height() / 2,
device_viewport_size_.width(),
device_viewport_size_.height());
gl->Clear(GL_STENCIL_BUFFER_BIT);
}
};

Expand Down
6 changes: 4 additions & 2 deletions cc/test/DEPS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
include_rules = [
"+gpu/command_buffer/client/gl_in_process_context.h",
"+gpu/command_buffer/client/gles2_implementation.h",
"+gpu/command_buffer/client/gles2_interface_stub.h",
# TODO(jamesr): Remove once cc depends on GLES2Interface instead of WGC3D
"+webkit/common/gpu",
"+gpu/command_buffer/client/gles2_lib.h",
"+gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h",
]
Loading

0 comments on commit 3831ae4

Please sign in to comment.