[go: nahoru, domu]

oop: Create a RasterInterface, and use it for Compositor Worker contexts.

This CL enables RasterInterface for Compositor Worker contexts in
content/renderer and content/browser.

RasterInterface provides a subset of GLES2Interface APIs required for
OOP Rasterization.  This will gradually diverge away from GLES2.

The initial change adds a client-side implementation of
RasterInterface on top of GLES2Interface.

Design Doc: https://goo.gl/Q6E1ZC
BUG=757607

Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: Iaefd861f0c51b9995ad27eb94de2068d0f9dab22
Reviewed-on: https://chromium-review.googlesource.com/778242
Commit-Queue: Victor Miura <vmiura@chromium.org>
Reviewed-by: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: vmpstr <vmpstr@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Reviewed-by: Eric Karl <ericrk@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523700}
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 168a79e..40a6486 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -363,6 +363,7 @@
     "//gpu",
     "//gpu/command_buffer/client:gles2_implementation",
     "//gpu/command_buffer/client:gles2_interface",
+    "//gpu/command_buffer/client:raster_interface",
     "//gpu/ipc:gl_in_process_context",
     "//gpu/skia_bindings:skia_bindings",
     "//gpu/vulkan:features",
@@ -728,6 +729,7 @@
     "//gpu:test_support",
     "//gpu/command_buffer/client:gles2_implementation",
     "//gpu/command_buffer/client:gles2_interface",
+    "//gpu/command_buffer/client:raster_interface",
     "//gpu/command_buffer/common:gles2_utils",
     "//gpu/ipc:gl_in_process_context",
     "//gpu/skia_bindings",
@@ -780,6 +782,7 @@
     "//components/viz/test:test_support",
     "//gpu",
     "//gpu:test_support",
+    "//gpu/command_buffer/client:gles2_implementation",
     "//gpu/command_buffer/common:gles2_utils",
     "//media",
     "//mojo/edk/system",
diff --git a/cc/DEPS b/cc/DEPS
index 96ddcce4..4c75c7d 100644
--- a/cc/DEPS
+++ b/cc/DEPS
@@ -6,12 +6,14 @@
   "+gpu/command_buffer/client/gles2_interface.h",
   "+gpu/command_buffer/client/gles2_interface_stub.h", # for tests
   "+gpu/command_buffer/client/gpu_memory_buffer_manager.h",
+  "+gpu/command_buffer/client/raster_implementation_gles.h",
   "+gpu/command_buffer/common/capabilities.h",
   "+gpu/command_buffer/common/discardable_handle.h",
   "+gpu/command_buffer/common/gpu_memory_allocation.h",
   "+gpu/command_buffer/common/gpu_memory_buffer_support.h",
   "+gpu/command_buffer/common/mailbox.h",
   "+gpu/command_buffer/common/mailbox_holder.h",
+  "+gpu/command_buffer/client/raster_interface.h",
   "+gpu/command_buffer/common/sync_token.h",
   "+gpu/command_buffer/common/texture_in_use_response.h",
   "+gpu/config/gpu_feature_info.h",
@@ -28,7 +30,7 @@
   "+ui/gl",
   "-cc/blink",
 ]
-  
+
 specific_include_rules = {
   "in_process_context_provider\.cc": [
     "+gpu/command_buffer/client",
diff --git a/cc/raster/gpu_raster_buffer_provider.cc b/cc/raster/gpu_raster_buffer_provider.cc
index ec0fc0a..f1d915e 100644
--- a/cc/raster/gpu_raster_buffer_provider.cc
+++ b/cc/raster/gpu_raster_buffer_provider.cc
@@ -21,6 +21,7 @@
 #include "cc/resources/resource.h"
 #include "gpu/command_buffer/client/context_support.h"
 #include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/client/raster_interface.h"
 #include "third_party/skia/include/core/SkMultiPictureDraw.h"
 #include "third_party/skia/include/core/SkPictureRecorder.h"
 #include "third_party/skia/include/core/SkSurface.h"
@@ -39,28 +40,28 @@
     const gfx::AxisTransform2d& transform,
     const RasterSource::PlaybackSettings& playback_settings,
     viz::ContextProvider* context_provider,
-    ResourceProvider::ScopedWriteLockGL* resource_lock,
+    ResourceProvider::ScopedWriteLockRaster* resource_lock,
     bool use_distance_field_text,
     int msaa_sample_count) {
-  gpu::gles2::GLES2Interface* gl = context_provider->ContextGL();
-  GLuint texture_id = resource_lock->ConsumeTexture(gl);
+  gpu::raster::RasterInterface* ri = context_provider->RasterContext();
+  GLuint texture_id = resource_lock->ConsumeTexture(ri);
 
-  gl->BeginRasterCHROMIUM(texture_id, raster_source->background_color(),
+  ri->BeginRasterCHROMIUM(texture_id, raster_source->background_color(),
                           msaa_sample_count, playback_settings.use_lcd_text,
                           use_distance_field_text,
                           resource_lock->PixelConfig());
   // TODO(enne): need to pass color space into this function as well.
   float recording_to_raster_scale =
       transform.scale() / raster_source->recording_scale_factor();
-  gl->RasterCHROMIUM(raster_source->GetDisplayItemList().get(),
+  ri->RasterCHROMIUM(raster_source->GetDisplayItemList().get(),
                      raster_full_rect.x(), raster_full_rect.y(),
                      playback_rect.x(), playback_rect.y(),
                      playback_rect.width(), playback_rect.height(),
                      transform.translation().x(), transform.translation().y(),
                      recording_to_raster_scale);
-  gl->EndRasterCHROMIUM();
+  ri->EndRasterCHROMIUM();
 
-  gl->DeleteTextures(1, &texture_id);
+  ri->DeleteTextures(1, &texture_id);
 }
 
 static void RasterizeSource(
@@ -72,13 +73,13 @@
     const gfx::AxisTransform2d& transform,
     const RasterSource::PlaybackSettings& playback_settings,
     viz::ContextProvider* context_provider,
-    ResourceProvider::ScopedWriteLockGL* resource_lock,
+    ResourceProvider::ScopedWriteLockRaster* resource_lock,
     bool use_distance_field_text,
     int msaa_sample_count) {
   ScopedGpuRaster gpu_raster(context_provider);
 
-  gpu::gles2::GLES2Interface* gl = context_provider->ContextGL();
-  GLuint texture_id = resource_lock->ConsumeTexture(gl);
+  gpu::raster::RasterInterface* ri = context_provider->RasterContext();
+  GLuint texture_id = resource_lock->ConsumeTexture(ri);
 
   {
     ResourceProvider::ScopedSkSurface scoped_surface(
@@ -106,7 +107,7 @@
         playback_rect, transform, playback_settings);
   }
 
-  gl->DeleteTextures(1, &texture_id);
+  ri->DeleteTextures(1, &texture_id);
 }
 
 }  // namespace
@@ -265,7 +266,7 @@
 }
 
 void GpuRasterBufferProvider::PlaybackOnWorkerThread(
-    ResourceProvider::ScopedWriteLockGL* resource_lock,
+    ResourceProvider::ScopedWriteLockRaster* resource_lock,
     const gpu::SyncToken& sync_token,
     bool resource_has_previous_content,
     const RasterSource* raster_source,
@@ -276,11 +277,11 @@
     const RasterSource::PlaybackSettings& playback_settings) {
   viz::ContextProvider::ScopedContextLock scoped_context(
       worker_context_provider_);
-  gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
-  DCHECK(gl);
+  gpu::raster::RasterInterface* ri = scoped_context.RasterContext();
+  DCHECK(ri);
 
   // Synchronize with compositor. Nop if sync token is empty.
-  gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
+  ri->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
 
   gfx::Rect playback_rect = raster_full_rect;
   if (resource_has_previous_content) {
@@ -318,7 +319,7 @@
   }
 
   // Generate sync token for cross context synchronization.
-  resource_lock->set_sync_token(ResourceProvider::GenerateSyncTokenHelper(gl));
+  resource_lock->set_sync_token(ResourceProvider::GenerateSyncTokenHelper(ri));
 
   // Mark resource as synchronized when worker and compositor are in same stream
   // to prevent extra wait sync token calls.
diff --git a/cc/raster/gpu_raster_buffer_provider.h b/cc/raster/gpu_raster_buffer_provider.h
index d1f8634..57d75fba5 100644
--- a/cc/raster/gpu_raster_buffer_provider.h
+++ b/cc/raster/gpu_raster_buffer_provider.h
@@ -48,7 +48,7 @@
   void Shutdown() override;
 
   void PlaybackOnWorkerThread(
-      ResourceProvider::ScopedWriteLockGL* resource_lock,
+      ResourceProvider::ScopedWriteLockRaster* resource_lock,
       const gpu::SyncToken& sync_token,
       bool resource_has_previous_content,
       const RasterSource* raster_source,
@@ -82,7 +82,7 @@
 
    private:
     GpuRasterBufferProvider* const client_;
-    ResourceProvider::ScopedWriteLockGL lock_;
+    ResourceProvider::ScopedWriteLockRaster lock_;
     const bool resource_has_previous_content_;
 
     gpu::SyncToken sync_token_;
diff --git a/cc/raster/one_copy_raster_buffer_provider.cc b/cc/raster/one_copy_raster_buffer_provider.cc
index 35fc45bb..ea3487eb 100644
--- a/cc/raster/one_copy_raster_buffer_provider.cc
+++ b/cc/raster/one_copy_raster_buffer_provider.cc
@@ -24,6 +24,7 @@
 #include "gpu/command_buffer/client/context_support.h"
 #include "gpu/command_buffer/client/gles2_interface.h"
 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
+#include "gpu/command_buffer/client/raster_interface.h"
 #include "ui/gfx/buffer_format_util.h"
 
 namespace cc {
@@ -201,7 +202,7 @@
 
 void OneCopyRasterBufferProvider::PlaybackAndCopyOnWorkerThread(
     const Resource* resource,
-    ResourceProvider::ScopedWriteLockGL* resource_lock,
+    ResourceProvider::ScopedWriteLockRaster* resource_lock,
     const gpu::SyncToken& sync_token,
     const RasterSource* raster_source,
     const gfx::Rect& raster_full_rect,
@@ -230,10 +231,10 @@
     const gpu::SyncToken& sync_token) {
   viz::ContextProvider::ScopedContextLock scoped_context(
       worker_context_provider_);
-  gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
-  DCHECK(gl);
+  gpu::raster::RasterInterface* ri = scoped_context.RasterContext();
+  DCHECK(ri);
   // Synchronize with compositor. Nop if sync token is empty.
-  gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
+  ri->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
 }
 
 void OneCopyRasterBufferProvider::PlaybackToStagingBuffer(
@@ -300,65 +301,65 @@
 
 void OneCopyRasterBufferProvider::CopyOnWorkerThread(
     StagingBuffer* staging_buffer,
-    ResourceProvider::ScopedWriteLockGL* resource_lock,
+    ResourceProvider::ScopedWriteLockRaster* resource_lock,
     const RasterSource* raster_source,
     const gfx::Rect& rect_to_copy) {
   viz::ContextProvider::ScopedContextLock scoped_context(
       worker_context_provider_);
-  gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
-  DCHECK(gl);
+  gpu::raster::RasterInterface* ri = scoped_context.RasterContext();
+  DCHECK(ri);
 
-  GLuint texture_id = resource_lock->ConsumeTexture(gl);
+  GLuint texture_id = resource_lock->ConsumeTexture(ri);
 
   GLenum image_target = resource_provider_->GetImageTextureTarget(
       StagingBufferUsage(), staging_buffer->format);
 
   // Create and bind staging texture.
   if (!staging_buffer->texture_id) {
-    gl->GenTextures(1, &staging_buffer->texture_id);
-    gl->BindTexture(image_target, staging_buffer->texture_id);
-    gl->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    gl->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    gl->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    gl->TexParameteri(image_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    ri->GenTextures(1, &staging_buffer->texture_id);
+    ri->BindTexture(image_target, staging_buffer->texture_id);
+    ri->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    ri->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    ri->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    ri->TexParameteri(image_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
   } else {
-    gl->BindTexture(image_target, staging_buffer->texture_id);
+    ri->BindTexture(image_target, staging_buffer->texture_id);
   }
 
   // Create and bind image.
   if (!staging_buffer->image_id) {
     if (staging_buffer->gpu_memory_buffer) {
-      staging_buffer->image_id = gl->CreateImageCHROMIUM(
+      staging_buffer->image_id = ri->CreateImageCHROMIUM(
           staging_buffer->gpu_memory_buffer->AsClientBuffer(),
           staging_buffer->size.width(), staging_buffer->size.height(),
           GLInternalFormat(resource_lock->format()));
-      gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
+      ri->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
     }
   } else {
-    gl->ReleaseTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
-    gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
+    ri->ReleaseTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
+    ri->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
   }
 
   // Unbind staging texture.
-  gl->BindTexture(image_target, 0);
+  ri->BindTexture(image_target, 0);
 
   if (resource_provider_->use_sync_query()) {
     if (!staging_buffer->query_id)
-      gl->GenQueriesEXT(1, &staging_buffer->query_id);
+      ri->GenQueriesEXT(1, &staging_buffer->query_id);
 
 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
     // TODO(reveman): This avoids a performance problem on ARM ChromeOS
     // devices. crbug.com/580166
-    gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, staging_buffer->query_id);
+    ri->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, staging_buffer->query_id);
 #else
-    gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, staging_buffer->query_id);
+    ri->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, staging_buffer->query_id);
 #endif
   }
 
   // Since compressed texture's cannot be pre-allocated we might have an
   // unallocated resource in which case we need to perform a full size copy.
   if (IsResourceFormatCompressed(resource_lock->format())) {
-    gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, texture_id);
+    ri->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, texture_id);
   } else {
     int bytes_per_row = ResourceUtil::UncheckedWidthInBytes<int>(
         rect_to_copy.width(), resource_lock->format());
@@ -373,7 +374,7 @@
       int rows_to_copy = std::min(chunk_size_in_rows, height - y);
       DCHECK_GT(rows_to_copy, 0);
 
-      gl->CopySubTextureCHROMIUM(
+      ri->CopySubTextureCHROMIUM(
           staging_buffer->texture_id, 0, GL_TEXTURE_2D, texture_id, 0, 0, y, 0,
           y, rect_to_copy.width(), rows_to_copy, false, false, false);
       y += rows_to_copy;
@@ -383,7 +384,7 @@
       bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row;
 
       if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) {
-        gl->ShallowFlushCHROMIUM();
+        ri->ShallowFlushCHROMIUM();
         bytes_scheduled_since_last_flush_ = 0;
       }
     }
@@ -391,16 +392,16 @@
 
   if (resource_provider_->use_sync_query()) {
 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
-    gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
+    ri->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
 #else
-    gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
+    ri->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
 #endif
   }
 
-  gl->DeleteTextures(1, &texture_id);
+  ri->DeleteTextures(1, &texture_id);
 
   // Generate sync token for cross context synchronization.
-  resource_lock->set_sync_token(ResourceProvider::GenerateSyncTokenHelper(gl));
+  resource_lock->set_sync_token(ResourceProvider::GenerateSyncTokenHelper(ri));
 
   // Mark resource as synchronized when worker and compositor are in same stream
   // to prevent extra wait sync token calls.
diff --git a/cc/raster/one_copy_raster_buffer_provider.h b/cc/raster/one_copy_raster_buffer_provider.h
index 9b87f229..14b41721e 100644
--- a/cc/raster/one_copy_raster_buffer_provider.h
+++ b/cc/raster/one_copy_raster_buffer_provider.h
@@ -51,7 +51,7 @@
   // Playback raster source and copy result into |resource|.
   void PlaybackAndCopyOnWorkerThread(
       const Resource* resource,
-      ResourceProvider::ScopedWriteLockGL* resource_lock,
+      ResourceProvider::ScopedWriteLockRaster* resource_lock,
       const gpu::SyncToken& sync_token,
       const RasterSource* raster_source,
       const gfx::Rect& raster_full_rect,
@@ -86,7 +86,7 @@
    private:
     OneCopyRasterBufferProvider* client_;
     const Resource* resource_;
-    ResourceProvider::ScopedWriteLockGL lock_;
+    ResourceProvider::ScopedWriteLockRaster lock_;
     uint64_t previous_content_id_;
 
     gpu::SyncToken sync_token_;
@@ -106,10 +106,11 @@
       const RasterSource::PlaybackSettings& playback_settings,
       uint64_t previous_content_id,
       uint64_t new_content_id);
-  void CopyOnWorkerThread(StagingBuffer* staging_buffer,
-                          ResourceProvider::ScopedWriteLockGL* resource_lock,
-                          const RasterSource* raster_source,
-                          const gfx::Rect& rect_to_copy);
+  void CopyOnWorkerThread(
+      StagingBuffer* staging_buffer,
+      ResourceProvider::ScopedWriteLockRaster* resource_lock,
+      const RasterSource* raster_source,
+      const gfx::Rect& rect_to_copy);
   gfx::BufferUsage StagingBufferUsage() const;
 
   viz::ContextProvider* const compositor_context_provider_;
diff --git a/cc/raster/raster_buffer_provider_perftest.cc b/cc/raster/raster_buffer_provider_perftest.cc
index 7b53d4bd..a95457e4 100644
--- a/cc/raster/raster_buffer_provider_perftest.cc
+++ b/cc/raster/raster_buffer_provider_perftest.cc
@@ -29,6 +29,7 @@
 #include "components/viz/common/gpu/context_provider.h"
 #include "components/viz/common/resources/platform_color.h"
 #include "components/viz/test/test_gpu_memory_buffer_manager.h"
+#include "gpu/command_buffer/client/raster_implementation_gles.h"
 #include "gpu/command_buffer/common/sync_token.h"
 #include "gpu/config/gpu_feature_info.h"
 #include "testing/gtest/include/gtest/gtest.h"
@@ -85,6 +86,9 @@
       : context_gl_(new PerfGLES2Interface),
         cache_controller_(&support_, nullptr) {
     capabilities_.sync_query = true;
+
+    raster_context_ = std::make_unique<gpu::raster::RasterImplementationGLES>(
+        context_gl_.get(), capabilities_);
   }
 
   gpu::ContextResult BindToCurrentThread() override {
@@ -97,6 +101,9 @@
     return gpu_feature_info_;
   }
   gpu::gles2::GLES2Interface* ContextGL() override { return context_gl_.get(); }
+  gpu::raster::RasterInterface* RasterContext() override {
+    return raster_context_.get();
+  }
   gpu::ContextSupport* ContextSupport() override { return &support_; }
   class GrContext* GrContext() override {
     if (gr_context_)
@@ -122,6 +129,7 @@
   ~PerfContextProvider() override = default;
 
   std::unique_ptr<PerfGLES2Interface> context_gl_;
+  std::unique_ptr<gpu::raster::RasterInterface> raster_context_;
   sk_sp<class GrContext> gr_context_;
   TestContextSupport support_;
   viz::ContextCacheController cache_controller_;
diff --git a/cc/raster/staging_buffer_pool.cc b/cc/raster/staging_buffer_pool.cc
index bef94ed..dd7c829 100644
--- a/cc/raster/staging_buffer_pool.cc
+++ b/cc/raster/staging_buffer_pool.cc
@@ -13,7 +13,7 @@
 #include "base/trace_event/memory_dump_manager.h"
 #include "cc/base/container_util.h"
 #include "cc/resources/scoped_resource.h"
-#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/client/raster_interface.h"
 
 using base::trace_event::MemoryAllocatorDump;
 using base::trace_event::MemoryAllocatorDumpGuid;
@@ -32,30 +32,30 @@
 // Delay before a staging buffer might be released.
 const int kStagingBufferExpirationDelayMs = 1000;
 
-bool CheckForQueryResult(gpu::gles2::GLES2Interface* gl, unsigned query_id) {
+bool CheckForQueryResult(gpu::raster::RasterInterface* ri, unsigned query_id) {
   unsigned complete = 1;
-  gl->GetQueryObjectuivEXT(query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &complete);
+  ri->GetQueryObjectuivEXT(query_id, GL_QUERY_RESULT_AVAILABLE_EXT, &complete);
   return !!complete;
 }
 
-void WaitForQueryResult(gpu::gles2::GLES2Interface* gl, unsigned query_id) {
+void WaitForQueryResult(gpu::raster::RasterInterface* ri, unsigned query_id) {
   TRACE_EVENT0("cc", "WaitForQueryResult");
 
   int attempts_left = kMaxCheckForQueryResultAvailableAttempts;
   while (attempts_left--) {
-    if (CheckForQueryResult(gl, query_id))
+    if (CheckForQueryResult(ri, query_id))
       break;
 
     // We have to flush the context to be guaranteed that a query result will
     // be available in a finite amount of time.
-    gl->ShallowFlushCHROMIUM();
+    ri->ShallowFlushCHROMIUM();
 
     base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(
         kCheckForQueryResultAvailableTickRateMs));
   }
 
   unsigned result = 0;
-  gl->GetQueryObjectuivEXT(query_id, GL_QUERY_RESULT_EXT, &result);
+  ri->GetQueryObjectuivEXT(query_id, GL_QUERY_RESULT_EXT, &result);
 }
 
 }  // namespace
@@ -74,17 +74,17 @@
   DCHECK_EQ(query_id, 0u);
 }
 
-void StagingBuffer::DestroyGLResources(gpu::gles2::GLES2Interface* gl) {
+void StagingBuffer::DestroyGLResources(gpu::raster::RasterInterface* ri) {
   if (query_id) {
-    gl->DeleteQueriesEXT(1, &query_id);
+    ri->DeleteQueriesEXT(1, &query_id);
     query_id = 0;
   }
   if (image_id) {
-    gl->DestroyImageCHROMIUM(image_id);
+    ri->DestroyImageCHROMIUM(image_id);
     image_id = 0;
   }
   if (texture_id) {
-    gl->DeleteTextures(1, &texture_id);
+    ri->DeleteTextures(1, &texture_id);
     texture_id = 0;
   }
 }
@@ -254,13 +254,13 @@
   viz::ContextProvider::ScopedContextLock scoped_context(
       worker_context_provider_);
 
-  gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
-  DCHECK(gl);
+  gpu::raster::RasterInterface* ri = scoped_context.RasterContext();
+  DCHECK(ri);
 
   // Check if any busy buffers have become available.
   if (resource_provider_->use_sync_query()) {
     while (!busy_buffers_.empty()) {
-      if (!CheckForQueryResult(gl, busy_buffers_.front()->query_id))
+      if (!CheckForQueryResult(ri, busy_buffers_.front()->query_id))
         break;
 
       MarkStagingBufferAsFree(busy_buffers_.front().get());
@@ -277,12 +277,12 @@
       break;
 
     if (resource_provider_->use_sync_query()) {
-      WaitForQueryResult(gl, busy_buffers_.front()->query_id);
+      WaitForQueryResult(ri, busy_buffers_.front()->query_id);
       MarkStagingBufferAsFree(busy_buffers_.front().get());
       free_buffers_.push_back(PopFront(&busy_buffers_));
     } else {
       // Fall-back to glFinish if CHROMIUM_sync_query is not available.
-      gl->Finish();
+      ri->Finish();
       while (!busy_buffers_.empty()) {
         MarkStagingBufferAsFree(busy_buffers_.front().get());
         free_buffers_.push_back(PopFront(&busy_buffers_));
@@ -332,7 +332,7 @@
     if (free_buffers_.empty())
       break;
 
-    free_buffers_.front()->DestroyGLResources(gl);
+    free_buffers_.front()->DestroyGLResources(ri);
     MarkStagingBufferAsBusy(free_buffers_.front().get());
     RemoveStagingBuffer(free_buffers_.front().get());
     free_buffers_.pop_front();
@@ -401,8 +401,8 @@
     viz::ContextProvider::ScopedContextLock scoped_context(
         worker_context_provider_);
 
-    gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
-    DCHECK(gl);
+    gpu::raster::RasterInterface* ri = scoped_context.RasterContext();
+    DCHECK(ri);
 
     // Note: Front buffer is guaranteed to be LRU so we can stop releasing
     // buffers as soon as we find a buffer that has been used since |time|.
@@ -410,7 +410,7 @@
       if (free_buffers_.front()->last_usage > time)
         return;
 
-      free_buffers_.front()->DestroyGLResources(gl);
+      free_buffers_.front()->DestroyGLResources(ri);
       MarkStagingBufferAsBusy(free_buffers_.front().get());
       RemoveStagingBuffer(free_buffers_.front().get());
       free_buffers_.pop_front();
@@ -420,7 +420,7 @@
       if (busy_buffers_.front()->last_usage > time)
         return;
 
-      busy_buffers_.front()->DestroyGLResources(gl);
+      busy_buffers_.front()->DestroyGLResources(ri);
       RemoveStagingBuffer(busy_buffers_.front().get());
       busy_buffers_.pop_front();
     }
diff --git a/cc/raster/staging_buffer_pool.h b/cc/raster/staging_buffer_pool.h
index 299831c4..34f5140 100644
--- a/cc/raster/staging_buffer_pool.h
+++ b/cc/raster/staging_buffer_pool.h
@@ -22,8 +22,8 @@
 #include "components/viz/common/gpu/context_provider.h"
 
 namespace gpu {
-namespace gles2 {
-class GLES2Interface;
+namespace raster {
+class RasterInterface;
 }
 }
 
@@ -34,7 +34,7 @@
   StagingBuffer(const gfx::Size& size, viz::ResourceFormat format);
   ~StagingBuffer();
 
-  void DestroyGLResources(gpu::gles2::GLES2Interface* gl);
+  void DestroyGLResources(gpu::raster::RasterInterface* gl);
   void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
                     viz::ResourceFormat format,
                     bool is_free) const;
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 0aef367..7f9e545 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -33,6 +33,7 @@
 #include "gpu/command_buffer/client/context_support.h"
 #include "gpu/command_buffer/client/gles2_interface.h"
 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
+#include "gpu/command_buffer/client/raster_interface.h"
 #include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
 #include "skia/ext/texture_handle.h"
 #include "third_party/khronos/GLES2/gl2.h"
@@ -648,7 +649,7 @@
   resource->read_lock_fences_enabled = true;
 }
 
-ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL(
+ResourceProvider::ScopedWriteLockGpu::ScopedWriteLockGpu(
     ResourceProvider* resource_provider,
     viz::ResourceId resource_id)
     : resource_provider_(resource_provider), resource_id_(resource_id) {
@@ -667,7 +668,7 @@
   allocated_ = resource->allocated;
 }
 
-ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() {
+ResourceProvider::ScopedWriteLockGpu::~ScopedWriteLockGpu() {
   viz::internal::Resource* resource =
       resource_provider_->GetResource(resource_id_);
   DCHECK(resource->locked_for_write);
@@ -683,16 +684,11 @@
   resource_provider_->UnlockForWrite(resource);
 }
 
-GrPixelConfig ResourceProvider::ScopedWriteLockGL::PixelConfig() const {
+GrPixelConfig ResourceProvider::ScopedWriteLockGpu::PixelConfig() const {
   return ToGrPixelConfig(format_);
 }
 
-GLuint ResourceProvider::ScopedWriteLockGL::GetTexture() {
-  LazyAllocate(resource_provider_->ContextGL(), texture_id_);
-  return texture_id_;
-}
-
-void ResourceProvider::ScopedWriteLockGL::CreateMailbox() {
+void ResourceProvider::ScopedWriteLockGpu::CreateMailbox() {
   if (!mailbox_.IsZero())
     return;
   gpu::gles2::GLES2Interface* gl = resource_provider_->ContextGL();
@@ -701,17 +697,16 @@
   gl->ProduceTextureDirectCHROMIUM(texture_id_, mailbox_.name);
 }
 
-GLuint ResourceProvider::ScopedWriteLockGL::ConsumeTexture(
-    gpu::gles2::GLES2Interface* gl) {
-  DCHECK(gl);
-  DCHECK(!mailbox_.IsZero());
+ResourceProvider::ScopedWriteLockGL::ScopedWriteLockGL(
+    ResourceProvider* resource_provider,
+    viz::ResourceId resource_id)
+    : ScopedWriteLockGpu(resource_provider, resource_id) {}
 
-  GLuint texture_id = gl->CreateAndConsumeTextureCHROMIUM(mailbox_.name);
-  DCHECK(texture_id);
+ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() {}
 
-  LazyAllocate(gl, texture_id);
-
-  return texture_id;
+GLuint ResourceProvider::ScopedWriteLockGL::GetTexture() {
+  LazyAllocate(resource_provider_->ContextGL(), texture_id_);
+  return texture_id_;
 }
 
 void ResourceProvider::ScopedWriteLockGL::LazyAllocate(
@@ -753,6 +748,47 @@
   }
 }
 
+ResourceProvider::ScopedWriteLockRaster::ScopedWriteLockRaster(
+    ResourceProvider* resource_provider,
+    viz::ResourceId resource_id)
+    : ScopedWriteLockGpu(resource_provider, resource_id) {}
+
+ResourceProvider::ScopedWriteLockRaster::~ScopedWriteLockRaster() {}
+
+GLuint ResourceProvider::ScopedWriteLockRaster::ConsumeTexture(
+    gpu::raster::RasterInterface* ri) {
+  DCHECK(ri);
+  DCHECK(!mailbox_.IsZero());
+
+  GLuint texture_id = ri->CreateAndConsumeTextureCHROMIUM(mailbox_.name);
+  DCHECK(texture_id);
+
+  LazyAllocate(ri, texture_id);
+
+  return texture_id;
+}
+
+void ResourceProvider::ScopedWriteLockRaster::LazyAllocate(
+    gpu::raster::RasterInterface* ri,
+    GLuint texture_id) {
+  // ETC1 resources cannot be preallocated.
+  if (format_ == viz::ETC1)
+    return;
+
+  if (allocated_)
+    return;
+  allocated_ = true;
+
+  ri->BindTexture(target_, texture_id);
+  ri->TexStorageForRaster(
+      target_, format_, size_.width(), size_.height(),
+      is_overlay_ ? gpu::raster::kOverlay : gpu::raster::kNone);
+  if (is_overlay_ && color_space_.IsValid()) {
+    ri->SetColorSpaceMetadataCHROMIUM(
+        texture_id, reinterpret_cast<GLColorSpace>(&color_space_));
+  }
+}
+
 ResourceProvider::ScopedSkSurface::ScopedSkSurface(GrContext* gr_context,
                                                    GLuint texture_id,
                                                    GLenum texture_target,
@@ -1015,6 +1051,24 @@
   return sync_token;
 }
 
+gpu::SyncToken ResourceProvider::GenerateSyncTokenHelper(
+    gpu::raster::RasterInterface* ri) {
+  DCHECK(ri);
+  const uint64_t fence_sync = ri->InsertFenceSyncCHROMIUM();
+
+  // Barrier to sync worker context output to cc context.
+  ri->OrderingBarrierCHROMIUM();
+
+  // Generate sync token after the barrier for cross context synchronization.
+  gpu::SyncToken sync_token;
+  ri->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
+
+  DCHECK(sync_token.HasData() ||
+         ri->GetGraphicsResetStatusKHR() != GL_NO_ERROR);
+
+  return sync_token;
+}
+
 GLenum ResourceProvider::GetImageTextureTarget(
     gfx::BufferUsage usage,
     viz::ResourceFormat format) const {
diff --git a/cc/resources/resource_provider.h b/cc/resources/resource_provider.h
index caf9726..268857f 100644
--- a/cc/resources/resource_provider.h
+++ b/cc/resources/resource_provider.h
@@ -54,6 +54,9 @@
 namespace gles {
 class GLES2Interface;
 }
+namespace raster {
+class RasterInterface;
+}
 }
 
 namespace viz {
@@ -164,11 +167,11 @@
   // needed to read and write the resource contents. The user must ensure
   // that they only use GL locks on GL resources, etc, and this is enforced
   // by assertions.
-  class CC_EXPORT ScopedWriteLockGL {
+  class CC_EXPORT ScopedWriteLockGpu {
    public:
-    ScopedWriteLockGL(ResourceProvider* resource_provider,
-                      viz::ResourceId resource_id);
-    ~ScopedWriteLockGL();
+    ScopedWriteLockGpu(ResourceProvider* resource_provider,
+                       viz::ResourceId resource_id);
+    ~ScopedWriteLockGpu();
 
     GLenum target() const { return target_; }
     viz::ResourceFormat format() const { return format_; }
@@ -190,19 +193,11 @@
 
     void set_generate_mipmap() { generate_mipmap_ = true; }
 
-    // Returns texture id on compositor context, allocating if necessary.
-    GLuint GetTexture();
-
-    // Creates mailbox that can be consumed on another context.
+    // Creates mailbox on compositor context that can be consumed on another
+    // context.
     void CreateMailbox();
 
-    // Creates a texture id, allocating if necessary, on the given context. The
-    // texture id must be deleted by the caller.
-    GLuint ConsumeTexture(gpu::gles2::GLES2Interface* gl);
-
-   private:
-    void LazyAllocate(gpu::gles2::GLES2Interface* gl, GLuint texture_id);
-
+   protected:
     ResourceProvider* const resource_provider_;
     const viz::ResourceId resource_id_;
 
@@ -223,9 +218,41 @@
     bool synchronized_ = false;
     bool generate_mipmap_ = false;
 
+   private:
+    DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGpu);
+  };
+
+  class CC_EXPORT ScopedWriteLockGL : public ScopedWriteLockGpu {
+   public:
+    ScopedWriteLockGL(ResourceProvider* resource_provider,
+                      viz::ResourceId resource_id);
+    ~ScopedWriteLockGL();
+
+    // Returns texture id on compositor context, allocating if necessary.
+    GLuint GetTexture();
+
+   private:
+    void LazyAllocate(gpu::gles2::GLES2Interface* gl, GLuint texture_id);
+
     DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL);
   };
 
+  class CC_EXPORT ScopedWriteLockRaster : public ScopedWriteLockGpu {
+   public:
+    ScopedWriteLockRaster(ResourceProvider* resource_provider,
+                          viz::ResourceId resource_id);
+    ~ScopedWriteLockRaster();
+
+    // Creates a texture id, allocating if necessary, on the given context. The
+    // texture id must be deleted by the caller.
+    GLuint ConsumeTexture(gpu::raster::RasterInterface* ri);
+
+   private:
+    void LazyAllocate(gpu::raster::RasterInterface* gl, GLuint texture_id);
+
+    DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockRaster);
+  };
+
   // TODO(sunnyps): Move to //components/viz/common/gl_helper.h ?
   class CC_EXPORT ScopedSkSurface {
    public:
@@ -322,6 +349,8 @@
   static GLint GetActiveTextureUnit(gpu::gles2::GLES2Interface* gl);
 
   static gpu::SyncToken GenerateSyncTokenHelper(gpu::gles2::GLES2Interface* gl);
+  static gpu::SyncToken GenerateSyncTokenHelper(
+      gpu::raster::RasterInterface* ri);
 
   GLenum GetImageTextureTarget(gfx::BufferUsage usage,
                                viz::ResourceFormat format) const;
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc
index ff1ed9f..4f22efb 100644
--- a/cc/resources/resource_provider_unittest.cc
+++ b/cc/resources/resource_provider_unittest.cc
@@ -3482,7 +3482,7 @@
   resource_provider->DeleteResource(id);
 }
 
-TEST_P(ResourceProviderTest, ScopedWriteLockGL_Mailbox) {
+TEST_P(ResourceProviderTest, ScopedWriteLockRaster_Mailbox) {
   if (GetParam() != viz::ResourceType::kTexture)
     return;
   std::unique_ptr<AllocationTrackingContext3D> context_owned(
@@ -3515,7 +3515,7 @@
     EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(kTextureId));
     EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId));
     EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber());
-    ResourceProvider::ScopedWriteLockGL lock(resource_provider.get(), id);
+    ResourceProvider::ScopedWriteLockRaster lock(resource_provider.get(), id);
     Mock::VerifyAndClearExpectations(context);
 
     EXPECT_CALL(*context, produceTextureDirectCHROMIUM(kTextureId, _));
@@ -3529,7 +3529,7 @@
                                      kWidth, kHeight, 0, GLDataFormat(format),
                                      GLDataType(format), nullptr));
     EXPECT_EQ(kWorkerTextureId,
-              lock.ConsumeTexture(context_provider->ContextGL()));
+              lock.ConsumeTexture(context_provider->RasterContext()));
     Mock::VerifyAndClearExpectations(context);
 
     EXPECT_CALL(*context, RetireTextureId(kWorkerTextureId));
@@ -3539,21 +3539,21 @@
 
   // Subsequent uses will not create mailbox or allocate.
   {
-    ResourceProvider::ScopedWriteLockGL lock(resource_provider.get(), id);
+    ResourceProvider::ScopedWriteLockRaster lock(resource_provider.get(), id);
     lock.CreateMailbox();
     Mock::VerifyAndClearExpectations(context);
 
     EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_))
         .WillOnce(Return(kWorkerTextureId));
     EXPECT_EQ(kWorkerTextureId,
-              lock.ConsumeTexture(context_provider->ContextGL()));
+              lock.ConsumeTexture(context_provider->RasterContext()));
     Mock::VerifyAndClearExpectations(context);
 
     EXPECT_CALL(*context, RetireTextureId(kWorkerTextureId));
     context_provider->ContextGL()->DeleteTextures(1, &kWorkerTextureId);
 
     sync_token = ResourceProvider::GenerateSyncTokenHelper(
-        context_provider->ContextGL());
+        context_provider->RasterContext());
     lock.set_sync_token(sync_token);
     Mock::VerifyAndClearExpectations(context);
   }
@@ -3564,7 +3564,7 @@
   resource_provider->DeleteResource(id);
 }
 
-TEST_P(ResourceProviderTest, ScopedWriteLockGL_Mailbox_Overlay) {
+TEST_P(ResourceProviderTest, ScopedWriteLockRaster_Mailbox_Overlay) {
   if (GetParam() != viz::ResourceType::kTexture)
     return;
 
@@ -3600,7 +3600,7 @@
     EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(kTextureId));
     EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId));
     EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber());
-    ResourceProvider::ScopedWriteLockGL lock(resource_provider.get(), id);
+    ResourceProvider::ScopedWriteLockRaster lock(resource_provider.get(), id);
     Mock::VerifyAndClearExpectations(context);
 
     EXPECT_CALL(*context, produceTextureDirectCHROMIUM(kTextureId, _));
@@ -3614,7 +3614,7 @@
                                                     GL_SCANOUT_CHROMIUM, kWidth,
                                                     kHeight));
     EXPECT_EQ(kWorkerTextureId,
-              lock.ConsumeTexture(context_provider->ContextGL()));
+              lock.ConsumeTexture(context_provider->RasterContext()));
     Mock::VerifyAndClearExpectations(context);
 
     EXPECT_CALL(*context, RetireTextureId(kWorkerTextureId));
@@ -3624,18 +3624,18 @@
 
   // Subsequent uses will not create mailbox or allocate.
   {
-    ResourceProvider::ScopedWriteLockGL lock(resource_provider.get(), id);
+    ResourceProvider::ScopedWriteLockRaster lock(resource_provider.get(), id);
     lock.CreateMailbox();
     Mock::VerifyAndClearExpectations(context);
 
     EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_))
         .WillOnce(Return(kWorkerTextureId));
     EXPECT_EQ(kWorkerTextureId,
-              lock.ConsumeTexture(context_provider->ContextGL()));
+              lock.ConsumeTexture(context_provider->RasterContext()));
     Mock::VerifyAndClearExpectations(context);
 
     sync_token = ResourceProvider::GenerateSyncTokenHelper(
-        context_provider->ContextGL());
+        context_provider->RasterContext());
     lock.set_sync_token(sync_token);
 
     EXPECT_CALL(*context, RetireTextureId(kWorkerTextureId));
diff --git a/cc/test/DEPS b/cc/test/DEPS
index c5c9556..5e9cc03 100644
--- a/cc/test/DEPS
+++ b/cc/test/DEPS
@@ -6,6 +6,7 @@
   "+gpu/command_buffer/client/gles2_implementation.h",
   "+gpu/command_buffer/client/gles2_interface_stub.h",
   "+gpu/command_buffer/client/gles2_lib.h",
+  "+gpu/command_buffer/client/raster_implementation_gles.h",
   "+gpu/command_buffer/client/shared_memory_limits.h",
   "+gpu/command_buffer/common/gles2_cmd_utils.h",
   "+gpu/command_buffer/service/image_factory.h",
diff --git a/cc/test/test_context_provider.cc b/cc/test/test_context_provider.cc
index e95e25b..ac385c7 100644
--- a/cc/test/test_context_provider.cc
+++ b/cc/test/test_context_provider.cc
@@ -18,6 +18,7 @@
 #include "cc/test/test_gles2_interface.h"
 #include "cc/test/test_web_graphics_context_3d.h"
 #include "components/viz/common/gpu/context_cache_controller.h"
+#include "gpu/command_buffer/client/raster_implementation_gles.h"
 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h"
 #include "third_party/skia/include/gpu/GrContext.h"
 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
@@ -189,6 +190,8 @@
   context_thread_checker_.DetachFromThread();
   context_gl_->set_test_context(context3d_.get());
   context3d_->set_test_support(support_.get());
+  raster_context_ = std::make_unique<gpu::raster::RasterImplementationGLES>(
+      context_gl_.get(), context3d_->test_capabilities());
   // Just pass nullptr to the viz::ContextCacheController for its task runner.
   // Idle handling is tested directly in viz::ContextCacheController's
   // unittests, and isn't needed here.
@@ -236,6 +239,10 @@
   return context_gl_.get();
 }
 
+gpu::raster::RasterInterface* TestContextProvider::RasterContext() {
+  return raster_context_.get();
+}
+
 gpu::ContextSupport* TestContextProvider::ContextSupport() {
   return support();
 }
diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h
index 37d4b00..209ae66e 100644
--- a/cc/test/test_context_provider.h
+++ b/cc/test/test_context_provider.h
@@ -54,6 +54,7 @@
   const gpu::Capabilities& ContextCapabilities() const override;
   const gpu::GpuFeatureInfo& GetGpuFeatureInfo() const override;
   gpu::gles2::GLES2Interface* ContextGL() override;
+  gpu::raster::RasterInterface* RasterContext() override;
   gpu::ContextSupport* ContextSupport() override;
   class GrContext* GrContext() override;
   viz::ContextCacheController* CacheController() override;
@@ -96,6 +97,7 @@
   std::unique_ptr<TestContextSupport> support_;
   std::unique_ptr<TestWebGraphicsContext3D> context3d_;
   std::unique_ptr<TestGLES2Interface> context_gl_;
+  std::unique_ptr<gpu::raster::RasterInterface> raster_context_;
   std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_;
   std::unique_ptr<viz::ContextCacheController> cache_controller_;
   const bool support_locking_ ALLOW_UNUSED_TYPE;
diff --git a/cc/test/test_in_process_context_provider.cc b/cc/test/test_in_process_context_provider.cc
index 36b677f..80c5113f 100644
--- a/cc/test/test_in_process_context_provider.cc
+++ b/cc/test/test_in_process_context_provider.cc
@@ -15,6 +15,7 @@
 #include "gpu/GLES2/gl2extchromium.h"
 #include "gpu/command_buffer/client/gles2_implementation.h"
 #include "gpu/command_buffer/client/gles2_lib.h"
+#include "gpu/command_buffer/client/raster_implementation_gles.h"
 #include "gpu/command_buffer/client/shared_memory_limits.h"
 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
 #include "gpu/ipc/gl_in_process_context.h"
@@ -78,6 +79,9 @@
       capabilities_.texture_format_bgra8888 = true;
       break;
   }
+
+  raster_context_ = std::make_unique<gpu::raster::RasterImplementationGLES>(
+      context_->GetImplementation(), capabilities_);
 }
 
 TestInProcessContextProvider::~TestInProcessContextProvider() = default;
@@ -90,6 +94,10 @@
   return context_->GetImplementation();
 }
 
+gpu::raster::RasterInterface* TestInProcessContextProvider::RasterContext() {
+  return raster_context_.get();
+}
+
 gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() {
   return context_->GetImplementation();
 }
diff --git a/cc/test/test_in_process_context_provider.h b/cc/test/test_in_process_context_provider.h
index ce61f806..082755b 100644
--- a/cc/test/test_in_process_context_provider.h
+++ b/cc/test/test_in_process_context_provider.h
@@ -42,6 +42,7 @@
 
   gpu::ContextResult BindToCurrentThread() override;
   gpu::gles2::GLES2Interface* ContextGL() override;
+  gpu::raster::RasterInterface* RasterContext() override;
   gpu::ContextSupport* ContextSupport() override;
   class GrContext* GrContext() override;
   viz::ContextCacheController* CacheController() override;
@@ -63,6 +64,7 @@
   viz::TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
   TestImageFactory image_factory_;
   std::unique_ptr<gpu::GLInProcessContext> context_;
+  std::unique_ptr<gpu::raster::RasterInterface> raster_context_;
   std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_;
   std::unique_ptr<viz::ContextCacheController> cache_controller_;
   base::Lock context_lock_;
diff --git a/cc/tiles/gpu_image_decode_cache.cc b/cc/tiles/gpu_image_decode_cache.cc
index d85d273..fdfb369 100644
--- a/cc/tiles/gpu_image_decode_cache.cc
+++ b/cc/tiles/gpu_image_decode_cache.cc
@@ -23,7 +23,7 @@
 #include "cc/tiles/mipmap_util.h"
 #include "components/viz/common/gpu/context_provider.h"
 #include "gpu/command_buffer/client/context_support.h"
-#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/client/raster_interface.h"
 #include "gpu_image_decode_cache.h"
 #include "skia/ext/texture_handle.h"
 #include "third_party/skia/include/core/SkCanvas.h"
@@ -1324,7 +1324,7 @@
     if (image_data->mode == DecodedDataMode::GPU) {
       // Notify the discardable system of this image so it will count against
       // budgets.
-      context_->ContextGL()->InitializeDiscardableTextureCHROMIUM(
+      context_->RasterContext()->InitializeDiscardableTextureCHROMIUM(
           image_data->upload.gl_id());
     }
   }
@@ -1387,15 +1387,15 @@
   images_pending_complete_lock_.clear();
 
   for (auto* image : images_pending_unlock_) {
-    context_->ContextGL()->UnlockDiscardableTextureCHROMIUM(
+    context_->RasterContext()->UnlockDiscardableTextureCHROMIUM(
         GlIdFromSkImage(image));
   }
   images_pending_unlock_.clear();
 
   for (auto& image : images_pending_deletion_) {
     uint32_t texture_id = GlIdFromSkImage(image.get());
-    if (context_->ContextGL()->LockDiscardableTextureCHROMIUM(texture_id)) {
-      context_->ContextGL()->DeleteTextures(1, &texture_id);
+    if (context_->RasterContext()->LockDiscardableTextureCHROMIUM(texture_id)) {
+      context_->RasterContext()->DeleteTextures(1, &texture_id);
     }
   }
   images_pending_deletion_.clear();
@@ -1418,7 +1418,7 @@
     return true;
 
   if (have_context_lock == HaveContextLock::kYes &&
-      context_->ContextGL()->LockDiscardableTextureCHROMIUM(
+      context_->RasterContext()->LockDiscardableTextureCHROMIUM(
           data->upload.gl_id())) {
     // If |have_context_lock|, we can immediately lock the image and send
     // the lock command to the GPU process.
diff --git a/cc/trees/layer_tree_frame_sink.cc b/cc/trees/layer_tree_frame_sink.cc
index f135e89..3d905212 100644
--- a/cc/trees/layer_tree_frame_sink.cc
+++ b/cc/trees/layer_tree_frame_sink.cc
@@ -15,7 +15,7 @@
 #include "components/viz/common/gpu/context_lost_observer.h"
 #include "gpu/GLES2/gl2extchromium.h"
 #include "gpu/command_buffer/client/context_support.h"
-#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/client/raster_interface.h"
 
 namespace cc {
 
@@ -89,8 +89,8 @@
     DCHECK(compositor_task_runner_->BelongsToCurrentThread());
     viz::ContextProvider::ScopedContextLock lock(
         worker_context_provider_.get());
-    if (worker_context_provider_->ContextGL()->GetGraphicsResetStatusKHR() !=
-        GL_NO_ERROR) {
+    if (worker_context_provider_->RasterContext()
+            ->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
       context_provider_->RemoveObserver(this);
       context_provider_ = nullptr;
       return false;
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 302e808aff..272f50e 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -87,6 +87,7 @@
 #include "gpu/GLES2/gl2extchromium.h"
 #include "gpu/command_buffer/client/context_support.h"
 #include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/client/raster_interface.h"
 #include "services/metrics/public/cpp/ukm_recorder.h"
 #include "third_party/skia/include/gpu/GrContext.h"
 #include "ui/gfx/geometry/point_conversions.h"
@@ -2673,7 +2674,7 @@
     if (auto* worker_context =
             layer_tree_frame_sink_->worker_context_provider()) {
       viz::ContextProvider::ScopedContextLock hold(worker_context);
-      worker_context->ContextGL()->ShallowFlushCHROMIUM();
+      worker_context->RasterContext()->ShallowFlushCHROMIUM();
     }
   }
 }
diff --git a/cc/trees/layer_tree_host_pixeltest_tiles.cc b/cc/trees/layer_tree_host_pixeltest_tiles.cc
index 8f21cb8f..b35cac8f 100644
--- a/cc/trees/layer_tree_host_pixeltest_tiles.cc
+++ b/cc/trees/layer_tree_host_pixeltest_tiles.cc
@@ -12,7 +12,7 @@
 #include "cc/test/layer_tree_pixel_test.h"
 #include "components/viz/common/frame_sinks/copy_output_request.h"
 #include "components/viz/test/test_layer_tree_frame_sink.h"
-#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/client/raster_interface.h"
 
 #if !defined(OS_ANDROID)
 
@@ -183,7 +183,7 @@
       return;
 
     viz::ContextProvider::ScopedContextLock lock(context_provider);
-    lock.ContextGL()->Finish();
+    lock.RasterContext()->Finish();
   }
 
  protected:
diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
index 2b8eba9..2139ddf 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -38,6 +38,7 @@
 #include "components/viz/common/resources/single_release_callback.h"
 #include "components/viz/test/test_layer_tree_frame_sink.h"
 #include "gpu/GLES2/gl2extchromium.h"
+#include "gpu/command_buffer/client/raster_interface.h"
 #include "media/base/media.h"
 
 using media::VideoFrame;
@@ -1629,8 +1630,8 @@
     did_lose_context = true;
     viz::ContextProvider::ScopedContextLock scoped_context(
         host_impl->layer_tree_frame_sink()->worker_context_provider());
-    gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
-    gl->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
+    gpu::raster::RasterInterface* ri = scoped_context.RasterContext();
+    ri->LoseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
                             GL_INNOCENT_CONTEXT_RESET_ARB);
   }