#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "cc/paint/paint_shader.h"
#include <algorithm>
#include <utility>
#include "base/atomic_sequence_num.h"
#include "base/notreached.h"
#include "base/numerics/checked_math.h"
#include "base/types/optional_util.h"
#include "cc/paint/image_provider.h"
#include "cc/paint/paint_image_builder.h"
#include "cc/paint/paint_op_writer.h"
#include "cc/paint/paint_record.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
namespace cc {
namespace {
base::AtomicSequenceNumber g_next_shader_id;
sk_sp<SkPicture> ToSkPicture(const PaintRecord& record,
const SkRect& bounds,
const gfx::SizeF* raster_scale,
ImageProvider* image_provider) { … }
bool CompareMatricesForTesting(const SkMatrix& a,
const SkMatrix& b,
bool ignore_scaling_differences) { … }
}
const PaintShader::RecordShaderId PaintShader::kInvalidRecordShaderId = …;
sk_sp<PaintShader> PaintShader::MakeEmpty() { … }
sk_sp<PaintShader> PaintShader::MakeColor(SkColor4f color) { … }
sk_sp<PaintShader> PaintShader::MakeLinearGradient(
const SkPoint points[],
const SkColor4f colors[],
const SkScalar pos[],
int count,
SkTileMode mode,
SkGradientShader::Interpolation interpolation,
uint32_t flags,
const SkMatrix* local_matrix,
SkColor4f fallback_color) { … }
sk_sp<PaintShader> PaintShader::MakeRadialGradient(
const SkPoint& center,
SkScalar radius,
const SkColor4f colors[],
const SkScalar pos[],
int count,
SkTileMode mode,
SkGradientShader::Interpolation interpolation,
uint32_t flags,
const SkMatrix* local_matrix,
SkColor4f fallback_color) { … }
sk_sp<PaintShader> PaintShader::MakeTwoPointConicalGradient(
const SkPoint& start,
SkScalar start_radius,
const SkPoint& end,
SkScalar end_radius,
const SkColor4f colors[],
const SkScalar pos[],
int count,
SkTileMode mode,
SkGradientShader::Interpolation interpolation,
uint32_t flags,
const SkMatrix* local_matrix,
SkColor4f fallback_color) { … }
sk_sp<PaintShader> PaintShader::MakeSweepGradient(
SkScalar cx,
SkScalar cy,
const SkColor4f colors[],
const SkScalar pos[],
int color_count,
SkTileMode mode,
SkScalar start_degrees,
SkScalar end_degrees,
SkGradientShader::Interpolation interpolation,
uint32_t flags,
const SkMatrix* local_matrix,
SkColor4f fallback_color) { … }
sk_sp<PaintShader> PaintShader::MakeImage(const PaintImage& image,
SkTileMode tx,
SkTileMode ty,
const SkMatrix* local_matrix,
const SkRect* tile_rect) { … }
sk_sp<PaintShader> PaintShader::MakePaintRecord(
PaintRecord record,
const SkRect& tile,
SkTileMode tx,
SkTileMode ty,
const SkMatrix* local_matrix,
ScalingBehavior scaling_behavior) { … }
size_t PaintShader::GetSerializedSize(const PaintShader* shader) { … }
PaintShader::PaintShader(Type type) : … { … }
PaintShader::~PaintShader() = default;
bool PaintShader::HasDiscardableImages(
gfx::ContentColorUsage* content_color_usage) const { … }
bool PaintShader::GetClampedRasterizationTileRect(const SkMatrix& ctm,
int max_texture_size,
SkRect* tile_rect) const { … }
sk_sp<PaintShader> PaintShader::CreateScaledPaintRecord(
const SkMatrix& ctm,
int max_texture_size,
gfx::SizeF* raster_scale) const { … }
sk_sp<PaintShader> PaintShader::CreatePaintWorkletRecord(
ImageProvider* image_provider) const { … }
sk_sp<PaintShader> PaintShader::CreateDecodedImage(
const SkMatrix& ctm,
PaintFlags::FilterQuality quality,
ImageProvider* image_provider,
uint32_t* transfer_cache_entry_id,
PaintFlags::FilterQuality* raster_quality,
bool* needs_mips,
gpu::Mailbox* mailbox) const { … }
sk_sp<SkShader> PaintShader::GetSkShader(
PaintFlags::FilterQuality quality) const { … }
void PaintShader::ResolveSkObjects(const gfx::SizeF* raster_scale,
ImageProvider* image_provider) { … }
void PaintShader::SetColorsAndPositions(const SkColor4f* colors,
const SkScalar* positions,
int count) { … }
void PaintShader::SetMatrixAndTiling(const SkMatrix* matrix,
SkTileMode tx,
SkTileMode ty) { … }
void PaintShader::SetFlagsAndFallback(uint32_t flags,
SkColor4f fallback_color) { … }
bool PaintShader::IsOpaque() const { … }
bool PaintShader::IsValid() const { … }
bool PaintShader::EqualsForTesting(const PaintShader& other) const { … }
}