#include "ui/views/painter.h"
#include <utility>
#include "base/check.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/layer_owner.h"
#include "ui/compositor/paint_recorder.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/insets_f.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/rounded_corners_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/nine_image_painter.h"
#include "ui/gfx/scoped_canvas.h"
#include "ui/views/view.h"
namespace views {
namespace {
class SolidRoundRectPainter : public Painter { … };
SolidRoundRectPainter::SolidRoundRectPainter(SkColor bg_color,
SkColor stroke_color,
gfx::RoundedCornersF radii,
const gfx::Insets& insets,
SkBlendMode blend_mode,
bool antialias,
bool should_border_scale)
: … { … }
SolidRoundRectPainter::~SolidRoundRectPainter() = default;
gfx::Size SolidRoundRectPainter::GetMinimumSize() const { … }
void SolidRoundRectPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { … }
class SolidFocusPainter : public Painter { … };
SolidFocusPainter::SolidFocusPainter(SkColor color,
int thickness,
const gfx::InsetsF& insets)
: … { … }
SolidFocusPainter::~SolidFocusPainter() = default;
gfx::Size SolidFocusPainter::GetMinimumSize() const { … }
void SolidFocusPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { … }
class ImagePainter : public Painter { … };
ImagePainter::ImagePainter(const int image_ids[])
: … { … }
ImagePainter::ImagePainter(const gfx::ImageSkia& image,
const gfx::Insets& insets)
: … { … }
ImagePainter::~ImagePainter() = default;
gfx::Size ImagePainter::GetMinimumSize() const { … }
void ImagePainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { … }
class PaintedLayer : public ui::LayerOwner, public ui::LayerDelegate { … };
PaintedLayer::PaintedLayer(std::unique_ptr<Painter> painter)
: … { … }
PaintedLayer::~PaintedLayer() = default;
void PaintedLayer::OnPaintLayer(const ui::PaintContext& context) { … }
void PaintedLayer::OnDeviceScaleFactorChanged(float old_device_scale_factor,
float new_device_scale_factor) { … }
}
Painter::Painter() = default;
Painter::~Painter() = default;
void Painter::PaintPainterAt(gfx::Canvas* canvas,
Painter* painter,
const gfx::Rect& rect) { … }
void Painter::PaintFocusPainter(View* view,
gfx::Canvas* canvas,
Painter* focus_painter) { … }
std::unique_ptr<Painter> Painter::CreateSolidRoundRectPainter(
SkColor color,
float radius,
const gfx::Insets& insets,
SkBlendMode blend_mode,
bool antialias) { … }
std::unique_ptr<Painter> Painter::CreateSolidRoundRectPainterWithVariableRadius(
SkColor color,
gfx::RoundedCornersF radii,
const gfx::Insets& insets,
SkBlendMode blend_mode,
bool antialias) { … }
std::unique_ptr<Painter> Painter::CreateRoundRectWith1PxBorderPainter(
SkColor bg_color,
SkColor stroke_color,
float radius,
SkBlendMode blend_mode,
bool antialias,
bool should_border_scale) { … }
std::unique_ptr<Painter> Painter::CreateImagePainter(
const gfx::ImageSkia& image,
const gfx::Insets& insets) { … }
std::unique_ptr<Painter> Painter::CreateImageGridPainter(
const int image_ids[]) { … }
std::unique_ptr<Painter> Painter::CreateSolidFocusPainter(
SkColor color,
const gfx::Insets& insets) { … }
std::unique_ptr<Painter> Painter::CreateSolidFocusPainter(
SkColor color,
int thickness,
const gfx::InsetsF& insets) { … }
std::unique_ptr<ui::LayerOwner> Painter::CreatePaintedLayer(
std::unique_ptr<Painter> painter) { … }
}