#include "ui/gfx/canvas.h"
#include <cmath>
#include <limits>
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "cc/paint/paint_flags.h"
#include "cc/paint/paint_shader.h"
#include "cc/paint/skottie_wrapper.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/insets_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/gfx/skia_paint_util.h"
#include "ui/gfx/switches.h"
namespace gfx {
Canvas::Canvas(const Size& size, float image_scale, bool is_opaque)
: … { … }
Canvas::Canvas()
: … { … }
Canvas::Canvas(cc::PaintCanvas* canvas, float image_scale)
: … { … }
Canvas::~Canvas() { … }
void Canvas::RecreateBackingCanvas(const Size& size,
float image_scale,
bool is_opaque) { … }
void Canvas::SizeStringInt(const std::u16string& text,
const FontList& font_list,
int* width,
int* height,
int line_height,
int flags) { … }
int Canvas::GetStringWidth(const std::u16string& text,
const FontList& font_list) { … }
float Canvas::GetStringWidthF(const std::u16string& text,
const FontList& font_list) { … }
int Canvas::DefaultCanvasTextAlignment() { … }
float Canvas::UndoDeviceScaleFactor() { … }
void Canvas::Save() { … }
void Canvas::SaveLayerAlpha(uint8_t alpha) { … }
void Canvas::SaveLayerAlpha(uint8_t alpha, const Rect& layer_bounds) { … }
void Canvas::SaveLayerWithFlags(const cc::PaintFlags& flags) { … }
void Canvas::Restore() { … }
void Canvas::ClipRect(const Rect& rect, SkClipOp op) { … }
void Canvas::ClipRect(const RectF& rect, SkClipOp op) { … }
void Canvas::ClipPath(const SkPath& path, bool do_anti_alias) { … }
bool Canvas::GetClipBounds(Rect* bounds) { … }
void Canvas::Translate(const Vector2d& offset) { … }
void Canvas::Scale(float x_scale, float y_scale) { … }
void Canvas::DrawColor(SkColor color) { … }
void Canvas::DrawColor(SkColor color, SkBlendMode mode) { … }
void Canvas::FillRect(const Rect& rect, SkColor color) { … }
void Canvas::FillRect(const Rect& rect, SkColor color, SkBlendMode mode) { … }
void Canvas::DrawRect(const RectF& rect, SkColor color) { … }
void Canvas::DrawRect(const RectF& rect, SkColor color, SkBlendMode mode) { … }
void Canvas::DrawRect(const Rect& rect, const cc::PaintFlags& flags) { … }
void Canvas::DrawRect(const RectF& rect, const cc::PaintFlags& flags) { … }
void Canvas::DrawLine(const Point& p1, const Point& p2, SkColor color) { … }
void Canvas::DrawLine(const PointF& p1, const PointF& p2, SkColor color) { … }
void Canvas::DrawLine(const Point& p1,
const Point& p2,
const cc::PaintFlags& flags) { … }
void Canvas::DrawLine(const PointF& p1,
const PointF& p2,
const cc::PaintFlags& flags) { … }
void Canvas::DrawSharpLine(PointF p1, PointF p2, SkColor color) { … }
void Canvas::Draw1pxLine(PointF p1, PointF p2, SkColor color) { … }
void Canvas::DrawCircle(const Point& center_point,
int radius,
const cc::PaintFlags& flags) { … }
void Canvas::DrawCircle(const PointF& center_point,
float radius,
const cc::PaintFlags& flags) { … }
void Canvas::DrawRoundRect(const Rect& rect,
int radius,
const cc::PaintFlags& flags) { … }
void Canvas::DrawRoundRect(const RectF& rect,
float radius,
const cc::PaintFlags& flags) { … }
void Canvas::DrawPath(const SkPath& path, const cc::PaintFlags& flags) { … }
void Canvas::DrawSolidFocusRect(RectF rect, SkColor color, int thickness) { … }
void Canvas::DrawImageInt(const ImageSkia& image, int x, int y) { … }
void Canvas::DrawImageInt(const ImageSkia& image, int x, int y, uint8_t a) { … }
void Canvas::DrawImageInt(const ImageSkia& image,
int x,
int y,
const cc::PaintFlags& flags) { … }
void Canvas::DrawImageInt(const ImageSkia& image,
int src_x,
int src_y,
int src_w,
int src_h,
int dest_x,
int dest_y,
int dest_w,
int dest_h,
bool filter) { … }
void Canvas::DrawImageInt(const ImageSkia& image,
int src_x,
int src_y,
int src_w,
int src_h,
int dest_x,
int dest_y,
int dest_w,
int dest_h,
bool filter,
const cc::PaintFlags& flags) { … }
void Canvas::DrawImageIntInPixel(const ImageSkiaRep& image_rep,
int dest_x,
int dest_y,
int dest_w,
int dest_h,
bool filter,
const cc::PaintFlags& flags) { … }
void Canvas::DrawImageInPath(const ImageSkia& image,
int x,
int y,
const SkPath& path,
const cc::PaintFlags& original_flags) { … }
void Canvas::DrawSkottie(scoped_refptr<cc::SkottieWrapper> skottie,
const Rect& dst,
float t,
cc::SkottieFrameDataMap images,
const cc::SkottieColorMap& color_map,
cc::SkottieTextPropertyValueMap text_map) { … }
void Canvas::DrawStringRect(const std::u16string& text,
const FontList& font_list,
SkColor color,
const Rect& display_rect) { … }
void Canvas::TileImageInt(const ImageSkia& image,
int x,
int y,
int w,
int h) { … }
void Canvas::TileImageInt(const ImageSkia& image,
int src_x,
int src_y,
int dest_x,
int dest_y,
int w,
int h,
float tile_scale,
SkTileMode tile_mode_x,
SkTileMode tile_mode_y,
cc::PaintFlags* flags) { … }
bool Canvas::InitPaintFlagsForTiling(const ImageSkia& image,
int src_x,
int src_y,
float tile_scale_x,
float tile_scale_y,
int dest_x,
int dest_y,
SkTileMode tile_mode_x,
SkTileMode tile_mode_y,
cc::PaintFlags* flags) { … }
void Canvas::Transform(const gfx::Transform& transform) { … }
SkBitmap Canvas::GetBitmap() const { … }
bool Canvas::IntersectsClipRect(const SkRect& rect) { … }
void Canvas::DrawImageIntHelper(const ImageSkiaRep& image_rep,
int src_x,
int src_y,
int src_w,
int src_h,
int dest_x,
int dest_y,
int dest_w,
int dest_h,
bool filter,
const cc::PaintFlags& original_flags,
bool remove_image_scale) { … }
cc::PaintCanvas* Canvas::CreateOwnedCanvas(const Size& size, bool is_opaque) { … }
}