#include "third_party/blink/renderer/platform/graphics/accelerated_static_bitmap_image.h"
#include <memory>
#include <utility>
#include "base/task/single_thread_task_runner.h"
#include "components/viz/common/resources/release_callback.h"
#include "components/viz/common/resources/shared_image_format_utils.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/client/shared_image_interface.h"
#include "gpu/command_buffer/common/capabilities.h"
#include "gpu/command_buffer/common/shared_image_usage.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_graphics_context_3d_provider.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h"
#include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/mailbox_ref.h"
#include "third_party/blink/renderer/platform/graphics/mailbox_texture_backing.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
#include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/skia/include/core/SkBlendMode.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkColorType.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkSamplingOptions.h"
#include "third_party/skia/include/gpu/GrBackendSurface.h"
#include "third_party/skia/include/gpu/GrDirectContext.h"
#include "third_party/skia/include/gpu/GrTypes.h"
#include "third_party/skia/include/gpu/ganesh/SkImageGanesh.h"
#include "third_party/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h"
#include "third_party/skia/include/gpu/gl/GrGLTypes.h"
namespace blink {
void AcceleratedStaticBitmapImage::ReleaseTexture(void* ctx) { … }
scoped_refptr<AcceleratedStaticBitmapImage>
AcceleratedStaticBitmapImage::CreateFromCanvasMailbox(
const gpu::Mailbox& mailbox,
const gpu::SyncToken& sync_token,
GLuint shared_image_texture_id,
const SkImageInfo& sk_image_info,
GLenum texture_target,
bool is_origin_top_left,
base::WeakPtr<WebGraphicsContext3DProviderWrapper> context_provider_wrapper,
base::PlatformThreadRef context_thread_ref,
scoped_refptr<base::SingleThreadTaskRunner> context_task_runner,
viz::ReleaseCallback release_callback,
bool supports_display_compositing,
bool is_overlay_candidate) { … }
scoped_refptr<AcceleratedStaticBitmapImage>
AcceleratedStaticBitmapImage::CreateFromCanvasSharedImage(
scoped_refptr<gpu::ClientSharedImage> shared_image,
const gpu::SyncToken& sync_token,
GLuint shared_image_texture_id,
const SkImageInfo& sk_image_info,
GLenum texture_target,
bool is_origin_top_left,
base::WeakPtr<WebGraphicsContext3DProviderWrapper> context_provider_wrapper,
base::PlatformThreadRef context_thread_ref,
scoped_refptr<base::SingleThreadTaskRunner> context_task_runner,
viz::ReleaseCallback release_callback,
bool supports_display_compositing,
bool is_overlay_candidate) { … }
scoped_refptr<AcceleratedStaticBitmapImage>
AcceleratedStaticBitmapImage::CreateFromExternalMailbox(
const gpu::MailboxHolder& mailbox_holder,
uint32_t usage,
const SkImageInfo& sk_image_info,
bool is_origin_top_left,
bool supports_display_compositing,
bool is_overlay_candidate,
base::OnceCallback<void(const gpu::SyncToken&)> external_callback) { … }
AcceleratedStaticBitmapImage::AcceleratedStaticBitmapImage(
const gpu::Mailbox& mailbox,
const gpu::SyncToken& sync_token,
GLuint shared_image_texture_id,
const SkImageInfo& sk_image_info,
GLenum texture_target,
bool is_origin_top_left,
bool supports_display_compositing,
bool is_overlay_candidate,
const ImageOrientation& orientation,
base::WeakPtr<WebGraphicsContext3DProviderWrapper> context_provider_wrapper,
base::PlatformThreadRef context_thread_ref,
scoped_refptr<base::SingleThreadTaskRunner> context_task_runner,
viz::ReleaseCallback release_callback)
: … { … }
AcceleratedStaticBitmapImage::AcceleratedStaticBitmapImage(
scoped_refptr<gpu::ClientSharedImage> shared_image,
const gpu::SyncToken& sync_token,
GLuint shared_image_texture_id,
const SkImageInfo& sk_image_info,
GLenum texture_target,
bool is_origin_top_left,
bool supports_display_compositing,
bool is_overlay_candidate,
const ImageOrientation& orientation,
base::WeakPtr<WebGraphicsContext3DProviderWrapper> context_provider_wrapper,
base::PlatformThreadRef context_thread_ref,
scoped_refptr<base::SingleThreadTaskRunner> context_task_runner,
viz::ReleaseCallback release_callback)
: … { … }
AcceleratedStaticBitmapImage::~AcceleratedStaticBitmapImage() { … }
SkImageInfo AcceleratedStaticBitmapImage::GetSkImageInfo() const { … }
scoped_refptr<StaticBitmapImage>
AcceleratedStaticBitmapImage::MakeUnaccelerated() { … }
bool AcceleratedStaticBitmapImage::CopyToTexture(
gpu::gles2::GLES2Interface* dest_gl,
GLenum dest_target,
GLuint dest_texture_id,
GLint dest_level,
bool unpack_premultiply_alpha,
bool unpack_flip_y,
const gfx::Point& dest_point,
const gfx::Rect& source_sub_rectangle) { … }
bool AcceleratedStaticBitmapImage::CopyToResourceProvider(
CanvasResourceProvider* resource_provider) { … }
bool AcceleratedStaticBitmapImage::CopyToResourceProvider(
CanvasResourceProvider* resource_provider,
const gfx::Rect& copy_rect) { … }
PaintImage AcceleratedStaticBitmapImage::PaintImageForCurrentFrame() { … }
void AcceleratedStaticBitmapImage::Draw(cc::PaintCanvas* canvas,
const cc::PaintFlags& flags,
const gfx::RectF& dst_rect,
const gfx::RectF& src_rect,
const ImageDrawOptions& draw_options) { … }
bool AcceleratedStaticBitmapImage::IsValid() const { … }
WebGraphicsContext3DProvider* AcceleratedStaticBitmapImage::ContextProvider()
const { … }
base::WeakPtr<WebGraphicsContext3DProviderWrapper>
AcceleratedStaticBitmapImage::ContextProviderWrapper() const { … }
void AcceleratedStaticBitmapImage::CreateImageFromMailboxIfNeeded() { … }
void AcceleratedStaticBitmapImage::InitializeTextureBacking(
GLuint shared_image_texture_id) { … }
void AcceleratedStaticBitmapImage::EnsureSyncTokenVerified() { … }
gpu::MailboxHolder AcceleratedStaticBitmapImage::GetMailboxHolder() const { … }
scoped_refptr<gpu::ClientSharedImage>
AcceleratedStaticBitmapImage::GetSharedImage() const { … }
void AcceleratedStaticBitmapImage::Transfer() { … }
bool AcceleratedStaticBitmapImage::CurrentFrameKnownToBeOpaque() { … }
scoped_refptr<StaticBitmapImage>
AcceleratedStaticBitmapImage::ConvertToColorSpace(
sk_sp<SkColorSpace> color_space,
SkColorType color_type) { … }
uint32_t AcceleratedStaticBitmapImage::GetUsage() const { … }
}