#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "gpu/command_buffer/client/raster_implementation_gles.h"
#include <algorithm>
#include <cstddef>
#include <limits>
#include <set>
#include <utility>
#include <vector>
#include "base/logging.h"
#include "cc/paint/decode_stashing_image_provider.h"
#include "cc/paint/display_item_list.h"
#include "cc/paint/paint_op_buffer_serializer.h"
#include "cc/paint/transfer_cache_entry.h"
#include "cc/paint/transfer_cache_serialize_helper.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/client_shared_image.h"
#include "gpu/command_buffer/client/gl_helper.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "gpu/command_buffer/common/capabilities.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "ui/gfx/geometry/rect_conversions.h"
namespace gpu {
namespace raster {
namespace {
BASE_FEATURE(…);
GLenum SkColorTypeToGLDataFormat(SkColorType color_type, bool supports_rg) { … }
GLenum SkColorTypeToGLDataType(SkColorType color_type) { … }
}
RasterImplementationGLES::RasterImplementationGLES(
gles2::GLES2Interface* gl,
ContextSupport* context_support,
const gpu::Capabilities& caps)
: … { … }
RasterImplementationGLES::~RasterImplementationGLES() = default;
void RasterImplementationGLES::Finish() { … }
void RasterImplementationGLES::Flush() { … }
void RasterImplementationGLES::ShallowFlushCHROMIUM() { … }
void RasterImplementationGLES::OrderingBarrierCHROMIUM() { … }
GLenum RasterImplementationGLES::GetError() { … }
GLenum RasterImplementationGLES::GetGraphicsResetStatusKHR() { … }
void RasterImplementationGLES::LoseContextCHROMIUM(GLenum current,
GLenum other) { … }
void RasterImplementationGLES::GenQueriesEXT(GLsizei n, GLuint* queries) { … }
void RasterImplementationGLES::DeleteQueriesEXT(GLsizei n,
const GLuint* queries) { … }
void RasterImplementationGLES::BeginQueryEXT(GLenum target, GLuint id) { … }
void RasterImplementationGLES::EndQueryEXT(GLenum target) { … }
void RasterImplementationGLES::QueryCounterEXT(GLuint id, GLenum target) { … }
void RasterImplementationGLES::GetQueryObjectuivEXT(GLuint id,
GLenum pname,
GLuint* params) { … }
void RasterImplementationGLES::GetQueryObjectui64vEXT(GLuint id,
GLenum pname,
GLuint64* params) { … }
void RasterImplementationGLES::CopySharedImage(
const gpu::Mailbox& source_mailbox,
const gpu::Mailbox& dest_mailbox,
GLenum dest_target,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLboolean unpack_flip_y,
GLboolean unpack_premultiply_alpha) { … }
void RasterImplementationGLES::WritePixels(const gpu::Mailbox& dest_mailbox,
int dst_x_offset,
int dst_y_offset,
GLenum texture_target,
const SkPixmap& src_sk_pixmap) { … }
void RasterImplementationGLES::WritePixelsYUV(
const gpu::Mailbox& dest_mailbox,
const SkYUVAPixmaps& src_yuv_pixmap) { … }
void RasterImplementationGLES::ConvertYUVAMailboxesToRGB(
const gpu::Mailbox& dest_mailbox,
GLint src_x,
GLint src_y,
GLsizei width,
GLsizei height,
SkYUVColorSpace planes_yuv_color_space,
const SkColorSpace* planes_rgb_color_space,
SkYUVAInfo::PlaneConfig plane_config,
SkYUVAInfo::Subsampling subsampling,
const gpu::Mailbox yuva_plane_mailboxes[]) { … }
void RasterImplementationGLES::ConvertRGBAToYUVAMailboxes(
SkYUVColorSpace planes_yuv_color_space,
SkYUVAInfo::PlaneConfig plane_config,
SkYUVAInfo::Subsampling subsampling,
const gpu::Mailbox yuva_plane_mailboxes[],
const gpu::Mailbox& source_mailbox) { … }
void RasterImplementationGLES::BeginRasterCHROMIUM(
SkColor4f sk_color_4f,
GLboolean needs_clear,
GLuint msaa_sample_count,
MsaaMode msaa_mode,
GLboolean can_use_lcd_text,
GLboolean visible,
const gfx::ColorSpace& color_space,
float hdr_headroom,
const GLbyte* mailbox) { … }
void RasterImplementationGLES::RasterCHROMIUM(
const cc::DisplayItemList* list,
cc::ImageProvider* provider,
const gfx::Size& content_size,
const gfx::Rect& full_raster_rect,
const gfx::Rect& playback_rect,
const gfx::Vector2dF& post_translate,
const gfx::Vector2dF& post_scale,
bool requires_clear,
const ScrollOffsetMap* raster_inducing_scroll_offsets,
size_t* max_op_size_hint) { … }
void RasterImplementationGLES::SetActiveURLCHROMIUM(const char* url) { … }
void RasterImplementationGLES::EndRasterCHROMIUM() { … }
SyncToken RasterImplementationGLES::ScheduleImageDecode(
base::span<const uint8_t> encoded_data,
const gfx::Size& output_size,
uint32_t transfer_cache_entry_id,
const gfx::ColorSpace& target_color_space,
bool needs_mips) { … }
void RasterImplementationGLES::ReadbackARGBPixelsAsync(
const gpu::Mailbox& source_mailbox,
GLenum source_target,
GrSurfaceOrigin src_origin,
const gfx::Size& source_size,
const gfx::Point& source_starting_point,
const SkImageInfo& dst_info,
GLuint dst_row_bytes,
unsigned char* out,
base::OnceCallback<void(bool)> readback_done) { … }
void RasterImplementationGLES::OnReadARGBPixelsAsync(
GLuint texture_id,
base::OnceCallback<void(bool)> readback_done,
bool success) { … }
void RasterImplementationGLES::ReadbackYUVPixelsAsync(
const gpu::Mailbox& source_mailbox,
GLenum source_target,
const gfx::Size& source_size,
const gfx::Rect& output_rect,
bool vertically_flip_texture,
int y_plane_row_stride_bytes,
unsigned char* y_plane_data,
int u_plane_row_stride_bytes,
unsigned char* u_plane_data,
int v_plane_row_stride_bytes,
unsigned char* v_plane_data,
const gfx::Point& paste_location,
base::OnceCallback<void()> release_mailbox,
base::OnceCallback<void(bool)> readback_done) { … }
void RasterImplementationGLES::OnReadYUVPixelsAsync(
GLuint copy_texture_id,
base::OnceCallback<void()> on_release_mailbox,
base::OnceCallback<void(bool)> readback_done,
bool success) { … }
void RasterImplementationGLES::OnReleaseMailbox(
GLuint shared_texture_id,
base::OnceCallback<void()> release_mailbox) { … }
bool RasterImplementationGLES::ReadbackImagePixels(
const gpu::Mailbox& source_mailbox,
const SkImageInfo& dst_info,
GLuint dst_row_bytes,
int src_x,
int src_y,
int plane_index,
void* dst_pixels) { … }
GLuint RasterImplementationGLES::CreateAndConsumeForGpuRaster(
const gpu::Mailbox& mailbox) { … }
GLuint RasterImplementationGLES::CreateAndConsumeForGpuRaster(
const scoped_refptr<gpu::ClientSharedImage>& shared_image) { … }
void RasterImplementationGLES::DeleteGpuRasterTexture(GLuint texture) { … }
void RasterImplementationGLES::BeginGpuRaster() { … }
void RasterImplementationGLES::EndGpuRaster() { … }
void RasterImplementationGLES::BeginSharedImageAccessDirectCHROMIUM(
GLuint texture,
GLenum mode) { … }
void RasterImplementationGLES::EndSharedImageAccessDirectCHROMIUM(
GLuint texture) { … }
void RasterImplementationGLES::InitializeDiscardableTextureCHROMIUM(
GLuint texture) { … }
void RasterImplementationGLES::UnlockDiscardableTextureCHROMIUM(
GLuint texture) { … }
bool RasterImplementationGLES::LockDiscardableTextureCHROMIUM(GLuint texture) { … }
void RasterImplementationGLES::TraceBeginCHROMIUM(const char* category_name,
const char* trace_name) { … }
void RasterImplementationGLES::TraceEndCHROMIUM() { … }
void RasterImplementationGLES::GenSyncTokenCHROMIUM(GLbyte* sync_token) { … }
void RasterImplementationGLES::GenUnverifiedSyncTokenCHROMIUM(
GLbyte* sync_token) { … }
void RasterImplementationGLES::VerifySyncTokensCHROMIUM(GLbyte** sync_tokens,
GLsizei count) { … }
void RasterImplementationGLES::WaitSyncTokenCHROMIUM(const GLbyte* sync_token) { … }
GLHelper* RasterImplementationGLES::GetGLHelper() { … }
}
}