summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-20 01:16:53 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-20 01:16:53 +0000
commit3831ae45b1e856e07e760e0a8630c79ef690f8c1 (patch)
tree6701b5e1f78af43872f500c967208b77258c5804
parent108949ca10059379fa04f52528ce300efe78ee20 (diff)
downloadchromium_src-3831ae45b1e856e07e760e0a8630c79ef690f8c1.zip
chromium_src-3831ae45b1e856e07e760e0a8630c79ef690f8c1.tar.gz
chromium_src-3831ae45b1e856e07e760e0a8630c79ef690f8c1.tar.bz2
Use the GL in process bindings directly in cc_unittests
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
-rw-r--r--cc/cc_tests.gyp6
-rw-r--r--cc/output/gl_renderer.cc6
-rw-r--r--cc/output/gl_renderer_unittest.cc20
-rw-r--r--cc/output/output_surface.cc19
-rw-r--r--cc/output/renderer_pixeltest.cc43
-rw-r--r--cc/test/DEPS6
-rw-r--r--cc/test/layer_tree_pixel_test.cc141
-rw-r--r--cc/test/layer_tree_pixel_test.h13
-rw-r--r--cc/test/pixel_test.cc18
-rw-r--r--cc/test/test_gles2_interface.cc6
-rw-r--r--cc/test/test_gles2_interface.h4
-rw-r--r--cc/test/test_in_process_context_provider.cc136
-rw-r--r--cc/test/test_in_process_context_provider.h52
13 files changed, 329 insertions, 141 deletions
diff --git a/cc/cc_tests.gyp b/cc/cc_tests.gyp
index eb29c67..7ac9838 100644
--- a/cc/cc_tests.gyp
+++ b/cc/cc_tests.gyp
@@ -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',
@@ -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',
],
@@ -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',
diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc
index 04db7b0..6fac3bb 100644
--- a/cc/output/gl_renderer.cc
+++ b/cc/output/gl_renderer.cc
@@ -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 =
@@ -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);
}
@@ -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);
}
diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc
index f165e15..b7f5c80 100644
--- a/cc/output/gl_renderer_unittest.cc
+++ b/cc/output/gl_renderer_unittest.cc
@@ -1842,15 +1842,15 @@ 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));
@@ -1858,7 +1858,7 @@ TEST_F(GLRendererTestSyncPoint, SignalSyncPointOnLostContext) {
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));
@@ -1874,12 +1874,12 @@ 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));
@@ -1887,7 +1887,7 @@ TEST_F(GLRendererTestSyncPoint, SignalSyncPoint) {
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));
diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc
index 5bad7ec..349cb34 100644
--- a/cc/output/output_surface.cc
+++ b/cc/output/output_surface.cc
@@ -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"
@@ -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());
@@ -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_)
@@ -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) {
@@ -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);
@@ -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);
}
diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc
index 24c6126..8ab93aa 100644
--- a/cc/output/renderer_pixeltest.cc
+++ b/cc/output/renderer_pixeltest.cc
@@ -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 {
@@ -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);
}
};
diff --git a/cc/test/DEPS b/cc/test/DEPS
index 8f04cc2..611de1b 100644
--- a/cc/test/DEPS
+++ b/cc/test/DEPS
@@ -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",
]
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc
index e41a038..d0635a7 100644
--- a/cc/test/layer_tree_pixel_test.cc
+++ b/cc/test/layer_tree_pixel_test.cc
@@ -17,10 +17,13 @@
#include "cc/test/pixel_test_output_surface.h"
#include "cc/test/pixel_test_software_output_device.h"
#include "cc/test/pixel_test_utils.h"
+#include "cc/test/test_in_process_context_provider.h"
#include "cc/trees/layer_tree_impl.h"
+#include "gpu/command_buffer/client/gl_in_process_context.h"
+#include "gpu/command_buffer/client/gles2_implementation.h"
#include "ui/gl/gl_implementation.h"
-#include "webkit/common/gpu/context_provider_in_process.h"
-#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
+
+using gpu::gles2::GLES2Interface;
namespace cc {
@@ -54,9 +57,8 @@ scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface(
case GL_WITH_BITMAP: {
CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL));
- using webkit::gpu::ContextProviderInProcess;
- output_surface = make_scoped_ptr(new PixelTestOutputSurface(
- ContextProviderInProcess::CreateOffscreen()));
+ output_surface = make_scoped_ptr(
+ new PixelTestOutputSurface(new TestInProcessContextProvider));
break;
}
}
@@ -66,10 +68,7 @@ scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface(
}
scoped_refptr<ContextProvider> LayerTreePixelTest::OffscreenContextProvider() {
- scoped_refptr<webkit::gpu::ContextProviderInProcess> provider =
- webkit::gpu::ContextProviderInProcess::CreateOffscreen();
- CHECK(provider.get());
- return provider;
+ return scoped_refptr<ContextProvider>(new TestInProcessContextProvider);
}
void LayerTreePixelTest::CommitCompleteOnThread(LayerTreeHostImpl* impl) {
@@ -234,49 +233,41 @@ scoped_ptr<SkBitmap> LayerTreePixelTest::CopyTextureMailboxToBitmap(
if (!texture_mailbox.IsTexture())
return scoped_ptr<SkBitmap>();
- using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
- scoped_ptr<blink::WebGraphicsContext3D> context3d(
- WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
- blink::WebGraphicsContext3D::Attributes()));
-
- EXPECT_TRUE(context3d->makeContextCurrent());
+ scoped_ptr<gpu::GLInProcessContext> context = CreateTestInProcessContext();
+ GLES2Interface* gl = context->GetImplementation();
if (texture_mailbox.sync_point())
- context3d->waitSyncPoint(texture_mailbox.sync_point());
-
- unsigned texture_id = context3d->createTexture();
- context3d->bindTexture(GL_TEXTURE_2D, texture_id);
- context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- context3d->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- context3d->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- context3d->consumeTextureCHROMIUM(texture_mailbox.target(),
- texture_mailbox.data());
- context3d->bindTexture(GL_TEXTURE_2D, 0);
-
- unsigned fbo = context3d->createFramebuffer();
- context3d->bindFramebuffer(GL_FRAMEBUFFER, fbo);
- context3d->framebufferTexture2D(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- texture_id,
- 0);
+ gl->WaitSyncPointCHROMIUM(texture_mailbox.sync_point());
+
+ GLuint texture_id = 0;
+ gl->GenTextures(1, &texture_id);
+ gl->BindTexture(GL_TEXTURE_2D, texture_id);
+ gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ gl->ConsumeTextureCHROMIUM(texture_mailbox.target(), texture_mailbox.data());
+ gl->BindTexture(GL_TEXTURE_2D, 0);
+
+ GLuint fbo = 0;
+ gl->GenFramebuffers(1, &fbo);
+ gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
+ gl->FramebufferTexture2D(
+ GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0);
EXPECT_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE),
- context3d->checkFramebufferStatus(GL_FRAMEBUFFER));
+ gl->CheckFramebufferStatus(GL_FRAMEBUFFER));
scoped_ptr<uint8[]> pixels(new uint8[size.GetArea() * 4]);
- context3d->readPixels(0,
- 0,
- size.width(),
- size.height(),
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- pixels.get());
+ gl->ReadPixels(0,
+ 0,
+ size.width(),
+ size.height(),
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ pixels.get());
- context3d->deleteFramebuffer(fbo);
- context3d->deleteTexture(texture_id);
+ gl->DeleteFramebuffers(1, &fbo);
+ gl->DeleteTextures(1, &texture_id);
scoped_ptr<SkBitmap> bitmap(new SkBitmap);
bitmap->setConfig(SkBitmap::kARGB_8888_Config,
@@ -305,13 +296,14 @@ scoped_ptr<SkBitmap> LayerTreePixelTest::CopyTextureMailboxToBitmap(
}
void LayerTreePixelTest::ReleaseTextureMailbox(
- scoped_ptr<blink::WebGraphicsContext3D> context3d,
+ scoped_ptr<gpu::GLInProcessContext> context,
uint32 texture,
uint32 sync_point,
bool lost_resource) {
+ GLES2Interface* gl = context->GetImplementation();
if (sync_point)
- context3d->waitSyncPoint(sync_point);
- context3d->deleteTexture(texture);
+ gl->WaitSyncPointCHROMIUM(sync_point);
+ gl->DeleteTextures(1, &texture);
pending_texture_mailbox_callbacks_--;
TryEndTest();
}
@@ -325,21 +317,16 @@ void LayerTreePixelTest::CopyBitmapToTextureMailboxAsTexture(
CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL));
- using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
- scoped_ptr<blink::WebGraphicsContext3D> context3d(
- WebGraphicsContext3DInProcessCommandBufferImpl::CreateOffscreenContext(
- blink::WebGraphicsContext3D::Attributes()));
-
- EXPECT_TRUE(context3d->makeContextCurrent());
+ scoped_ptr<gpu::GLInProcessContext> context = CreateTestInProcessContext();
+ GLES2Interface* gl = context->GetImplementation();
- unsigned texture_id = context3d->createTexture();
- context3d->bindTexture(GL_TEXTURE_2D, texture_id);
- context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- context3d->texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- context3d->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- context3d->texParameteri(
- GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ GLuint texture_id = 0;
+ gl->GenTextures(1, &texture_id);
+ gl->BindTexture(GL_TEXTURE_2D, texture_id);
+ gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
DCHECK_EQ(SkBitmap::kARGB_8888_Config, bitmap.getConfig());
@@ -364,28 +351,28 @@ void LayerTreePixelTest::CopyBitmapToTextureMailboxAsTexture(
}
}
- context3d->texImage2D(GL_TEXTURE_2D,
- 0,
- GL_RGBA,
- bitmap.width(),
- bitmap.height(),
- 0,
- GL_RGBA,
- GL_UNSIGNED_BYTE,
- gl_pixels.get());
+ gl->TexImage2D(GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ bitmap.width(),
+ bitmap.height(),
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ gl_pixels.get());
}
gpu::Mailbox mailbox;
- context3d->genMailboxCHROMIUM(mailbox.name);
- context3d->produceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
- context3d->bindTexture(GL_TEXTURE_2D, 0);
- uint32 sync_point = context3d->insertSyncPoint();
+ gl->GenMailboxCHROMIUM(mailbox.name);
+ gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
+ gl->BindTexture(GL_TEXTURE_2D, 0);
+ uint32 sync_point = gl->InsertSyncPointCHROMIUM();
*texture_mailbox = TextureMailbox(mailbox, sync_point);
*release_callback = SingleReleaseCallback::Create(
base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox,
base::Unretained(this),
- base::Passed(&context3d),
+ base::Passed(&context),
texture_id));
}
diff --git a/cc/test/layer_tree_pixel_test.h b/cc/test/layer_tree_pixel_test.h
index 92d955f..d905d53 100644
--- a/cc/test/layer_tree_pixel_test.h
+++ b/cc/test/layer_tree_pixel_test.h
@@ -15,6 +15,10 @@
class SkBitmap;
+namespace gpu {
+class GLInProcessContext;
+}
+
namespace cc {
class CopyOutputRequest;
class CopyOutputResult;
@@ -79,11 +83,10 @@ class LayerTreePixelTest : public LayerTreeTest {
TextureMailbox* texture_mailbox,
scoped_ptr<SingleReleaseCallback>* release_callback);
- void ReleaseTextureMailbox(
- scoped_ptr<blink::WebGraphicsContext3D> context3d,
- uint32 texture,
- uint32 sync_point,
- bool lost_resource);
+ void ReleaseTextureMailbox(scoped_ptr<gpu::GLInProcessContext> context,
+ uint32 texture,
+ uint32 sync_point,
+ bool lost_resource);
// Common CSS colors defined for tests to use.
enum Colors {
diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc
index 78cdd69..713f09e 100644
--- a/cc/test/pixel_test.cc
+++ b/cc/test/pixel_test.cc
@@ -21,10 +21,9 @@
#include "cc/test/pixel_test_output_surface.h"
#include "cc/test/pixel_test_software_output_device.h"
#include "cc/test/pixel_test_utils.h"
+#include "cc/test/test_in_process_context_provider.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_implementation.h"
-#include "webkit/common/gpu/context_provider_in_process.h"
-#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
namespace cc {
@@ -59,13 +58,12 @@ bool PixelTest::RunPixelTestWithReadbackTarget(
base::Unretained(this),
run_loop.QuitClosure())));
- scoped_refptr<webkit::gpu::ContextProviderInProcess> offscreen_contexts;
+ scoped_refptr<ContextProvider> offscreen_contexts;
switch (provide_offscreen_context) {
case NoOffscreenContext:
break;
case WithOffscreenContext:
- offscreen_contexts =
- webkit::gpu::ContextProviderInProcess::CreateOffscreen();
+ offscreen_contexts = new TestInProcessContextProvider;
CHECK(offscreen_contexts->BindToCurrentThread());
break;
}
@@ -115,17 +113,15 @@ bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file,
if (cmd->HasSwitch(switches::kCCRebaselinePixeltests))
return WritePNGFile(*result_bitmap_, test_data_dir.Append(ref_file), true);
- return MatchesPNGFile(*result_bitmap_,
- test_data_dir.Append(ref_file),
- comparator);
+ return MatchesPNGFile(
+ *result_bitmap_, test_data_dir.Append(ref_file), comparator);
}
void PixelTest::SetUpGLRenderer(bool use_skia_gpu_backend) {
CHECK(gfx::InitializeGLBindings(gfx::kGLImplementationOSMesaGL));
- using webkit::gpu::ContextProviderInProcess;
- output_surface_.reset(new PixelTestOutputSurface(
- ContextProviderInProcess::CreateOffscreen()));
+ output_surface_.reset(
+ new PixelTestOutputSurface(new TestInProcessContextProvider));
output_surface_->BindToClient(output_surface_client_.get());
resource_provider_ =
diff --git a/cc/test/test_gles2_interface.cc b/cc/test/test_gles2_interface.cc
index ad75280..b2bf39a 100644
--- a/cc/test/test_gles2_interface.cc
+++ b/cc/test/test_gles2_interface.cc
@@ -363,4 +363,10 @@ void TestGLES2Interface::ConsumeTextureCHROMIUM(GLenum target,
test_context_->consumeTextureCHROMIUM(target, mailbox);
}
+void TestGLES2Interface::ResizeCHROMIUM(GLuint width,
+ GLuint height,
+ float device_scale) {
+ test_context_->reshapeWithScaleFactor(width, height, device_scale);
+}
+
} // namespace cc
diff --git a/cc/test/test_gles2_interface.h b/cc/test/test_gles2_interface.h
index 1d3ecce..40130c2 100644
--- a/cc/test/test_gles2_interface.h
+++ b/cc/test/test_gles2_interface.h
@@ -162,6 +162,10 @@ class TestGLES2Interface : public gpu::gles2::GLES2InterfaceStub {
virtual void ConsumeTextureCHROMIUM(GLenum target,
const GLbyte* mailbox) OVERRIDE;
+ virtual void ResizeCHROMIUM(GLuint width,
+ GLuint height,
+ float device_scale) OVERRIDE;
+
private:
TestWebGraphicsContext3D* test_context_;
};
diff --git a/cc/test/test_in_process_context_provider.cc b/cc/test/test_in_process_context_provider.cc
new file mode 100644
index 0000000..14c65d1
--- /dev/null
+++ b/cc/test/test_in_process_context_provider.cc
@@ -0,0 +1,136 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/test/test_in_process_context_provider.h"
+
+#include "base/lazy_instance.h"
+#include "gpu/GLES2/gl2extchromium.h"
+#include "gpu/command_buffer/client/gl_in_process_context.h"
+#include "gpu/command_buffer/client/gles2_implementation.h"
+#include "gpu/command_buffer/client/gles2_lib.h"
+#include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
+#include "third_party/khronos/GLES2/gl2.h"
+#include "third_party/khronos/GLES2/gl2ext.h"
+#include "third_party/skia/include/gpu/GrContext.h"
+#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace cc {
+
+// static
+scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() {
+ const bool is_offscreen = true;
+ const bool share_resources = true;
+ gpu::GLInProcessContextAttribs attribs;
+ attribs.alpha_size = 8;
+ attribs.blue_size = 8;
+ attribs.green_size = 8;
+ attribs.red_size = 8;
+ attribs.depth_size = 24;
+ attribs.stencil_size = 8;
+ attribs.samples = 0;
+ attribs.sample_buffers = 0;
+ attribs.fail_if_major_perf_caveat = false;
+ gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
+
+ scoped_ptr<gpu::GLInProcessContext> context = make_scoped_ptr(
+ gpu::GLInProcessContext::CreateContext(is_offscreen,
+ gfx::AcceleratedWidget(),
+ gfx::Size(1, 1),
+ share_resources,
+ attribs,
+ gpu_preference));
+ DCHECK(context);
+ return context.Pass();
+}
+
+TestInProcessContextProvider::TestInProcessContextProvider()
+ : context_(CreateTestInProcessContext()) {}
+
+TestInProcessContextProvider::~TestInProcessContextProvider() {
+ if (gr_context_)
+ gr_context_->contextDestroyed();
+}
+
+bool TestInProcessContextProvider::BindToCurrentThread() { return true; }
+
+blink::WebGraphicsContext3D* TestInProcessContextProvider::Context3d() {
+ return NULL;
+}
+
+gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() {
+ return context_->GetImplementation();
+}
+
+gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() {
+ return context_->GetImplementation();
+}
+
+static void BindGrContextCallback(const GrGLInterface* interface) {
+#if GR_GL_PER_GL_FUNC_CALLBACK
+ reinterpret_cast<TestInProcessContextProvider*>(interface->fCallbackData)
+ ->MakeGrContextCurrent();
+#endif // GR_GL_PER_GL_FUNC_CALLBACK
+}
+
+class GrContext* TestInProcessContextProvider::GrContext() {
+ if (gr_context_)
+ return gr_context_.get();
+
+ skia::RefPtr<GrGLInterface> interface =
+ skia::AdoptRef(skia_bindings::CreateCommandBufferSkiaGLBinding());
+#if GR_GL_PER_GL_FUNC_CALLBACK
+ interface->fCallback = BindGrContextCallback;
+ interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(this);
+#endif // GR_GL_PER_GL_FUNC_CALLBACK
+
+ gr_context_ = skia::AdoptRef(GrContext::Create(
+ kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get())));
+
+ return gr_context_.get();
+}
+
+namespace {
+
+// Singleton used to initialize and terminate the gles2 library.
+class GLES2Initializer {
+ public:
+ GLES2Initializer() { ::gles2::Initialize(); }
+
+ ~GLES2Initializer() { ::gles2::Terminate(); }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
+};
+
+static base::LazyInstance<GLES2Initializer> g_gles2_initializer =
+ LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+void TestInProcessContextProvider::MakeGrContextCurrent() {
+ // Make sure the gles2 library is initialized first on exactly one thread.
+ g_gles2_initializer.Get();
+
+ gles2::SetGLContext(context_->GetImplementation());
+}
+
+ContextProvider::Capabilities
+TestInProcessContextProvider::ContextCapabilities() {
+ return ContextProvider::Capabilities();
+}
+
+bool TestInProcessContextProvider::IsContextLost() { return false; }
+
+void TestInProcessContextProvider::VerifyContexts() {}
+
+bool TestInProcessContextProvider::DestroyedOnMainThread() { return false; }
+
+void TestInProcessContextProvider::SetLostContextCallback(
+ const LostContextCallback& lost_context_callback) {}
+
+void TestInProcessContextProvider::SetMemoryPolicyChangedCallback(
+ const MemoryPolicyChangedCallback& memory_policy_changed_callback) {}
+
+} // namespace cc
diff --git a/cc/test/test_in_process_context_provider.h b/cc/test/test_in_process_context_provider.h
new file mode 100644
index 0000000..f0d78fb4
--- /dev/null
+++ b/cc/test/test_in_process_context_provider.h
@@ -0,0 +1,52 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_
+#define CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_
+
+#include "cc/output/context_provider.h"
+#include "skia/ext/refptr.h"
+
+class GrContext;
+
+namespace gpu {
+class GLInProcessContext;
+}
+
+namespace cc {
+
+scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext();
+
+class TestInProcessContextProvider : public ContextProvider {
+ public:
+ TestInProcessContextProvider();
+
+ virtual bool BindToCurrentThread() OVERRIDE;
+ virtual blink::WebGraphicsContext3D* Context3d() OVERRIDE;
+ virtual gpu::gles2::GLES2Interface* ContextGL() OVERRIDE;
+ virtual gpu::ContextSupport* ContextSupport() OVERRIDE;
+ virtual class GrContext* GrContext() OVERRIDE;
+ virtual void MakeGrContextCurrent() OVERRIDE;
+ virtual Capabilities ContextCapabilities() OVERRIDE;
+ virtual bool IsContextLost() OVERRIDE;
+ virtual void VerifyContexts() OVERRIDE;
+ virtual bool DestroyedOnMainThread() OVERRIDE;
+ virtual void SetLostContextCallback(
+ const LostContextCallback& lost_context_callback) OVERRIDE;
+ virtual void SetMemoryPolicyChangedCallback(
+ const MemoryPolicyChangedCallback& memory_policy_changed_callback)
+ OVERRIDE;
+
+ protected:
+ friend class base::RefCountedThreadSafe<TestInProcessContextProvider>;
+ virtual ~TestInProcessContextProvider();
+
+ private:
+ skia::RefPtr<class GrContext> gr_context_;
+ scoped_ptr<gpu::GLInProcessContext> context_;
+};
+
+} // namespace cc
+
+#endif // CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_