chromium/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h"

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <optional>
#include <ostream>  // IWYU pragma: keep (https://github.com/clangd/clangd/issues/2053)
#include <string>  // IWYU pragma: keep (for String::Utf8())
#include <type_traits>
#include <utility>
#include <vector>

#include "base/check.h"
#include "base/check_deref.h"
#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/location.h"
#include "base/memory/raw_ref.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "cc/paint/paint_canvas.h"
#include "cc/paint/paint_flags.h"
#include "cc/paint/paint_image.h"
#include "cc/paint/record_paint_canvas.h"
#include "cc/paint/refcounted_buffer.h"
#include "gpu/command_buffer/common/sync_token.h"
#include "media/base/video_frame.h"
#include "media/base/video_frame_metadata.h"
#include "media/base/video_transformation.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/metrics/document_update_reason.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom-blink.h"
#include "third_party/blink/public/mojom/frame/color_scheme.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_object_objectarray_string.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_begin_layer_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_canvas_2d_gpu_transfer_option.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_canvas_font_stretch.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_canvas_text_rendering.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_texture_format.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_canvasfilter_string.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_value.h"
#include "third_party/blink/renderer/core/css/css_value_list.h"
#include "third_party/blink/renderer/core/css/parser/css_parser.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_mode.h"
#include "third_party/blink/renderer/core/css/properties/computed_style_utils.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder_converter.h"
#include "third_party/blink/renderer/core/css/style_color.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/text_link_colors.h"
#include "third_party/blink/renderer/core/event_type_names.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/execution_context/security_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/geometry/dom_matrix.h"
#include "third_party/blink/renderer/core/geometry/dom_matrix_read_only.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_context_creation_attributes_core.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_font_cache.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_image_source.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_performance_monitor.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context_host.h"
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/core/html/canvas/image_data.h"
#include "third_party/blink/renderer/core/html/canvas/text_metrics.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/paint/filter_effect_builder.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/filter_operations.h"
#include "third_party/blink/renderer/core/typed_arrays/array_buffer_view_helpers.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/cached_color.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_filter.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_gradient.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_image_source_util.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_path.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_pattern.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_state.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_style.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/identifiability_study_helper.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/mesh_2d_index_buffer.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/mesh_2d_uv_buffer.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/mesh_2d_vertex_buffer.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/path_2d.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/v8_canvas_style.h"
#include "third_party/blink/renderer/modules/webcodecs/video_frame.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/dawn_enum_conversions.h"
#include "third_party/blink/renderer/modules/webgpu/gpu.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_texture.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/fonts/font.h"
#include "third_party/blink/renderer/platform/fonts/font_description.h"
#include "third_party/blink/renderer/platform/fonts/font_selection_types.h"
#include "third_party/blink/renderer/platform/fonts/text_run_paint_info.h"
#include "third_party/blink/renderer/platform/graphics/bitmap_image.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h"
#include "third_party/blink/renderer/platform/graphics/color.h"
#include "third_party/blink/renderer/platform/graphics/filters/paint_filter_builder.h"
#include "third_party/blink/renderer/platform/graphics/gpu/dawn_control_client_holder.h"
#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_cpp.h"
#include "third_party/blink/renderer/platform/graphics/gpu/webgpu_mailbox_texture.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/graphics_types.h"
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/graphics/image_data_buffer.h"
#include "third_party/blink/renderer/platform/graphics/image_orientation.h"
#include "third_party/blink/renderer/platform/graphics/interpolation_space.h"
#include "third_party/blink/renderer/platform/graphics/memory_managed_paint_canvas.h"  // IWYU pragma: keep (https://github.com/clangd/clangd/issues/2044)
#include "third_party/blink/renderer/platform/graphics/memory_managed_paint_recorder.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_filter.h"
#include "third_party/blink/renderer/platform/graphics/path.h"
#include "third_party/blink/renderer/platform/graphics/pattern.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/stroke_data.h"
#include "third_party/blink/renderer/platform/graphics/video_frame_image_util.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/privacy_budget/identifiability_digest_helpers.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/text/text_run.h"
#include "third_party/blink/renderer/platform/text/unicode_bidi.h"
#include "third_party/blink/renderer/platform/timer.h"
#include "third_party/blink/renderer/platform/transforms/affine_transform.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_view.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "third_party/blink/renderer/platform/wtf/wtf_size_t.h"
#include "third_party/perfetto/include/perfetto/tracing/event_context.h"
#include "third_party/perfetto/include/perfetto/tracing/track_event_args.h"
#include "third_party/skia/include/core/SkAlphaType.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkBlendMode.h"
#include "third_party/skia/include/core/SkClipOp.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkM44.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkPathTypes.h"
#include "third_party/skia/include/core/SkPixmap.h"
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkSamplingOptions.h"
#include "third_party/skia/include/core/SkScalar.h"
#include "third_party/skia/include/private/base/SkTo.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/quad_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "v8/include/v8-local-handle.h"

// Including "base/time/time.h" triggers a bug in IWYU.
// https://github.com/include-what-you-use/include-what-you-use/issues/1122
// IWYU pragma: no_include "base/numerics/clamped_math.h"

// UMA Histogram macros trigger a bug in IWYU.
// https://github.com/include-what-you-use/include-what-you-use/issues/1546
// IWYU pragma: no_include <atomic>
// IWYU pragma: no_include <string_view>
// IWYU pragma: no_include "base/metrics/histogram_base.h"

// `base::HashingLRUCache` uses a std::list internally and a bug in IWYU leaks
// that implementation detail.
// https://github.com/include-what-you-use/include-what-you-use/issues/1539
// IWYU pragma: no_include <list>

enum SkColorType : int;

namespace gpu {
struct Mailbox;
}  // namespace gpu

namespace v8 {
class Isolate;
class Value;
}  // namespace v8

namespace blink {

class DOMMatrixInit;
class FontSelector;
class ImageDataSettings;
class ScriptState;
class SimpleFontData;

UsePaintCache;

BASE_FEATURE();

// Maximum number of colors in the color cache
// (`BaseRenderingContext2D::color_cache_`).
constexpr size_t kColorCacheMaxSize =;

const char BaseRenderingContext2D::kDefaultFont[] =;
const char BaseRenderingContext2D::kInheritDirectionString[] =;
const char BaseRenderingContext2D::kRtlDirectionString[] =;
const char BaseRenderingContext2D::kLtrDirectionString[] =;
const char BaseRenderingContext2D::kAutoKerningString[] =;
const char BaseRenderingContext2D::kNormalKerningString[] =;
const char BaseRenderingContext2D::kNoneKerningString[] =;
const char BaseRenderingContext2D::kUltraCondensedString[] =;
const char BaseRenderingContext2D::kExtraCondensedString[] =;
const char BaseRenderingContext2D::kCondensedString[] =;
const char BaseRenderingContext2D::kSemiCondensedString[] =;
const char BaseRenderingContext2D::kNormalStretchString[] =;
const char BaseRenderingContext2D::kSemiExpandedString[] =;
const char BaseRenderingContext2D::kExpandedString[] =;
const char BaseRenderingContext2D::kExtraExpandedString[] =;
const char BaseRenderingContext2D::kUltraExpandedString[] =;
const char BaseRenderingContext2D::kNormalVariantString[] =;
const char BaseRenderingContext2D::kSmallCapsVariantString[] =;
const char BaseRenderingContext2D::kAllSmallCapsVariantString[] =;
const char BaseRenderingContext2D::kPetiteVariantString[] =;
const char BaseRenderingContext2D::kAllPetiteVariantString[] =;
const char BaseRenderingContext2D::kUnicaseVariantString[] =;
const char BaseRenderingContext2D::kTitlingCapsVariantString[] =;

// Dummy overdraw test for ops that do not support overdraw detection
const auto kNoOverdraw =;

// After context lost, it waits |kTryRestoreContextInterval| before start the
// restore the context. This wait needs to be long enough to avoid spamming the
// GPU process with retry attempts and short enough to provide decent UX. It's
// currently set to 500ms.
const base::TimeDelta kTryRestoreContextInterval =;

BaseRenderingContext2D::BaseRenderingContext2D(
    scoped_refptr<base::SingleThreadTaskRunner> task_runner)
    :{}

BaseRenderingContext2D::~BaseRenderingContext2D() {}

void BaseRenderingContext2D::save() {}

void BaseRenderingContext2D::restore(ExceptionState& exception_state) {}

void BaseRenderingContext2D::beginLayerImpl(ScriptState* script_state,
                                            const BeginLayerOptions* options,
                                            ExceptionState* exception_state) {}

void BaseRenderingContext2D::AddLayerFilterUserCount(
    const V8CanvasFilterInput* filter_input) {}

class ScopedResetCtm {};

namespace {
sk_sp<PaintFilter> CombineFilters(sk_sp<PaintFilter> first,
                                  sk_sp<PaintFilter> second) {}
}  // namespace

CanvasRenderingContext2DState::SaveType
BaseRenderingContext2D::SaveLayerForState(
    const CanvasRenderingContext2DState& state,
    sk_sp<PaintFilter> layer_filter,
    cc::PaintCanvas& canvas) {}

void BaseRenderingContext2D::endLayer(ExceptionState& exception_state) {}

void BaseRenderingContext2D::PopAndRestore(cc::PaintCanvas& canvas) {}

void BaseRenderingContext2D::ValidateStateStackImpl(
    const cc::PaintCanvas* canvas) const {}

void BaseRenderingContext2D::RestoreMatrixClipStack(cc::PaintCanvas* c) const {}

void BaseRenderingContext2D::ResetInternal() {}

void BaseRenderingContext2D::reset() {}

void BaseRenderingContext2D::IdentifiabilityUpdateForStyleUnion(
    const V8CanvasStyle& style) {}

RespectImageOrientationEnum
BaseRenderingContext2D::RespectImageOrientationInternal(
    CanvasImageSource* image_source) {}

v8::Local<v8::Value> BaseRenderingContext2D::strokeStyle(
    ScriptState* script_state) const {}

void BaseRenderingContext2D::
    UpdateIdentifiabilityStudyBeforeSettingStrokeOrFill(
        const V8CanvasStyle& v8_style,
        CanvasOps op) {}

void BaseRenderingContext2D::
    UpdateIdentifiabilityStudyBeforeSettingStrokeOrFill(
        v8::Local<v8::String> v8_string,
        CanvasOps op) {}

bool BaseRenderingContext2D::ExtractColorFromV8StringAndUpdateCache(
    v8::Isolate* isolate,
    v8::Local<v8::String> v8_string,
    ExceptionState& exception_state,
    Color& color) {}

void BaseRenderingContext2D::setStrokeStyle(v8::Isolate* isolate,
                                            v8::Local<v8::Value> value,
                                            ExceptionState& exception_state) {}

ColorParseResult BaseRenderingContext2D::ParseColorOrCurrentColor(
    const String& color_string,
    Color& color) const {}

const ui::ColorProvider* BaseRenderingContext2D::GetColorProvider() const {}

bool BaseRenderingContext2D::IsInWebAppScope() const {}

v8::Local<v8::Value> BaseRenderingContext2D::fillStyle(
    ScriptState* script_state) const {}

void BaseRenderingContext2D::setFillStyle(v8::Isolate* isolate,
                                          v8::Local<v8::Value> value,
                                          ExceptionState& exception_state) {}

double BaseRenderingContext2D::lineWidth() const {}

void BaseRenderingContext2D::setLineWidth(double width) {}

String BaseRenderingContext2D::lineCap() const {}

void BaseRenderingContext2D::setLineCap(const String& s) {}

String BaseRenderingContext2D::lineJoin() const {}

void BaseRenderingContext2D::setLineJoin(const String& s) {}

double BaseRenderingContext2D::miterLimit() const {}

void BaseRenderingContext2D::setMiterLimit(double limit) {}

double BaseRenderingContext2D::shadowOffsetX() const {}

void BaseRenderingContext2D::setShadowOffsetX(double x) {}

double BaseRenderingContext2D::shadowOffsetY() const {}

void BaseRenderingContext2D::setShadowOffsetY(double y) {}

double BaseRenderingContext2D::shadowBlur() const {}

void BaseRenderingContext2D::setShadowBlur(double blur) {}

String BaseRenderingContext2D::shadowColor() const {}

void BaseRenderingContext2D::setShadowColor(const String& color_string) {}

const Vector<double>& BaseRenderingContext2D::getLineDash() const {}

static bool LineDashSequenceIsValid(const Vector<double>& dash) {}

void BaseRenderingContext2D::setLineDash(const Vector<double>& dash) {}

double BaseRenderingContext2D::lineDashOffset() const {}

void BaseRenderingContext2D::setLineDashOffset(double offset) {}

double BaseRenderingContext2D::globalAlpha() const {}

void BaseRenderingContext2D::setGlobalAlpha(double alpha) {}

String BaseRenderingContext2D::globalCompositeOperation() const {}

void BaseRenderingContext2D::setGlobalCompositeOperation(
    const String& operation) {}

const V8UnionCanvasFilterOrString* BaseRenderingContext2D::filter() const {}

void BaseRenderingContext2D::setFilter(
    ScriptState* script_state,
    const V8UnionCanvasFilterOrString* input) {}

void BaseRenderingContext2D::scale(double sx, double sy) {}

void BaseRenderingContext2D::rotate(double angle_in_radians) {}

void BaseRenderingContext2D::translate(double tx, double ty) {}

void BaseRenderingContext2D::transform(double m11,
                                       double m12,
                                       double m21,
                                       double m22,
                                       double dx,
                                       double dy) {}

void BaseRenderingContext2D::resetTransform() {}

void BaseRenderingContext2D::setTransform(double m11,
                                          double m12,
                                          double m21,
                                          double m22,
                                          double dx,
                                          double dy) {}

void BaseRenderingContext2D::setTransform(DOMMatrixInit* transform,
                                          ExceptionState& exception_state) {}

DOMMatrix* BaseRenderingContext2D::getTransform() {}

AffineTransform BaseRenderingContext2D::GetTransform() const {}

void BaseRenderingContext2D::beginPath() {}

void BaseRenderingContext2D::DrawPathInternal(
    const CanvasPath& path,
    CanvasRenderingContext2DState::PaintType paint_type,
    SkPathFillType fill_type,
    UsePaintCache use_paint_cache) {}

static SkPathFillType ParseWinding(const String& winding_rule_string) {}

void BaseRenderingContext2D::fill() {}

void BaseRenderingContext2D::fill(const String& winding) {}

void BaseRenderingContext2D::FillImpl(SkPathFillType winding_rule) {}

void BaseRenderingContext2D::fill(Path2D* dom_path) {}

void BaseRenderingContext2D::fill(Path2D* dom_path, const String& winding) {}

void BaseRenderingContext2D::FillPathImpl(Path2D* dom_path,
                                          SkPathFillType winding_rule) {}

void BaseRenderingContext2D::stroke() {}

void BaseRenderingContext2D::stroke(Path2D* dom_path) {}

void BaseRenderingContext2D::fillRect(double x,
                                      double y,
                                      double width,
                                      double height) {}

static void StrokeRectOnCanvas(const gfx::RectF& rect,
                               cc::PaintCanvas* canvas,
                               const cc::PaintFlags* flags) {}

void BaseRenderingContext2D::strokeRect(double x,
                                        double y,
                                        double width,
                                        double height) {}

void BaseRenderingContext2D::ClipInternal(const Path& path,
                                          const String& winding_rule_string,
                                          UsePaintCache use_paint_cache) {}

void BaseRenderingContext2D::clip(const String& winding_rule_string) {}

void BaseRenderingContext2D::clip(Path2D* dom_path,
                                  const String& winding_rule_string) {}

bool BaseRenderingContext2D::isPointInPath(const double x,
                                           const double y,
                                           const String& winding_rule_string) {}

bool BaseRenderingContext2D::isPointInPath(Path2D* dom_path,
                                           const double x,
                                           const double y,
                                           const String& winding_rule_string) {}

bool BaseRenderingContext2D::IsPointInPathInternal(
    const Path& path,
    const double x,
    const double y,
    const String& winding_rule_string) {}

bool BaseRenderingContext2D::isPointInStroke(const double x, const double y) {}

bool BaseRenderingContext2D::isPointInStroke(Path2D* dom_path,
                                             const double x,
                                             const double y) {}

bool BaseRenderingContext2D::IsPointInStrokeInternal(const Path& path,
                                                     const double x,
                                                     const double y) {}

cc::PaintFlags BaseRenderingContext2D::GetClearFlags() const {}

void BaseRenderingContext2D::clearRect(double x,
                                       double y,
                                       double width,
                                       double height) {}

static inline void ClipRectsToImageRect(const gfx::RectF& image_rect,
                                        gfx::RectF* src_rect,
                                        gfx::RectF* dst_rect) {}

void BaseRenderingContext2D::drawImage(const V8CanvasImageSource* image_source,
                                       double x,
                                       double y,
                                       ExceptionState& exception_state) {}

void BaseRenderingContext2D::drawImage(const V8CanvasImageSource* image_source,
                                       double x,
                                       double y,
                                       double width,
                                       double height,
                                       ExceptionState& exception_state) {}

void BaseRenderingContext2D::drawImage(const V8CanvasImageSource* image_source,
                                       double sx,
                                       double sy,
                                       double sw,
                                       double sh,
                                       double dx,
                                       double dy,
                                       double dw,
                                       double dh,
                                       ExceptionState& exception_state) {}

bool BaseRenderingContext2D::ShouldDrawImageAntialiased(
    const gfx::RectF& dest_rect) const {}

void BaseRenderingContext2D::DispatchContextLostEvent(TimerBase*) {}

void BaseRenderingContext2D::DispatchContextRestoredEvent(TimerBase*) {}

void BaseRenderingContext2D::DrawImageInternal(
    cc::PaintCanvas* c,
    CanvasImageSource* image_source,
    Image* image,
    const gfx::RectF& src_rect,
    const gfx::RectF& dst_rect,
    const SkSamplingOptions& sampling,
    const cc::PaintFlags* flags) {}

void BaseRenderingContext2D::SetOriginTaintedByContent() {}

void BaseRenderingContext2D::drawImage(CanvasImageSource* image_source,
                                       double sx,
                                       double sy,
                                       double sw,
                                       double sh,
                                       double dx,
                                       double dy,
                                       double dw,
                                       double dh,
                                       ExceptionState& exception_state) {}

bool BaseRenderingContext2D::RectContainsTransformedRect(
    const gfx::RectF& rect,
    const SkIRect& transformed_rect) const {}

CanvasGradient* BaseRenderingContext2D::createLinearGradient(double x0,
                                                             double y0,
                                                             double x1,
                                                             double y1) {}

CanvasGradient* BaseRenderingContext2D::createRadialGradient(
    double x0,
    double y0,
    double r0,
    double x1,
    double y1,
    double r1,
    ExceptionState& exception_state) {}

CanvasGradient* BaseRenderingContext2D::createConicGradient(double startAngle,
                                                            double centerX,
                                                            double centerY) {}

CanvasPattern* BaseRenderingContext2D::createPattern(

    const V8CanvasImageSource* image_source,
    const String& repetition_type,
    ExceptionState& exception_state) {}

CanvasPattern* BaseRenderingContext2D::createPattern(
    CanvasImageSource* image_source,
    const String& repetition_type,
    ExceptionState& exception_state) {}

namespace {

scoped_refptr<cc::RefCountedBuffer<SkPoint>> MakeSkPointBuffer(
    NotShared<DOMFloat32Array> array,
    ExceptionState& exception_state,
    const char* msg) {}

}  // namespace

Mesh2DVertexBuffer* BaseRenderingContext2D::createMesh2DVertexBuffer(
    NotShared<DOMFloat32Array> array,
    ExceptionState& exception_state) {}

Mesh2DUVBuffer* BaseRenderingContext2D::createMesh2DUVBuffer(
    NotShared<DOMFloat32Array> array,
    ExceptionState& exception_state) {}

Mesh2DIndexBuffer* BaseRenderingContext2D::createMesh2DIndexBuffer(
    NotShared<DOMUint16Array> array,
    ExceptionState& exception_state) {}

void BaseRenderingContext2D::drawMesh(
    const Mesh2DVertexBuffer* vertex_buffer,
    const Mesh2DUVBuffer* uv_buffer,
    const Mesh2DIndexBuffer* index_buffer,
    const V8CanvasImageSource* v8_image_source,
    ExceptionState& exception_state) {}

bool BaseRenderingContext2D::ComputeDirtyRect(const gfx::RectF& local_rect,
                                              SkIRect* dirty_rect) {}

ImageData* BaseRenderingContext2D::createImageData(
    ImageData* image_data,
    ExceptionState& exception_state) const {}

ImageData* BaseRenderingContext2D::createImageData(
    int sw,
    int sh,
    ExceptionState& exception_state) const {}

ImageData* BaseRenderingContext2D::createImageData(
    int sw,
    int sh,
    ImageDataSettings* image_data_settings,
    ExceptionState& exception_state) const {}

ImageData* BaseRenderingContext2D::getImageData(
    int sx,
    int sy,
    int sw,
    int sh,
    ExceptionState& exception_state) {}

ImageData* BaseRenderingContext2D::getImageData(
    int sx,
    int sy,
    int sw,
    int sh,
    ImageDataSettings* image_data_settings,
    ExceptionState& exception_state) {}
perfetto::EventContext GetEventContext();

ImageData* BaseRenderingContext2D::getImageDataInternal(
    int sx,
    int sy,
    int sw,
    int sh,
    ImageDataSettings* image_data_settings,
    ExceptionState& exception_state) {}

void BaseRenderingContext2D::putImageData(ImageData* data,
                                          int dx,
                                          int dy,
                                          ExceptionState& exception_state) {}

void BaseRenderingContext2D::putImageData(ImageData* data,
                                          int dx,
                                          int dy,
                                          int dirty_x,
                                          int dirty_y,
                                          int dirty_width,
                                          int dirty_height,
                                          ExceptionState& exception_state) {}

void BaseRenderingContext2D::PutByteArray(const SkPixmap& source,
                                          const gfx::Rect& source_rect,
                                          const gfx::Vector2d& dest_offset) {}

void BaseRenderingContext2D::InflateStrokeRect(gfx::RectF& rect) const {}

bool BaseRenderingContext2D::imageSmoothingEnabled() const {}

void BaseRenderingContext2D::setImageSmoothingEnabled(bool enabled) {}

String BaseRenderingContext2D::imageSmoothingQuality() const {}

void BaseRenderingContext2D::setImageSmoothingQuality(const String& quality) {}

String BaseRenderingContext2D::letterSpacing() const {}

String BaseRenderingContext2D::wordSpacing() const {}

String BaseRenderingContext2D::textRendering() const {}

float BaseRenderingContext2D::GetFontBaseline(
    const SimpleFontData& font_data) const {}

String BaseRenderingContext2D::textAlign() const {}

void BaseRenderingContext2D::setTextAlign(const String& s) {}

String BaseRenderingContext2D::textBaseline() const {}

void BaseRenderingContext2D::setTextBaseline(const String& s) {}

String BaseRenderingContext2D::fontKerning() const {}

String BaseRenderingContext2D::fontStretch() const {}

String BaseRenderingContext2D::fontVariantCaps() const {}

void BaseRenderingContext2D::Trace(Visitor* visitor) const {}

BaseRenderingContext2D::UsageCounters::UsageCounters()
    :{}

namespace {

void CanvasOverdrawHistogram(BaseRenderingContext2D::OverdrawOp op) {}

}  // unnamed namespace

void BaseRenderingContext2D::WillOverwriteCanvas(
    BaseRenderingContext2D::OverdrawOp op) {}

void BaseRenderingContext2D::WillUseCurrentFont() const {}

String BaseRenderingContext2D::font() const {}

bool BaseRenderingContext2D::WillSetFont() const {}

bool BaseRenderingContext2D::CurrentFontResolvedAndUpToDate() const {}

void BaseRenderingContext2D::setFont(const String& new_font) {}

static inline TextDirection ToTextDirection(
    CanvasRenderingContext2DState::Direction direction,
    HTMLCanvasElement* canvas,
    const ComputedStyle** computed_style = nullptr) {}

HTMLCanvasElement* BaseRenderingContext2D::HostAsHTMLCanvasElement() const {}

OffscreenCanvas* BaseRenderingContext2D::HostAsOffscreenCanvas() const {}

String BaseRenderingContext2D::direction() const {}

void BaseRenderingContext2D::setDirection(const String& direction_string) {}

void BaseRenderingContext2D::fillText(const String& text, double x, double y) {}

void BaseRenderingContext2D::fillText(const String& text,
                                      double x,
                                      double y,
                                      double max_width) {}

void BaseRenderingContext2D::strokeText(const String& text,
                                        double x,
                                        double y) {}

void BaseRenderingContext2D::strokeText(const String& text,
                                        double x,
                                        double y,
                                        double max_width) {}

const Font& BaseRenderingContext2D::AccessFont(HTMLCanvasElement* canvas) {}

void BaseRenderingContext2D::DrawTextInternal(
    const String& text,
    double x,
    double y,
    CanvasRenderingContext2DState::PaintType paint_type,
    double* max_width) {}

TextMetrics* BaseRenderingContext2D::measureText(const String& text) {}

void BaseRenderingContext2D::SnapshotStateForFilter() {}

void BaseRenderingContext2D::setLetterSpacing(const String& letter_spacing) {}

void BaseRenderingContext2D::setWordSpacing(const String& word_spacing) {}

void BaseRenderingContext2D::setTextRendering(
    const String& text_rendering_string) {}

void BaseRenderingContext2D::setFontKerning(const String& font_kerning_string) {}

void BaseRenderingContext2D::setFontStretch(const String& font_stretch) {}

void BaseRenderingContext2D::setFontVariantCaps(
    const String& font_variant_caps_string) {}

FontSelector* BaseRenderingContext2D::GetFontSelector() const {}

bool BaseRenderingContext2D::IsAccelerated() const {}

V8GPUTextureFormat BaseRenderingContext2D::getTextureFormat() const {}

GPUTexture* BaseRenderingContext2D::transferToGPUTexture(
    const Canvas2dGPUTransferOption* access_options,
    ExceptionState& exception_state) {}

bool BaseRenderingContext2D::CopyGPUTextureToResourceProvider(
    GPUTexture& texture,
    CanvasResourceProvider& resource_provider) {}

void BaseRenderingContext2D::transferBackFromGPUTexture(
    ExceptionState& exception_state) {}

}  // namespace blink