Commit 94852edc authored by Nathan Zabriskie's avatar Nathan Zabriskie Committed by Commit Bot

Remove ContextGL from PepperGraphics2dHost

Remove another instance of ContextGL from the shared main thread
context in preparation for OOPR Canvas. Also a semi-step toward
supporting texture upload on RasterInterface. Since
RasterImplementationGLES just wraps glTexSubImage2D I anticipate that
the WritePixels interface will look different for the
RasterImplementation version as it won't rely on texture_target.

Bug: 1063725, 1018898
Change-Id: I5ae922b5496690e4b6135e98fa0bcb76c144d7f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2119635Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Reviewed-by: default avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Nathan Zabriskie <nazabris@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#753408}
parent cf7321c8
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "content/renderer/pepper/ppb_image_data_impl.h" #include "content/renderer/pepper/ppb_image_data_impl.h"
#include "content/renderer/render_thread_impl.h" #include "content/renderer/render_thread_impl.h"
#include "gpu/GLES2/gl2extchromium.h" #include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h" #include "gpu/command_buffer/client/raster_interface.h"
#include "gpu/command_buffer/common/capabilities.h" #include "gpu/command_buffer/common/capabilities.h"
#include "gpu/command_buffer/common/gpu_memory_buffer_support.h" #include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "gpu/command_buffer/common/shared_image_usage.h" #include "gpu/command_buffer/common/shared_image_usage.h"
...@@ -585,7 +585,7 @@ void PepperGraphics2DHost::ReleaseSoftwareCallback( ...@@ -585,7 +585,7 @@ void PepperGraphics2DHost::ReleaseSoftwareCallback(
// static // static
void PepperGraphics2DHost::ReleaseTextureCallback( void PepperGraphics2DHost::ReleaseTextureCallback(
base::WeakPtr<PepperGraphics2DHost> host, base::WeakPtr<PepperGraphics2DHost> host,
scoped_refptr<viz::ContextProvider> context, scoped_refptr<viz::RasterContextProvider> context,
const gfx::Size& size, const gfx::Size& size,
const gpu::Mailbox& mailbox, const gpu::Mailbox& mailbox,
const gpu::SyncToken& sync_token, const gpu::SyncToken& sync_token,
...@@ -608,7 +608,7 @@ bool PepperGraphics2DHost::PrepareTransferableResource( ...@@ -608,7 +608,7 @@ bool PepperGraphics2DHost::PrepareTransferableResource(
// reuse the shared images, they are invalid. If the compositing mode changed, // reuse the shared images, they are invalid. If the compositing mode changed,
// the context will be lost also, so we get both together. // the context will be lost also, so we get both together.
if (!main_thread_context_ || if (!main_thread_context_ ||
main_thread_context_->ContextGL()->GetGraphicsResetStatusKHR() != main_thread_context_->RasterInterface()->GetGraphicsResetStatusKHR() !=
GL_NO_ERROR) { GL_NO_ERROR) {
recycled_shared_images_.clear(); recycled_shared_images_.clear();
main_thread_context_ = nullptr; main_thread_context_ = nullptr;
...@@ -639,7 +639,7 @@ bool PepperGraphics2DHost::PrepareTransferableResource( ...@@ -639,7 +639,7 @@ bool PepperGraphics2DHost::PrepareTransferableResource(
// When gpu compositing, the compositor expects gpu resources, so we copy the // When gpu compositing, the compositor expects gpu resources, so we copy the
// |image_data_| into a texture. // |image_data_| into a texture.
if (main_thread_context_) { if (main_thread_context_) {
auto* gl = main_thread_context_->ContextGL(); auto* ri = main_thread_context_->RasterInterface();
auto* sii = main_thread_context_->SharedImageInterface(); auto* sii = main_thread_context_->SharedImageInterface();
// The bitmap in |image_data_| uses the skia N32 byte order. // The bitmap in |image_data_| uses the skia N32 byte order.
...@@ -700,19 +700,15 @@ bool PepperGraphics2DHost::PrepareTransferableResource( ...@@ -700,19 +700,15 @@ bool PepperGraphics2DHost::PrepareTransferableResource(
src = swizzled.get(); src = swizzled.get();
} }
gl->WaitSyncTokenCHROMIUM(in_sync_token.GetConstData()); SkImageInfo src_info =
GLuint texture_id = SkImageInfo::Make(size.width(), size.height(),
gl->CreateAndTexStorage2DSharedImageCHROMIUM(gpu_mailbox.name); viz::ResourceFormatToClosestSkColorType(true, format),
gl->BeginSharedImageAccessDirectCHROMIUM( kUnknown_SkAlphaType);
texture_id, GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM); ri->WaitSyncTokenCHROMIUM(in_sync_token.GetConstData());
gl->BindTexture(texture_target, texture_id); ri->WritePixels(gpu_mailbox, 0, 0, texture_target, src_info, src);
gl->TexSubImage2D(texture_target, 0, 0, 0, size.width(), size.height(),
viz::GLDataFormat(format), viz::GLDataType(format), src);
gl->BindTexture(texture_target, 0);
gl->EndSharedImageAccessDirectCHROMIUM(texture_id);
gl->DeleteTextures(1, &texture_id);
gpu::SyncToken out_sync_token; gpu::SyncToken out_sync_token;
gl->GenUnverifiedSyncTokenCHROMIUM(out_sync_token.GetData()); ri->GenUnverifiedSyncTokenCHROMIUM(out_sync_token.GetData());
image_data_->Unmap(); image_data_->Unmap();
swizzled.reset(); swizzled.reset();
......
...@@ -33,7 +33,7 @@ class Rect; ...@@ -33,7 +33,7 @@ class Rect;
} }
namespace viz { namespace viz {
class ContextProvider; class RasterContextProvider;
class SingleReleaseCallback; class SingleReleaseCallback;
struct TransferableResource; struct TransferableResource;
} }
...@@ -185,7 +185,7 @@ class CONTENT_EXPORT PepperGraphics2DHost ...@@ -185,7 +185,7 @@ class CONTENT_EXPORT PepperGraphics2DHost
// has been destroyed. // has been destroyed.
static void ReleaseTextureCallback( static void ReleaseTextureCallback(
base::WeakPtr<PepperGraphics2DHost> host, base::WeakPtr<PepperGraphics2DHost> host,
scoped_refptr<viz::ContextProvider> context, scoped_refptr<viz::RasterContextProvider> context,
const gfx::Size& size, const gfx::Size& size,
const gpu::Mailbox& mailbox, const gpu::Mailbox& mailbox,
const gpu::SyncToken& sync_token, const gpu::SyncToken& sync_token,
...@@ -234,7 +234,7 @@ class CONTENT_EXPORT PepperGraphics2DHost ...@@ -234,7 +234,7 @@ class CONTENT_EXPORT PepperGraphics2DHost
bool is_gpu_compositing_disabled_ = false; bool is_gpu_compositing_disabled_ = false;
// The shared main thread context provider, used to upload 2d pepper frames // The shared main thread context provider, used to upload 2d pepper frames
// if the compositor is expecting gpu content. // if the compositor is expecting gpu content.
scoped_refptr<viz::ContextProvider> main_thread_context_; scoped_refptr<viz::RasterContextProvider> main_thread_context_;
struct SharedImageInfo { struct SharedImageInfo {
SharedImageInfo(gpu::SyncToken sync_token, SharedImageInfo(gpu::SyncToken sync_token,
gpu::Mailbox mailbox, gpu::Mailbox mailbox,
......
...@@ -1072,6 +1072,15 @@ void RasterImplementation::CopySubTexture(const gpu::Mailbox& source_mailbox, ...@@ -1072,6 +1072,15 @@ void RasterImplementation::CopySubTexture(const gpu::Mailbox& source_mailbox,
CheckGLError(); CheckGLError();
} }
void RasterImplementation::WritePixels(const gpu::Mailbox& dest_mailbox,
int dst_x_offset,
int dst_y_offset,
GLenum texture_target,
const SkImageInfo& src_info,
const void* src_pixels) {
NOTREACHED();
}
void RasterImplementation::BeginRasterCHROMIUM( void RasterImplementation::BeginRasterCHROMIUM(
GLuint sk_color, GLuint sk_color,
GLuint msaa_sample_count, GLuint msaa_sample_count,
......
...@@ -122,6 +122,13 @@ class RASTER_EXPORT RasterImplementation : public RasterInterface, ...@@ -122,6 +122,13 @@ class RASTER_EXPORT RasterImplementation : public RasterInterface,
GLboolean unpack_flip_y, GLboolean unpack_flip_y,
GLboolean unpack_premultiply_alpha) override; GLboolean unpack_premultiply_alpha) override;
void WritePixels(const gpu::Mailbox& dest_mailbox,
int dst_x_offset,
int dst_y_offset,
GLenum texture_target,
const SkImageInfo& src_info,
const void* src_pixels) override;
void BeginRasterCHROMIUM(GLuint sk_color, void BeginRasterCHROMIUM(GLuint sk_color,
GLuint msaa_sample_count, GLuint msaa_sample_count,
GLboolean can_use_lcd_text, GLboolean can_use_lcd_text,
......
...@@ -31,6 +31,35 @@ ...@@ -31,6 +31,35 @@
namespace gpu { namespace gpu {
namespace raster { namespace raster {
namespace {
GLenum SkColorTypeToGLDataFormat(SkColorType color_type) {
switch (color_type) {
case kRGBA_8888_SkColorType:
return GL_RGBA;
case kBGRA_8888_SkColorType:
return GL_BGRA_EXT;
default:
DLOG(ERROR) << "Unknown SkColorType " << color_type;
}
NOTREACHED();
return 0;
}
GLenum SkColorTypeToGLDataType(SkColorType color_type) {
switch (color_type) {
case kRGBA_8888_SkColorType:
case kBGRA_8888_SkColorType:
return GL_UNSIGNED_BYTE;
default:
DLOG(ERROR) << "Unknown SkColorType " << color_type;
}
NOTREACHED();
return 0;
}
} // namespace
RasterImplementationGLES::RasterImplementationGLES( RasterImplementationGLES::RasterImplementationGLES(
gles2::GLES2Interface* gl, gles2::GLES2Interface* gl,
ContextSupport* context_support) ContextSupport* context_support)
...@@ -134,6 +163,27 @@ void RasterImplementationGLES::CopySubTexture( ...@@ -134,6 +163,27 @@ void RasterImplementationGLES::CopySubTexture(
gl_->DeleteTextures(2, texture_ids); gl_->DeleteTextures(2, texture_ids);
} }
void RasterImplementationGLES::WritePixels(const gpu::Mailbox& dest_mailbox,
int dst_x_offset,
int dst_y_offset,
GLenum texture_target,
const SkImageInfo& src_info,
const void* src_pixels) {
GLuint texture_id = CreateAndConsumeForGpuRaster(dest_mailbox);
BeginSharedImageAccessDirectCHROMIUM(
texture_id, GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM);
gl_->BindTexture(texture_target, texture_id);
gl_->TexSubImage2D(texture_target, 0, dst_x_offset, dst_y_offset,
src_info.width(), src_info.height(),
SkColorTypeToGLDataFormat(src_info.colorType()),
SkColorTypeToGLDataType(src_info.colorType()), src_pixels);
gl_->BindTexture(texture_target, 0);
EndSharedImageAccessDirectCHROMIUM(texture_id);
DeleteGpuRasterTexture(texture_id);
}
void RasterImplementationGLES::BeginRasterCHROMIUM( void RasterImplementationGLES::BeginRasterCHROMIUM(
GLuint sk_color, GLuint sk_color,
GLuint msaa_sample_count, GLuint msaa_sample_count,
......
...@@ -69,6 +69,13 @@ class RASTER_EXPORT RasterImplementationGLES : public RasterInterface { ...@@ -69,6 +69,13 @@ class RASTER_EXPORT RasterImplementationGLES : public RasterInterface {
GLboolean unpack_flip_y, GLboolean unpack_flip_y,
GLboolean unpack_premultiply_alpha) override; GLboolean unpack_premultiply_alpha) override;
void WritePixels(const gpu::Mailbox& dest_mailbox,
int dst_x_offset,
int dst_y_offset,
GLenum texture_target,
const SkImageInfo& src_info,
const void* src_pixels) override;
// OOP-Raster // OOP-Raster
void BeginRasterCHROMIUM(GLuint sk_color, void BeginRasterCHROMIUM(GLuint sk_color,
GLuint msaa_sample_count, GLuint msaa_sample_count,
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "gpu/command_buffer/client/interface_base.h" #include "gpu/command_buffer/client/interface_base.h"
#include "gpu/command_buffer/common/sync_token.h" #include "gpu/command_buffer/common/sync_token.h"
struct SkImageInfo;
namespace cc { namespace cc {
class DisplayItemList; class DisplayItemList;
class ImageProvider; class ImageProvider;
...@@ -53,6 +55,14 @@ class RasterInterface : public InterfaceBase { ...@@ -53,6 +55,14 @@ class RasterInterface : public InterfaceBase {
GLsizei height, GLsizei height,
GLboolean unpack_flip_y, GLboolean unpack_flip_y,
GLboolean unpack_premultiply_alpha) = 0; GLboolean unpack_premultiply_alpha) = 0;
virtual void WritePixels(const gpu::Mailbox& dest_mailbox,
int dst_x_offset,
int dst_y_offset,
GLenum texture_target,
const SkImageInfo& src_info,
const void* src_pixels) = 0;
// OOP-Raster // OOP-Raster
virtual void BeginRasterCHROMIUM(GLuint sk_color, virtual void BeginRasterCHROMIUM(GLuint sk_color,
GLuint msaa_sample_count, GLuint msaa_sample_count,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment