Skip to content

Commit

Permalink
Add Begin/EndSharedImageAccessDirectCHROMIUM to RasterInterface
Browse files Browse the repository at this point in the history
As part of the OOPR-Canvas2D project we need to fill a few holes in the
raster API to make the transition to fully relying on RasterInterface.
This CL adds Begin/EndSharedImageAccessDirectCHROMIUM to
RasterInterface. RasterImplementationGLES calls the underlying
GLContext while RasterImplementation doesn't implement the API.

Bug: 1023266
Change-Id: Ie0e9baec2b826b10699b9596af9ba4fb9841c20a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1927316
Reviewed-by: Khushal <khushalsagar@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Commit-Queue: Nathan Zabriskie <nazabris@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#717469}
  • Loading branch information
NathanZabriskie authored and Commit Bot committed Nov 21, 2019
1 parent 7f5b4e2 commit 513f870
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
9 changes: 9 additions & 0 deletions gpu/command_buffer/client/raster_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,15 @@ void RasterImplementation::EndGpuRaster() {
NOTREACHED();
}

void RasterImplementation::BeginSharedImageAccessDirectCHROMIUM(GLuint texture,
GLenum mode) {
NOTREACHED();
}

void RasterImplementation::EndSharedImageAccessDirectCHROMIUM(GLuint texture) {
NOTREACHED();
}

void RasterImplementation::TraceBeginCHROMIUM(const char* category_name,
const char* trace_name) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
Expand Down
3 changes: 3 additions & 0 deletions gpu/command_buffer/client/raster_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class RASTER_EXPORT RasterImplementation : public RasterInterface,
void DeleteGpuRasterTexture(GLuint texture) override;
void BeginGpuRaster() override;
void EndGpuRaster() override;
void BeginSharedImageAccessDirectCHROMIUM(GLuint texture,
GLenum mode) override;
void EndSharedImageAccessDirectCHROMIUM(GLuint texture) override;

// ContextSupport implementation.
void SetAggressivelyFreeResources(bool aggressively_free_resources) override;
Expand Down
11 changes: 11 additions & 0 deletions gpu/command_buffer/client/raster_implementation_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ void RasterImplementationGLES::EndGpuRaster() {
gl_->ActiveTexture(GL_TEXTURE0);
}

void RasterImplementationGLES::BeginSharedImageAccessDirectCHROMIUM(
GLuint texture,
GLenum mode) {
gl_->BeginSharedImageAccessDirectCHROMIUM(texture, mode);
}

void RasterImplementationGLES::EndSharedImageAccessDirectCHROMIUM(
GLuint texture) {
gl_->EndSharedImageAccessDirectCHROMIUM(texture);
}

void RasterImplementationGLES::TraceBeginCHROMIUM(const char* category_name,
const char* trace_name) {
gl_->TraceBeginCHROMIUM(category_name, trace_name);
Expand Down
3 changes: 3 additions & 0 deletions gpu/command_buffer/client/raster_implementation_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class RASTER_EXPORT RasterImplementationGLES : public RasterInterface {
void DeleteGpuRasterTexture(GLuint texture) override;
void BeginGpuRaster() override;
void EndGpuRaster() override;
void BeginSharedImageAccessDirectCHROMIUM(GLuint texture,
GLenum mode) override;
void EndSharedImageAccessDirectCHROMIUM(GLuint texture) override;

void TraceBeginCHROMIUM(const char* category_name,
const char* trace_name) override;
Expand Down
3 changes: 3 additions & 0 deletions gpu/command_buffer/client/raster_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ class RasterInterface : public InterfaceBase {
virtual void DeleteGpuRasterTexture(GLuint texture) = 0;
virtual void BeginGpuRaster() = 0;
virtual void EndGpuRaster() = 0;
virtual void BeginSharedImageAccessDirectCHROMIUM(GLuint texture,
GLenum mode) = 0;
virtual void EndSharedImageAccessDirectCHROMIUM(GLuint texture) = 0;

// Include the auto-generated part of this class. We split this because
// it means we can easily edit the non-auto generated parts right here in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,15 @@ class CanvasResourceProviderSharedImage : public CanvasResourceProvider {
if (surface_) {
// Take read access to the outgoing resource for the skia copy below.
if (!old_resource_shared_image->has_read_access()) {
ContextGL()->BeginSharedImageAccessDirectCHROMIUM(
RasterInterface()->BeginSharedImageAccessDirectCHROMIUM(
old_resource_shared_image->GetTextureIdForReadAccess(),
GL_SHARED_IMAGE_ACCESS_MODE_READ_CHROMIUM);
}
surface_->replaceBackendTexture(CreateGrTextureForResource(),
GetGrSurfaceOrigin());
surface_->flush();
if (!old_resource_shared_image->has_read_access()) {
ContextGL()->EndSharedImageAccessDirectCHROMIUM(
RasterInterface()->EndSharedImageAccessDirectCHROMIUM(
old_resource_shared_image->GetTextureIdForReadAccess());
}
}
Expand Down Expand Up @@ -394,7 +394,7 @@ class CanvasResourceProviderSharedImage : public CanvasResourceProvider {

if (is_accelerated_) {
auto texture_id = resource()->GetTextureIdForWriteAccess();
ContextGL()->BeginSharedImageAccessDirectCHROMIUM(
RasterInterface()->BeginSharedImageAccessDirectCHROMIUM(
texture_id, GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM);
}

Expand All @@ -414,7 +414,7 @@ class CanvasResourceProviderSharedImage : public CanvasResourceProvider {
// Issue any skia work using this resource before releasing write access.
FlushGrContext();
auto texture_id = resource()->GetTextureIdForWriteAccess();
ContextGL()->EndSharedImageAccessDirectCHROMIUM(texture_id);
RasterInterface()->EndSharedImageAccessDirectCHROMIUM(texture_id);
} else {
if (DoCopyOnWrite())
resource_ = NewOrRecycledResource();
Expand Down

0 comments on commit 513f870

Please sign in to comment.