#include "third_party/blink/renderer/core/offscreencanvas/offscreen_canvas.h"
#include <memory>
#include <utility>
#include "base/metrics/histogram_functions.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_metric_builder.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_metrics.h"
#include "third_party/blink/public/common/privacy_budget/identifiability_study_settings.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/scheduler/web_agent_group_scheduler.h"
#include "third_party/blink/renderer/core/css/css_font_selector.h"
#include "third_party/blink/renderer/core/css/offscreen_font_selector.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_async_blob_creator.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_context_creation_attributes_core.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context_factory.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_resource_tracker.h"
#include "third_party/blink/renderer/core/html/canvas/image_data.h"
#include "third_party/blink/renderer/core/html/canvas/ukm_parameters.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/workers/dedicated_worker_global_scope.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource_dispatcher.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/image.h"
#include "third_party/blink/renderer/platform/graphics/skia/skia_utils.h"
#include "third_party/blink/renderer/platform/graphics/static_bitmap_image.h"
#include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h"
#include "third_party/blink/renderer/platform/heap/thread_state.h"
#include "third_party/blink/renderer/platform/image-encoders/image_encoder_utils.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/skia/include/core/SkSurface.h"
namespace blink {
OffscreenCanvas::OffscreenCanvas(ExecutionContext* context, gfx::Size size)
: … { … }
OffscreenCanvas* OffscreenCanvas::Create(ScriptState* script_state,
unsigned width,
unsigned height) { … }
OffscreenCanvas::~OffscreenCanvas() { … }
void OffscreenCanvas::Commit(scoped_refptr<CanvasResource>&& canvas_resource,
const SkIRect& damage_rect) { … }
void OffscreenCanvas::Dispose() { … }
void OffscreenCanvas::DeregisterFromAnimationFrameProvider() { … }
void OffscreenCanvas::SetPlaceholderCanvasId(DOMNodeId canvas_id) { … }
void OffscreenCanvas::setWidth(unsigned width) { … }
void OffscreenCanvas::setHeight(unsigned height) { … }
void OffscreenCanvas::SetSize(gfx::Size size) { … }
void OffscreenCanvas::RecordTransfer() { … }
void OffscreenCanvas::SetNeutered() { … }
ImageBitmap* OffscreenCanvas::transferToImageBitmap(
ScriptState* script_state,
ExceptionState& exception_state) { … }
void OffscreenCanvas::RecordIdentifiabilityMetric(
const blink::IdentifiableSurface& surface,
const IdentifiableToken& token) const { … }
scoped_refptr<Image> OffscreenCanvas::GetSourceImageForCanvas(
FlushReason reason,
SourceImageStatus* status,
const gfx::SizeF& size,
const AlphaDisposition alpha_disposition) { … }
gfx::Size OffscreenCanvas::BitmapSourceSize() const { … }
ScriptPromise<ImageBitmap> OffscreenCanvas::CreateImageBitmap(
ScriptState* script_state,
std::optional<gfx::Rect> crop_rect,
const ImageBitmapOptions* options,
ExceptionState& exception_state) { … }
ScriptPromise<Blob> OffscreenCanvas::convertToBlob(
ScriptState* script_state,
const ImageEncodeOptions* options,
ExceptionState& exception_state) { … }
bool OffscreenCanvas::IsOpaque() const { … }
CanvasRenderingContext* OffscreenCanvas::GetCanvasRenderingContext(
ExecutionContext* execution_context,
const String& id,
const CanvasContextCreationAttributesCore& attributes) { … }
OffscreenCanvas::ContextFactoryVector&
OffscreenCanvas::RenderingContextFactories() { … }
CanvasRenderingContextFactory* OffscreenCanvas::GetRenderingContextFactory(
int type) { … }
void OffscreenCanvas::RegisterRenderingContextFactory(
std::unique_ptr<CanvasRenderingContextFactory> rendering_context_factory) { … }
bool OffscreenCanvas::OriginClean() const { … }
bool OffscreenCanvas::IsAccelerated() const { … }
bool OffscreenCanvas::EnableAcceleration() { … }
bool OffscreenCanvas::HasPlaceholderCanvas() const { … }
CanvasResourceDispatcher* OffscreenCanvas::GetOrCreateResourceDispatcher() { … }
CanvasResourceProvider* OffscreenCanvas::GetOrCreateResourceProvider() { … }
void OffscreenCanvas::DidDraw(const SkIRect& rect) { … }
bool OffscreenCanvas::BeginFrame() { … }
void OffscreenCanvas::SetFilterQualityInResource(
cc::PaintFlags::FilterQuality filter_quality) { … }
bool OffscreenCanvas::PushFrameIfNeeded() { … }
bool OffscreenCanvas::PushFrame(scoped_refptr<CanvasResource>&& canvas_resource,
const SkIRect& damage_rect) { … }
bool OffscreenCanvas::ShouldAccelerate2dContext() const { … }
UkmParameters OffscreenCanvas::GetUkmParameters() { … }
void OffscreenCanvas::NotifyGpuContextLost() { … }
void OffscreenCanvas::CheckForGpuContextLost() { … }
FontSelector* OffscreenCanvas::GetFontSelector() { … }
void OffscreenCanvas::UpdateMemoryUsage() { … }
size_t OffscreenCanvas::GetMemoryUsage() const { … }
void OffscreenCanvas::Trace(Visitor* visitor) const { … }
}