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 @@
#include "content/renderer/pepper/ppb_image_data_impl.h"
#include "content/renderer/render_thread_impl.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/gpu_memory_buffer_support.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
......@@ -585,7 +585,7 @@ void PepperGraphics2DHost::ReleaseSoftwareCallback(
// static
void PepperGraphics2DHost::ReleaseTextureCallback(
base::WeakPtr<PepperGraphics2DHost> host,
scoped_refptr<viz::ContextProvider> context,
scoped_refptr<viz::RasterContextProvider> context,
const gfx::Size& size,
const gpu::Mailbox& mailbox,
const gpu::SyncToken& sync_token,
......@@ -608,7 +608,7 @@ bool PepperGraphics2DHost::PrepareTransferableResource(
// reuse the shared images, they are invalid. If the compositing mode changed,
// the context will be lost also, so we get both together.
if (!main_thread_context_ ||
main_thread_context_->ContextGL()->GetGraphicsResetStatusKHR() !=
main_thread_context_->RasterInterface()->GetGraphicsResetStatusKHR() !=
GL_NO_ERROR) {
recycled_shared_images_.clear();
main_thread_context_ = nullptr;
......@@ -639,7 +639,7 @@ bool PepperGraphics2DHost::PrepareTransferableResource(
// When gpu compositing, the compositor expects gpu resources, so we copy the
// |image_data_| into a texture.
if (main_thread_context_) {
auto* gl = main_thread_context_->ContextGL();
auto* ri = main_thread_context_->RasterInterface();
auto* sii = main_thread_context_->SharedImageInterface();
// The bitmap in |image_data_| uses the skia N32 byte order.
......@@ -700,19 +700,15 @@ bool PepperGraphics2DHost::PrepareTransferableResource(
src = swizzled.get();
}
gl->WaitSyncTokenCHROMIUM(in_sync_token.GetConstData());
GLuint texture_id =
gl->CreateAndTexStorage2DSharedImageCHROMIUM(gpu_mailbox.name);
gl->BeginSharedImageAccessDirectCHROMIUM(
texture_id, GL_SHARED_IMAGE_ACCESS_MODE_READWRITE_CHROMIUM);
gl->BindTexture(texture_target, texture_id);
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);
SkImageInfo src_info =
SkImageInfo::Make(size.width(), size.height(),
viz::ResourceFormatToClosestSkColorType(true, format),
kUnknown_SkAlphaType);
ri->WaitSyncTokenCHROMIUM(in_sync_token.GetConstData());
ri->WritePixels(gpu_mailbox, 0, 0, texture_target, src_info, src);
gpu::SyncToken out_sync_token;
gl->GenUnverifiedSyncTokenCHROMIUM(out_sync_token.GetData());
ri->GenUnverifiedSyncTokenCHROMIUM(out_sync_token.GetData());
image_data_->Unmap();
swizzled.reset();
......
......@@ -33,7 +33,7 @@ class Rect;
}
namespace viz {
class ContextProvider;
class RasterContextProvider;
class SingleReleaseCallback;
struct TransferableResource;
}
......@@ -185,7 +185,7 @@ class CONTENT_EXPORT PepperGraphics2DHost
// has been destroyed.
static void ReleaseTextureCallback(
base::WeakPtr<PepperGraphics2DHost> host,
scoped_refptr<viz::ContextProvider> context,
scoped_refptr<viz::RasterContextProvider> context,
const gfx::Size& size,
const gpu::Mailbox& mailbox,
const gpu::SyncToken& sync_token,
......@@ -234,7 +234,7 @@ class CONTENT_EXPORT PepperGraphics2DHost
bool is_gpu_compositing_disabled_ = false;
// The shared main thread context provider, used to upload 2d pepper frames
// if the compositor is expecting gpu content.
scoped_refptr<viz::ContextProvider> main_thread_context_;
scoped_refptr<viz::RasterContextProvider> main_thread_context_;
struct SharedImageInfo {
SharedImageInfo(gpu::SyncToken sync_token,
gpu::Mailbox mailbox,
......
......@@ -1072,6 +1072,15 @@ void RasterImplementation::CopySubTexture(const gpu::Mailbox& source_mailbox,
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(
GLuint sk_color,
GLuint msaa_sample_count,
......
......@@ -122,6 +122,13 @@ class RASTER_EXPORT RasterImplementation : public RasterInterface,
GLboolean unpack_flip_y,
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,
GLuint msaa_sample_count,
GLboolean can_use_lcd_text,
......
......@@ -31,6 +31,35 @@
namespace gpu {
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(
gles2::GLES2Interface* gl,
ContextSupport* context_support)
......@@ -134,6 +163,27 @@ void RasterImplementationGLES::CopySubTexture(
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(
GLuint sk_color,
GLuint msaa_sample_count,
......
......@@ -69,6 +69,13 @@ class RASTER_EXPORT RasterImplementationGLES : public RasterInterface {
GLboolean unpack_flip_y,
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
void BeginRasterCHROMIUM(GLuint sk_color,
GLuint msaa_sample_count,
......
......@@ -12,6 +12,8 @@
#include "gpu/command_buffer/client/interface_base.h"
#include "gpu/command_buffer/common/sync_token.h"
struct SkImageInfo;
namespace cc {
class DisplayItemList;
class ImageProvider;
......@@ -53,6 +55,14 @@ class RasterInterface : public InterfaceBase {
GLsizei height,
GLboolean unpack_flip_y,
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
virtual void BeginRasterCHROMIUM(GLuint sk_color,
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