0

Rename PaintOpType enum values to be consistent with PaintOp class names

For example, kDrawrect is renamed to kDrawRect to be consistent with
class DrawRectOp.

Also simplify PaintOpTypeToString, but with a side effect that the
strings are ended with "Op".

Change-Id: Ic3f955e1e2d8ad2d98342167626e89b3e3126cc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5034472
Reviewed-by: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: Robert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1225702}
This commit is contained in:
Xianzhu Wang
2023-11-16 20:51:52 +00:00
committed by Chromium LUCI CQ
parent f5bb3940c2
commit c0bd7e56e8
23 changed files with 318 additions and 392 deletions

@ -137,13 +137,13 @@ class DiscardableImageGenerator {
}
PaintOpType op_type = static_cast<PaintOpType>(op.type);
if (op_type == PaintOpType::kDrawimage) {
if (op_type == PaintOpType::kDrawImage) {
const auto& image_op = static_cast<const DrawImageOp&>(op);
AddImage(
image_op.image, image_op.flags.useDarkModeForImage(),
SkRect::MakeIWH(image_op.image.width(), image_op.image.height()),
op_rect, ctm, image_op.flags.getFilterQuality());
} else if (op_type == PaintOpType::kDrawimagerect) {
} else if (op_type == PaintOpType::kDrawImageRect) {
const auto& image_rect_op = static_cast<const DrawImageRectOp&>(op);
// TODO(crbug.com/1155544): Make a RectToRect method that uses SkM44s
// in MathUtil.
@ -152,7 +152,7 @@ class DiscardableImageGenerator {
AddImage(image_rect_op.image, image_rect_op.flags.useDarkModeForImage(),
image_rect_op.src, op_rect, matrix,
image_rect_op.flags.getFilterQuality());
} else if (op_type == PaintOpType::kDrawskottie) {
} else if (op_type == PaintOpType::kDrawSkottie) {
const auto& skottie_op = static_cast<const DrawSkottieOp&>(op);
for (const auto& image_pair : skottie_op.images) {
const SkottieFrameData& frame_data = image_pair.second;
@ -188,7 +188,7 @@ class DiscardableImageGenerator {
std::move(image_src_rect), std::move(dst_rect), matrix,
frame_data.quality);
}
} else if (op_type == PaintOpType::kDrawrecord) {
} else if (op_type == PaintOpType::kDrawRecord) {
GatherDiscardableImages(
static_cast<const DrawRecordOp&>(op).record.buffer(),
top_level_op_rect, canvas);

@ -41,9 +41,9 @@ void IterateTextContent(const PaintOpBuffer& buffer,
if (!buffer.has_draw_text_ops())
return;
for (const PaintOp& op : buffer) {
if (op.GetType() == PaintOpType::kDrawtextblob) {
if (op.GetType() == PaintOpType::kDrawTextBlob) {
yield(static_cast<const DrawTextBlobOp&>(op), rect);
} else if (op.GetType() == PaintOpType::kDrawrecord) {
} else if (op.GetType() == PaintOpType::kDrawRecord) {
IterateTextContent(static_cast<const DrawRecordOp&>(op).record.buffer(),
yield, rect);
}
@ -59,9 +59,9 @@ void IterateTextContentByOffsets(const PaintOpBuffer& buffer,
DCHECK_EQ(rects.size(), offsets.size());
size_t index = 0;
for (const PaintOp& op : PaintOpBuffer::OffsetIterator(buffer, offsets)) {
if (op.GetType() == PaintOpType::kDrawtextblob) {
if (op.GetType() == PaintOpType::kDrawTextBlob) {
yield(static_cast<const DrawTextBlobOp&>(op), rects[index]);
} else if (op.GetType() == PaintOpType::kDrawrecord) {
} else if (op.GetType() == PaintOpType::kDrawRecord) {
IterateTextContent(static_cast<const DrawRecordOp&>(op).record.buffer(),
yield, rects[index]);
}
@ -133,11 +133,11 @@ double DisplayItemList::AreaOfDrawText(const gfx::Rect& rect) const {
size_t index = 0;
for (const PaintOp& op :
PaintOpBuffer::OffsetIterator(paint_op_buffer_, offsets)) {
if (op.GetType() == PaintOpType::kDrawtextblob ||
if (op.GetType() == PaintOpType::kDrawTextBlob ||
// Don't walk into the record because the visual rect is already the
// bounding box of the sub paint operations. This works for most paint
// results for text generated by blink.
(op.GetType() == PaintOpType::kDrawrecord &&
(op.GetType() == PaintOpType::kDrawRecord &&
static_cast<const DrawRecordOp&>(op).record.has_draw_text_ops())) {
area += static_cast<double>(rects[index].width()) * rects[index].height();
}
@ -406,7 +406,7 @@ DirectlyCompositedImageResultForPaintOpBuffer(const PaintOpBuffer& op_buffer) {
transpose_image_size = (concat_op.matrix.rc(0, 0) == 0);
break;
}
case PaintOpType::kDrawimagerect: {
case PaintOpType::kDrawImageRect: {
if (result)
return std::nullopt;
const auto& draw_image_rect_op =
@ -425,7 +425,7 @@ DirectlyCompositedImageResultForPaintOpBuffer(const PaintOpBuffer& op_buffer) {
PaintFlags::FilterQuality::kNone;
break;
}
case PaintOpType::kDrawrecord:
case PaintOpType::kDrawRecord:
if (result)
return std::nullopt;
result = DirectlyCompositedImageResultForPaintOpBuffer(

@ -127,7 +127,7 @@ TEST_F(DisplayItemListTest, TraceEmptyVisualRect) {
EXPECT_TRACED_RECT(0, 0, 0, 0, visual_rect);
name = item_dict->FindString("name");
ASSERT_NE(nullptr, name);
EXPECT_EQ("DrawRect", *name);
EXPECT_EQ("DrawRectOp", *name);
item_dict = ((*items)[1]).GetIfDict();
ASSERT_NE(nullptr, item_dict);
@ -136,7 +136,7 @@ TEST_F(DisplayItemListTest, TraceEmptyVisualRect) {
EXPECT_TRACED_RECT(8, 9, 10, 10, visual_rect);
name = item_dict->FindString("name");
ASSERT_NE(nullptr, name);
EXPECT_EQ("DrawRect", *name);
EXPECT_EQ("DrawRectOp", *name);
}
TEST_F(DisplayItemListTest, SingleUnpairedRange) {
@ -570,9 +570,9 @@ TEST_F(DisplayItemListTest, AsValueWithOps) {
ASSERT_NE(nullptr, items);
ASSERT_EQ(7u, items->size());
const char* expected_names[] = {"Save", "Concat", "SaveLayer",
"Translate", "DrawRect", "Restore",
"Restore"};
const char* expected_names[] = {
"SaveOp", "ConcatOp", "SaveLayerOp", "TranslateOp",
"DrawRectOp", "RestoreOp", "RestoreOp"};
bool expected_has_skp[] = {false, true, true, true, true, false, false};
for (int i = 0; i < 7; ++i) {

@ -318,76 +318,22 @@ bool PaintOp::g_is_draw_op[kNumOpTypes] = {TYPES(M)};
bool PaintOp::g_has_paint_flags[kNumOpTypes] = {TYPES(M)};
#undef M
#undef TYPES
const SkRect PaintOp::kUnsetRect = {SK_ScalarInfinity, 0, 0, 0};
std::string PaintOpTypeToString(PaintOpType type) {
switch (type) {
case PaintOpType::kAnnotate:
return "Annotate";
case PaintOpType::kClippath:
return "ClipPath";
case PaintOpType::kCliprect:
return "ClipRect";
case PaintOpType::kCliprrect:
return "ClipRRect";
case PaintOpType::kConcat:
return "Concat";
case PaintOpType::kCustomdata:
return "CustomData";
case PaintOpType::kDrawcolor:
return "DrawColor";
case PaintOpType::kDrawdrrect:
return "DrawDRRect";
case PaintOpType::kDrawimage:
return "DrawImage";
case PaintOpType::kDrawimagerect:
return "DrawImageRect";
case PaintOpType::kDrawirect:
return "DrawIRect";
case PaintOpType::kDrawline:
return "DrawLine";
case PaintOpType::kDrawoval:
return "DrawOval";
case PaintOpType::kDrawpath:
return "DrawPath";
case PaintOpType::kDrawrecord:
return "DrawRecord";
case PaintOpType::kDrawrect:
return "DrawRect";
case PaintOpType::kDrawrrect:
return "DrawRRect";
case PaintOpType::kDrawskottie:
return "DrawSkottie";
case PaintOpType::kDrawslug:
return "DrawSlug";
case PaintOpType::kDrawtextblob:
return "DrawTextBlob";
case PaintOpType::kNoop:
return "Noop";
case PaintOpType::kRestore:
return "Restore";
case PaintOpType::kRotate:
return "Rotate";
case PaintOpType::kSave:
return "Save";
case PaintOpType::kSavelayer:
return "SaveLayer";
case PaintOpType::kSavelayeralpha:
return "SaveLayerAlpha";
case PaintOpType::kScale:
return "Scale";
case PaintOpType::kSetmatrix:
return "SetMatrix";
case PaintOpType::kSetnodeid:
return "SetNodeId";
case PaintOpType::kTranslate:
return "Translate";
#define M(T) \
case T::kType: \
return #T;
TYPES(M)
#undef M
}
return "UNKNOWN";
NOTREACHED_NORETURN();
}
#undef TYPES
std::ostream& operator<<(std::ostream& os, PaintOpType type) {
return os << PaintOpTypeToString(type);
}
@ -1679,8 +1625,8 @@ size_t PaintOp::Serialize(void* memory,
original_ctm);
// Convert DrawTextBlobOp to DrawSlugOp.
if (GetType() == PaintOpType::kDrawtextblob) {
return writer.FinishOp(static_cast<uint8_t>(PaintOpType::kDrawslug));
if (GetType() == PaintOpType::kDrawTextBlob) {
return writer.FinishOp(static_cast<uint8_t>(PaintOpType::kDrawSlug));
}
return writer.FinishOp(type);
}
@ -1733,78 +1679,78 @@ bool PaintOp::GetBounds(const PaintOp& op, SkRect* rect) {
DCHECK(op.IsDrawOp());
switch (op.GetType()) {
case PaintOpType::kDrawcolor:
case PaintOpType::kDrawColor:
return false;
case PaintOpType::kDrawdrrect: {
case PaintOpType::kDrawDRRect: {
const auto& rect_op = static_cast<const DrawDRRectOp&>(op);
*rect = rect_op.outer.getBounds();
rect->sort();
return true;
}
case PaintOpType::kDrawimage: {
case PaintOpType::kDrawImage: {
const auto& image_op = static_cast<const DrawImageOp&>(op);
*rect = SkRect::MakeXYWH(image_op.left, image_op.top,
image_op.image.width(), image_op.image.height());
rect->sort();
return true;
}
case PaintOpType::kDrawimagerect: {
case PaintOpType::kDrawImageRect: {
const auto& image_rect_op = static_cast<const DrawImageRectOp&>(op);
*rect = image_rect_op.dst;
rect->sort();
return true;
}
case PaintOpType::kDrawirect: {
case PaintOpType::kDrawIRect: {
const auto& rect_op = static_cast<const DrawIRectOp&>(op);
*rect = SkRect::Make(rect_op.rect);
rect->sort();
return true;
}
case PaintOpType::kDrawline: {
case PaintOpType::kDrawLine: {
const auto& line_op = static_cast<const DrawLineOp&>(op);
rect->setLTRB(line_op.x0, line_op.y0, line_op.x1, line_op.y1);
rect->sort();
return true;
}
case PaintOpType::kDrawoval: {
case PaintOpType::kDrawOval: {
const auto& oval_op = static_cast<const DrawOvalOp&>(op);
*rect = oval_op.oval;
rect->sort();
return true;
}
case PaintOpType::kDrawpath: {
case PaintOpType::kDrawPath: {
const auto& path_op = static_cast<const DrawPathOp&>(op);
*rect = path_op.path.getBounds();
rect->sort();
return true;
}
case PaintOpType::kDrawrect: {
case PaintOpType::kDrawRect: {
const auto& rect_op = static_cast<const DrawRectOp&>(op);
*rect = rect_op.rect;
rect->sort();
return true;
}
case PaintOpType::kDrawrrect: {
case PaintOpType::kDrawRRect: {
const auto& rect_op = static_cast<const DrawRRectOp&>(op);
*rect = rect_op.rrect.rect();
rect->sort();
return true;
}
case PaintOpType::kDrawrecord:
case PaintOpType::kDrawRecord:
return false;
case PaintOpType::kDrawskottie: {
case PaintOpType::kDrawSkottie: {
const auto& skottie_op = static_cast<const DrawSkottieOp&>(op);
*rect = skottie_op.dst;
rect->sort();
return true;
}
case PaintOpType::kDrawtextblob: {
case PaintOpType::kDrawTextBlob: {
const auto& text_op = static_cast<const DrawTextBlobOp&>(op);
*rect = text_op.blob->bounds().makeOffset(text_op.x, text_op.y);
rect->sort();
return true;
}
case PaintOpType::kDrawslug: {
case PaintOpType::kDrawSlug: {
const auto& slug_op = static_cast<const DrawSlugOp&>(op);
*rect = slug_op.slug->sourceBoundsWithOrigin();
rect->sort();
@ -1896,16 +1842,16 @@ bool PaintOp::OpHasDiscardableImages(const PaintOp& op) {
return true;
}
if (op.GetType() == PaintOpType::kDrawimage &&
if (op.GetType() == PaintOpType::kDrawImage &&
static_cast<const DrawImageOp&>(op).HasDiscardableImages()) {
return true;
} else if (op.GetType() == PaintOpType::kDrawimagerect &&
} else if (op.GetType() == PaintOpType::kDrawImageRect &&
static_cast<const DrawImageRectOp&>(op).HasDiscardableImages()) {
return true;
} else if (op.GetType() == PaintOpType::kDrawrecord &&
} else if (op.GetType() == PaintOpType::kDrawRecord &&
static_cast<const DrawRecordOp&>(op).HasDiscardableImages()) {
return true;
} else if (op.GetType() == PaintOpType::kDrawskottie &&
} else if (op.GetType() == PaintOpType::kDrawSkottie &&
static_cast<const DrawSkottieOp&>(op).HasDiscardableImages()) {
return true;
}

@ -69,36 +69,36 @@ class CC_PAINT_EXPORT ThreadsafePath : public SkPath {
enum class PaintOpType : uint8_t {
kAnnotate,
kClippath,
kCliprect,
kCliprrect,
kClipPath,
kClipRect,
kClipRRect,
kConcat,
kCustomdata,
kDrawcolor,
kDrawdrrect,
kDrawimage,
kDrawimagerect,
kDrawirect,
kDrawline,
kDrawoval,
kDrawpath,
kDrawrecord,
kDrawrect,
kDrawrrect,
kDrawskottie,
kDrawslug,
kDrawtextblob,
kCustomData,
kDrawColor,
kDrawDRRect,
kDrawImage,
kDrawImageRect,
kDrawIRect,
kDrawLine,
kDrawOval,
kDrawPath,
kDrawRecord,
kDrawRect,
kDrawRRect,
kDrawSkottie,
kDrawSlug,
kDrawTextBlob,
kNoop,
kRestore,
kRotate,
kSave,
kSavelayer,
kSavelayeralpha,
kSaveLayer,
kSaveLayerAlpha,
kScale,
kSetmatrix,
kSetnodeid,
kSetMatrix,
kSetNodeId,
kTranslate,
kLastpaintoptype = kTranslate,
kLastPaintOpType = kTranslate,
};
CC_PAINT_EXPORT std::string PaintOpTypeToString(PaintOpType type);
@ -199,7 +199,7 @@ class CC_PAINT_EXPORT PaintOp {
bool HasSaveLayerOps() const { return false; }
bool HasSaveLayerAlphaOps() const { return false; }
// Returns true if effects are present that would break LCD text or be broken
// by the flags for kSavelayeralpha to preserving LCD text.
// by the flags for kSaveLayerAlpha to preserving LCD text.
bool HasEffectsPreventingLCDTextForSaveLayerAlpha() const { return false; }
bool HasDiscardableImages() const { return false; }
@ -216,13 +216,13 @@ class CC_PAINT_EXPORT PaintOp {
// memory buffers and so don't have their destructors run automatically.
void DestroyThis();
// kDrawcolor is more restrictive on the blend modes that can be used.
// kDrawColor is more restrictive on the blend modes that can be used.
static bool IsValidDrawColorSkBlendMode(SkBlendMode mode) {
return static_cast<uint32_t>(mode) <=
static_cast<uint32_t>(SkBlendMode::kLastCoeffMode);
}
// PaintFlags can have more complex blend modes than kDrawcolor.
// PaintFlags can have more complex blend modes than kDrawColor.
static bool IsValidPaintFlagsSkBlendMode(SkBlendMode mode) {
return static_cast<uint32_t>(mode) <=
static_cast<uint32_t>(SkBlendMode::kLastMode);
@ -244,7 +244,7 @@ class CC_PAINT_EXPORT PaintOp {
}
static constexpr size_t kNumOpTypes =
static_cast<size_t>(PaintOpType::kLastpaintoptype) + 1;
static_cast<size_t>(PaintOpType::kLastPaintOpType) + 1;
static bool g_is_draw_op[kNumOpTypes];
static bool g_has_paint_flags[kNumOpTypes];
@ -311,7 +311,7 @@ class CC_PAINT_EXPORT AnnotateOp final : public PaintOp {
class CC_PAINT_EXPORT ClipPathOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kClippath;
static constexpr PaintOpType kType = PaintOpType::kClipPath;
ClipPathOp(SkPath path,
SkClipOp op,
bool antialias,
@ -341,7 +341,7 @@ class CC_PAINT_EXPORT ClipPathOp final : public PaintOp {
class CC_PAINT_EXPORT ClipRectOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kCliprect;
static constexpr PaintOpType kType = PaintOpType::kClipRect;
ClipRectOp(const SkRect& rect, SkClipOp op, bool antialias)
: PaintOp(kType), rect(rect), op(op), antialias(antialias) {}
static void Raster(const ClipRectOp* op,
@ -361,7 +361,7 @@ class CC_PAINT_EXPORT ClipRectOp final : public PaintOp {
class CC_PAINT_EXPORT ClipRRectOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kCliprrect;
static constexpr PaintOpType kType = PaintOpType::kClipRRect;
ClipRRectOp(const SkRRect& rrect, SkClipOp op, bool antialias)
: PaintOp(kType), rrect(rrect), op(op), antialias(antialias) {}
static void Raster(const ClipRRectOp* op,
@ -399,7 +399,7 @@ class CC_PAINT_EXPORT ConcatOp final : public PaintOp {
class CC_PAINT_EXPORT CustomDataOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kCustomdata;
static constexpr PaintOpType kType = PaintOpType::kCustomData;
explicit CustomDataOp(uint32_t id) : PaintOp(kType), id(id) {}
static void Raster(const CustomDataOp* op,
SkCanvas* canvas,
@ -417,7 +417,7 @@ class CC_PAINT_EXPORT CustomDataOp final : public PaintOp {
class CC_PAINT_EXPORT DrawColorOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawcolor;
static constexpr PaintOpType kType = PaintOpType::kDrawColor;
static constexpr bool kIsDrawOp = true;
DrawColorOp(SkColor4f color, SkBlendMode mode)
: PaintOp(kType), color(color), mode(mode) {}
@ -437,7 +437,7 @@ class CC_PAINT_EXPORT DrawColorOp final : public PaintOp {
class CC_PAINT_EXPORT DrawDRRectOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawdrrect;
static constexpr PaintOpType kType = PaintOpType::kDrawDRRect;
static constexpr bool kIsDrawOp = true;
DrawDRRectOp(const SkRRect& outer,
const SkRRect& inner,
@ -462,7 +462,7 @@ class CC_PAINT_EXPORT DrawDRRectOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawImageOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawimage;
static constexpr PaintOpType kType = PaintOpType::kDrawImage;
static constexpr bool kIsDrawOp = true;
DrawImageOp(const PaintImage& image, SkScalar left, SkScalar top);
DrawImageOp(const PaintImage& image,
@ -499,7 +499,7 @@ class CC_PAINT_EXPORT DrawImageOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawImageRectOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawimagerect;
static constexpr PaintOpType kType = PaintOpType::kDrawImageRect;
static constexpr bool kIsDrawOp = true;
DrawImageRectOp(const PaintImage& image,
const SkRect& src,
@ -541,7 +541,7 @@ class CC_PAINT_EXPORT DrawImageRectOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawIRectOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawirect;
static constexpr PaintOpType kType = PaintOpType::kDrawIRect;
static constexpr bool kIsDrawOp = true;
DrawIRectOp(const SkIRect& rect, const PaintFlags& flags)
: PaintOpWithFlags(kType, flags), rect(rect) {}
@ -562,7 +562,7 @@ class CC_PAINT_EXPORT DrawIRectOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawLineOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawline;
static constexpr PaintOpType kType = PaintOpType::kDrawLine;
static constexpr bool kIsDrawOp = true;
DrawLineOp(SkScalar x0,
SkScalar y0,
@ -601,7 +601,7 @@ class CC_PAINT_EXPORT DrawLineOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawOvalOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawoval;
static constexpr PaintOpType kType = PaintOpType::kDrawOval;
static constexpr bool kIsDrawOp = true;
DrawOvalOp(const SkRect& oval, const PaintFlags& flags)
: PaintOpWithFlags(kType, flags), oval(oval) {}
@ -624,7 +624,7 @@ class CC_PAINT_EXPORT DrawOvalOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawPathOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawpath;
static constexpr PaintOpType kType = PaintOpType::kDrawPath;
static constexpr bool kIsDrawOp = true;
DrawPathOp(const SkPath& path,
const PaintFlags& flags,
@ -657,7 +657,7 @@ class CC_PAINT_EXPORT DrawPathOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawRecordOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawrecord;
static constexpr PaintOpType kType = PaintOpType::kDrawRecord;
static constexpr bool kIsDrawOp = true;
explicit DrawRecordOp(PaintRecord record);
~DrawRecordOp();
@ -682,7 +682,7 @@ class CC_PAINT_EXPORT DrawRecordOp final : public PaintOp {
class CC_PAINT_EXPORT DrawRectOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawrect;
static constexpr PaintOpType kType = PaintOpType::kDrawRect;
static constexpr bool kIsDrawOp = true;
DrawRectOp(const SkRect& rect, const PaintFlags& flags)
: PaintOpWithFlags(kType, flags), rect(rect) {}
@ -702,7 +702,7 @@ class CC_PAINT_EXPORT DrawRectOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawRRectOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawrrect;
static constexpr PaintOpType kType = PaintOpType::kDrawRRect;
static constexpr bool kIsDrawOp = true;
DrawRRectOp(const SkRRect& rrect, const PaintFlags& flags)
: PaintOpWithFlags(kType, flags), rrect(rrect) {}
@ -722,7 +722,7 @@ class CC_PAINT_EXPORT DrawRRectOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawSkottieOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawskottie;
static constexpr PaintOpType kType = PaintOpType::kDrawSkottie;
static constexpr bool kIsDrawOp = true;
DrawSkottieOp(scoped_refptr<SkottieWrapper> skottie,
SkRect dst,
@ -769,7 +769,7 @@ class CC_PAINT_EXPORT DrawSkottieOp final : public PaintOp {
class CC_PAINT_EXPORT DrawSlugOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawslug;
static constexpr PaintOpType kType = PaintOpType::kDrawSlug;
static constexpr bool kIsDrawOp = true;
DrawSlugOp(sk_sp<sktext::gpu::Slug> slug, const PaintFlags& flags);
~DrawSlugOp();
@ -797,7 +797,7 @@ class CC_PAINT_EXPORT DrawSlugOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT DrawTextBlobOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kDrawtextblob;
static constexpr PaintOpType kType = PaintOpType::kDrawTextBlob;
static constexpr bool kIsDrawOp = true;
DrawTextBlobOp(sk_sp<SkTextBlob> blob,
SkScalar x,
@ -885,7 +885,7 @@ class CC_PAINT_EXPORT SaveOp final : public PaintOp {
class CC_PAINT_EXPORT SaveLayerOp final : public PaintOpWithFlags {
public:
static constexpr PaintOpType kType = PaintOpType::kSavelayer;
static constexpr PaintOpType kType = PaintOpType::kSaveLayer;
explicit SaveLayerOp(const PaintFlags& flags)
: PaintOpWithFlags(kType, flags), bounds(kUnsetRect) {}
SaveLayerOp(const SkRect& bounds, const PaintFlags& flags)
@ -899,7 +899,7 @@ class CC_PAINT_EXPORT SaveLayerOp final : public PaintOpWithFlags {
bool HasNonAAPaint() const { return false; }
// We simply assume any effects (or even no effects -- just starting an empty
// transparent layer) would break LCD text or be broken by the flags for
// kSavelayeralpha to preserve LCD text.
// kSaveLayerAlpha to preserve LCD text.
bool HasEffectsPreventingLCDTextForSaveLayerAlpha() const { return true; }
bool HasSaveLayerOps() const { return true; }
HAS_SERIALIZATION_FUNCTIONS();
@ -912,7 +912,7 @@ class CC_PAINT_EXPORT SaveLayerOp final : public PaintOpWithFlags {
class CC_PAINT_EXPORT SaveLayerAlphaOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kSavelayeralpha;
static constexpr PaintOpType kType = PaintOpType::kSaveLayerAlpha;
template <class F, class = std::enable_if_t<std::is_same_v<F, float>>>
explicit SaveLayerAlphaOp(F alpha)
: PaintOp(kType), bounds(kUnsetRect), alpha(alpha) {}
@ -955,14 +955,14 @@ class CC_PAINT_EXPORT ScaleOp final : public PaintOp {
class CC_PAINT_EXPORT SetMatrixOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kSetmatrix;
static constexpr PaintOpType kType = PaintOpType::kSetMatrix;
explicit SetMatrixOp(const SkM44& matrix) : PaintOp(kType), matrix(matrix) {}
// This is the only op that needs the original ctm of the SkCanvas
// used for raster (since kSetmatrix is relative to the recording origin and
// used for raster (since kSetMatrix is relative to the recording origin and
// shouldn't clobber the SkCanvas raster origin).
//
// TODO(enne): Find some cleaner way to do this, possibly by making
// all kSetmatrix calls kConcat??
// all kSetMatrix calls kConcat??
static void Raster(const SetMatrixOp* op,
SkCanvas* canvas,
const PlaybackParams& params);
@ -978,7 +978,7 @@ class CC_PAINT_EXPORT SetMatrixOp final : public PaintOp {
class CC_PAINT_EXPORT SetNodeIdOp final : public PaintOp {
public:
static constexpr PaintOpType kType = PaintOpType::kSetnodeid;
static constexpr PaintOpType kType = PaintOpType::kSetNodeId;
explicit SetNodeIdOp(int node_id) : PaintOp(kType), node_id(node_id) {}
static void Raster(const SetNodeIdOp* op,
SkCanvas* canvas,

@ -15,7 +15,7 @@ namespace {
static const PaintOp* GetNestedSingleDrawingOp(const PaintOp* op) {
if (!op->IsDrawOp())
return nullptr;
while (op->GetType() == PaintOpType::kDrawrecord) {
while (op->GetType() == PaintOpType::kDrawRecord) {
auto* draw_record_op = static_cast<const DrawRecordOp*>(op);
if (draw_record_op->record.size() > 1) {
// If there's more than one op, then we need to keep the
@ -65,7 +65,7 @@ void PaintOpBuffer::PlaybackFoldingIterator::FindNextOp() {
current_alpha_ = 1.0f;
for (current_op_ = NextUnfoldedOp(); current_op_;
current_op_ = NextUnfoldedOp()) {
if (current_op_->GetType() != PaintOpType::kSavelayeralpha) {
if (current_op_->GetType() != PaintOpType::kSaveLayerAlpha) {
break;
}
const PaintOp* second = NextUnfoldedOp();
@ -73,7 +73,7 @@ void PaintOpBuffer::PlaybackFoldingIterator::FindNextOp() {
break;
if (second->GetType() == PaintOpType::kRestore) {
// Drop a kSavelayeralpha/kRestore combo.
// Drop a kSaveLayerAlpha/kRestore combo.
continue;
}
@ -89,16 +89,16 @@ void PaintOpBuffer::PlaybackFoldingIterator::FindNextOp() {
auto* save_op = static_cast<const SaveLayerAlphaOp*>(current_op_);
if (draw_op->IsPaintOpWithFlags() &&
// SkPaint::drawTextBlob() applies alpha on each glyph so we don't
// fold kSavelayeralpha into DrwaTextBlob to ensure correct alpha
// fold kSaveLayerAlpha into DrwaTextBlob to ensure correct alpha
// even if some glyphs overlap.
draw_op->GetType() != PaintOpType::kDrawtextblob) {
draw_op->GetType() != PaintOpType::kDrawTextBlob) {
auto* flags_op = static_cast<const PaintOpWithFlags*>(draw_op);
if (flags_op->flags.SupportsFoldingAlpha()) {
current_alpha_ = save_op->alpha;
current_op_ = draw_op;
break;
}
} else if (draw_op->GetType() == PaintOpType::kDrawcolor &&
} else if (draw_op->GetType() == PaintOpType::kDrawColor &&
static_cast<const DrawColorOp*>(draw_op)->mode ==
SkBlendMode::kSrcOver) {
auto* draw_color_op = static_cast<const DrawColorOp*>(draw_op);
@ -112,7 +112,7 @@ void PaintOpBuffer::PlaybackFoldingIterator::FindNextOp() {
}
// If we get here, then we could not find a foldable sequence after
// this kSavelayeralpha, so store any peeked at ops.
// this kSaveLayerAlpha, so store any peeked at ops.
stack_.push_back(second);
if (third)
stack_.push_back(third);

@ -123,7 +123,7 @@ class CC_PAINT_EXPORT PaintOpBuffer::OffsetIterator
op_offset_ = target_offset;
DCHECK(!*this || (*this)->type <=
static_cast<uint32_t>(PaintOpType::kLastpaintoptype));
static_cast<uint32_t>(PaintOpType::kLastPaintOpType));
return *this;
}
OffsetIterator operator++(int) {

@ -200,11 +200,11 @@ bool PaintOpBufferSerializer::WillSerializeNextOp(const PaintOp& op,
PaintOp::QuickRejectDraw(op, canvas);
// Skip text ops if there is no SkStrikeServer.
skip_op |=
op.GetType() == PaintOpType::kDrawtextblob && !options_.strike_server;
op.GetType() == PaintOpType::kDrawTextBlob && !options_.strike_server;
if (skip_op)
return true;
if (op.GetType() == PaintOpType::kDrawrecord) {
if (op.GetType() == PaintOpType::kDrawRecord) {
int save_count = canvas->getSaveCount();
Save(canvas, params);
SerializeBuffer(
@ -213,7 +213,7 @@ bool PaintOpBufferSerializer::WillSerializeNextOp(const PaintOp& op,
return true;
}
if (op.GetType() == PaintOpType::kDrawimagerect &&
if (op.GetType() == PaintOpType::kDrawImageRect &&
static_cast<const DrawImageRectOp&>(op).image.IsPaintWorklet()) {
DCHECK(options_.image_provider);
const DrawImageRectOp& draw_op = static_cast<const DrawImageRectOp&>(op);
@ -342,7 +342,7 @@ void PaintOpBufferSerializer::PlaybackOnAnalysisCanvas(
// 2) kDrawtextblob ops since they need to be analyzed by the cache diff
// canvas
// to serialize/lock the requisite glyphs for this op.
if (op.IsDrawOp() && op.GetType() != PaintOpType::kDrawtextblob) {
if (op.IsDrawOp() && op.GetType() != PaintOpType::kDrawTextBlob) {
return;
}

@ -255,7 +255,7 @@ TEST_F(PaintOpAppendTest, MoveThenReappendOperatorEq) {
EXPECT_TRUE(original.EqualsForTesting(destination));
}
// Verify that a kSavelayeralpha / Draw / kRestore can be optimized to just
// Verify that a kSaveLayerAlpha / Draw / kRestore can be optimized to just
// a draw with opacity.
TEST(PaintOpBufferTest, SaveDrawRestore) {
PaintOpBuffer buffer;
@ -285,7 +285,7 @@ TEST(PaintOpBufferTest, SaveDrawRestore) {
EXPECT_NEAR(expected_alpha, canvas.paint_.getAlphaf(), 0.01f);
}
// Verify that we don't optimize kSavelayeralpha / kDrawtextblob / kRestore.
// Verify that we don't optimize kSaveLayerAlpha / kDrawTextBlob / kRestore.
TEST(PaintOpBufferTest, SaveDrawTextBlobRestore) {
PaintOpBuffer buffer;
@ -405,7 +405,7 @@ TEST(PaintOpBufferTest, SaveDrawRestore_SingleOpNotADrawOp) {
}
// Test that the save/draw/restore optimization applies if the single op
// is a kDrawrecord that itself has a single draw op.
// is a kDrawRecord that itself has a single draw op.
TEST(PaintOpBufferTest, SaveDrawRestore_SingleOpRecordWithSingleOp) {
PaintOpBuffer sub_buffer;
@ -757,7 +757,7 @@ TEST_F(PaintOpBufferOffsetsTest, EmptyClipRectShouldRejectAnOp) {
for (PaintOpBuffer::PlaybackFoldingIterator iter(buffer_, &offsets); iter;
++iter) {
const PaintOp& op = *iter;
EXPECT_EQ(op.GetType(), PaintOpType::kDrawimagerect);
EXPECT_EQ(op.GetType(), PaintOpType::kDrawImageRect);
EXPECT_TRUE(PaintOp::QuickRejectDraw(op, canvas));
}
}
@ -863,7 +863,7 @@ TEST_F(PaintOpBufferOffsetsTest, ContiguousIndicesWithSaveLayerAlphaRestore) {
testing::Sequence s;
EXPECT_CALL(canvas, OnDrawPaintWithColor(0u)).InSequence(s);
EXPECT_CALL(canvas, OnDrawPaintWithColor(1u)).InSequence(s);
// The empty kSavelayeralpha/kRestore is dropped.
// The empty kSaveLayerAlpha/kRestore is dropped.
EXPECT_CALL(canvas, OnDrawPaintWithColor(2u)).InSequence(s);
EXPECT_CALL(canvas, OnDrawPaintWithColor(3u)).InSequence(s);
EXPECT_CALL(canvas, OnDrawPaintWithColor(4u)).InSequence(s);
@ -891,7 +891,7 @@ TEST_F(PaintOpBufferOffsetsTest,
testing::Sequence s;
EXPECT_CALL(canvas, OnDrawPaintWithColor(0u)).InSequence(s);
EXPECT_CALL(canvas, OnDrawPaintWithColor(1u)).InSequence(s);
// The kSavelayeralpha/kRestore is not dropped if we draw the middle
// The kSaveLayerAlpha/kRestore is not dropped if we draw the middle
// range, as we need them to represent the two draws inside the layer
// correctly.
EXPECT_CALL(canvas, OnSaveLayer()).InSequence(s);
@ -908,7 +908,7 @@ TEST_F(PaintOpBufferOffsetsTest,
testing::Sequence s;
EXPECT_CALL(canvas, OnDrawPaintWithColor(0u)).InSequence(s);
EXPECT_CALL(canvas, OnDrawPaintWithColor(1u)).InSequence(s);
// The now-empty kSavelayeralpha/kRestore is dropped
// The now-empty kSaveLayerAlpha/kRestore is dropped
EXPECT_CALL(canvas, OnDrawPaintWithColor(4u)).InSequence(s);
Playback(&canvas, Select({0, 1, 2, 5, 6}));
}
@ -939,7 +939,7 @@ TEST_F(PaintOpBufferOffsetsTest,
testing::Sequence s;
EXPECT_CALL(canvas, OnDrawRectWithColor(0u)).InSequence(s);
EXPECT_CALL(canvas, OnDrawRectWithColor(1u)).InSequence(s);
// The empty kSavelayeralpha/kRestore is dropped, the containing
// The empty kSaveLayerAlpha/kRestore is dropped, the containing
// operation can be drawn with alpha.
EXPECT_CALL(canvas, OnDrawRectWithColor(2u)).InSequence(s);
EXPECT_CALL(canvas, OnDrawRectWithColor(3u)).InSequence(s);
@ -969,7 +969,7 @@ TEST_F(PaintOpBufferOffsetsTest,
// Items are are {0, 1, save, 2, 3, 4, restore}.
// If the middle range is played, then the kSavelayeralpha/kRestore
// If the middle range is played, then the kSaveLayerAlpha/kRestore
// can't be dropped.
{
testing::Sequence s;
@ -984,7 +984,7 @@ TEST_F(PaintOpBufferOffsetsTest,
}
Mock::VerifyAndClearExpectations(&canvas);
// If the middle range is not played, then the kSavelayeralpha/kRestore
// If the middle range is not played, then the kSaveLayerAlpha/kRestore
// can be dropped.
{
testing::Sequence s;
@ -995,7 +995,7 @@ TEST_F(PaintOpBufferOffsetsTest,
}
Mock::VerifyAndClearExpectations(&canvas);
// If the middle range is not played, then the kSavelayeralpha/kRestore
// If the middle range is not played, then the kSaveLayerAlpha/kRestore
// can be dropped.
{
testing::Sequence s;
@ -1299,8 +1299,8 @@ class SimpleSerializer {
size_t bytes_to_read = 0;
EXPECT_TRUE(
ReadAndValidateOpHeader(current_, remaining_, &type, &bytes_to_read));
if (op.GetType() == PaintOpType::kDrawtextblob) {
EXPECT_EQ(type, static_cast<int>(PaintOpType::kDrawslug));
if (op.GetType() == PaintOpType::kDrawTextBlob) {
EXPECT_EQ(type, static_cast<int>(PaintOpType::kDrawSlug));
} else {
EXPECT_EQ(op.type, type);
}
@ -1811,61 +1811,61 @@ class PaintOpSerializationTest : public ::testing::TestWithParam<uint8_t> {
case PaintOpType::kAnnotate:
PushAnnotateOps(&buffer_);
break;
case PaintOpType::kClippath:
case PaintOpType::kClipPath:
PushClipPathOps(&buffer_);
break;
case PaintOpType::kCliprect:
case PaintOpType::kClipRect:
PushClipRectOps(&buffer_);
break;
case PaintOpType::kCliprrect:
case PaintOpType::kClipRRect:
PushClipRRectOps(&buffer_);
break;
case PaintOpType::kConcat:
PushConcatOps(&buffer_);
break;
case PaintOpType::kCustomdata:
case PaintOpType::kCustomData:
PushCustomDataOps(&buffer_);
break;
case PaintOpType::kDrawcolor:
case PaintOpType::kDrawColor:
PushDrawColorOps(&buffer_);
break;
case PaintOpType::kDrawdrrect:
case PaintOpType::kDrawDRRect:
PushDrawDRRectOps(&buffer_);
break;
case PaintOpType::kDrawimage:
case PaintOpType::kDrawImage:
PushDrawImageOps(&buffer_);
break;
case PaintOpType::kDrawimagerect:
case PaintOpType::kDrawImageRect:
PushDrawImageRectOps(&buffer_);
break;
case PaintOpType::kDrawirect:
case PaintOpType::kDrawIRect:
PushDrawIRectOps(&buffer_);
break;
case PaintOpType::kDrawline:
case PaintOpType::kDrawLine:
PushDrawLineOps(&buffer_);
break;
case PaintOpType::kDrawoval:
case PaintOpType::kDrawOval:
PushDrawOvalOps(&buffer_);
break;
case PaintOpType::kDrawpath:
case PaintOpType::kDrawPath:
PushDrawPathOps(&buffer_);
break;
case PaintOpType::kDrawrecord:
case PaintOpType::kDrawRecord:
// Not supported.
break;
case PaintOpType::kDrawrect:
case PaintOpType::kDrawRect:
PushDrawRectOps(&buffer_);
break;
case PaintOpType::kDrawrrect:
case PaintOpType::kDrawRRect:
PushDrawRRectOps(&buffer_);
break;
case PaintOpType::kDrawskottie:
case PaintOpType::kDrawSkottie:
PushDrawSkottieOps(&buffer_);
break;
case PaintOpType::kDrawslug:
// TODO(crbug.com/1321150): fix the test for kDrawslug.
case PaintOpType::kDrawSlug:
// TODO(crbug.com/1321150): fix the test for kDrawSlug.
break;
case PaintOpType::kDrawtextblob:
case PaintOpType::kDrawTextBlob:
// TODO(crbug.com/1321150): fix the test for kDrawtextblobs
// PushDrawTextBlobOps(&buffer_);
break;
@ -1881,22 +1881,22 @@ class PaintOpSerializationTest : public ::testing::TestWithParam<uint8_t> {
case PaintOpType::kSave:
PushSaveOps(&buffer_);
break;
case PaintOpType::kSavelayer:
case PaintOpType::kSaveLayer:
PushSaveLayerOps(&buffer_);
break;
case PaintOpType::kSavelayeralpha:
case PaintOpType::kSaveLayerAlpha:
PushSaveLayerAlphaOps(&buffer_);
break;
case PaintOpType::kScale:
PushScaleOps(&buffer_);
break;
case PaintOpType::kSetmatrix:
case PaintOpType::kSetMatrix:
PushSetMatrixOps(&buffer_);
break;
case PaintOpType::kTranslate:
PushTranslateOps(&buffer_);
break;
case PaintOpType::kSetnodeid:
case PaintOpType::kSetNodeId:
PushSetNodeIdOps(&buffer_);
break;
}
@ -1910,15 +1910,15 @@ class PaintOpSerializationTest : public ::testing::TestWithParam<uint8_t> {
bool IsTypeSupported() {
// TODO(crbug.com/1321150): fix the test for kDrawtextblobs
if (GetParamType() == PaintOpType::kDrawtextblob ||
GetParamType() == PaintOpType::kDrawslug) {
if (GetParamType() == PaintOpType::kDrawTextBlob ||
GetParamType() == PaintOpType::kDrawSlug) {
return false;
}
// DrawRecordOps must be flattened and are not currently serialized. All
// other types must push non-zero amounts of ops in PushTestOps.
return GetParamType() != PaintOpType::kDrawrecord &&
(GetParamType() != PaintOpType::kDrawskottie || kIsSkottieSupported);
return GetParamType() != PaintOpType::kDrawRecord &&
(GetParamType() != PaintOpType::kDrawSkottie || kIsSkottieSupported);
}
protected:
@ -1931,7 +1931,7 @@ INSTANTIATE_TEST_SUITE_P(
P,
PaintOpSerializationTest,
::testing::Range(static_cast<uint8_t>(0),
static_cast<uint8_t>(PaintOpType::kLastpaintoptype)));
static_cast<uint8_t>(PaintOpType::kLastPaintOpType)));
// Test serializing and then deserializing all test ops. They should all
// write successfully and be identical to the original ops in the buffer.
@ -2135,8 +2135,8 @@ TEST_P(PaintOpSerializationTest, UsesOverridenFlags) {
}
// See https://crbug.com/1321150#c3.
if (GetParamType() == PaintOpType::kDrawtextblob ||
GetParamType() == PaintOpType::kDrawslug) {
if (GetParamType() == PaintOpType::kDrawTextBlob ||
GetParamType() == PaintOpType::kDrawSlug) {
return;
}
@ -2262,7 +2262,7 @@ TEST(PaintOpSerializationTest,
PaintOpBuffer::Iterator iter(buffer);
const PaintOp* op = iter.get();
ASSERT_TRUE(op);
EXPECT_EQ(op->GetType(), PaintOpType::kDrawtextblob);
EXPECT_EQ(op->GetType(), PaintOpType::kDrawTextBlob);
size_t output_size = kSerializedBytesPerOp * buffer.size();
std::unique_ptr<char, base::AlignedFreeDeleter> output =
@ -2291,7 +2291,7 @@ TEST(PaintOpSerializationTest,
output.get(), serializer.TotalBytesWritten(),
serializer.options_provider()->deserialize_options())) {
ASSERT_TRUE(iter);
EXPECT_EQ(PaintOpType::kDrawslug, base_written.GetType());
EXPECT_EQ(PaintOpType::kDrawSlug, base_written.GetType());
++iter;
++i;
}
@ -2479,7 +2479,7 @@ TEST(PaintOpBufferTest, PaintOpDeserialize) {
// Bogus types fail to deserialize.
PaintOpWriter::WriteHeaderForTesting(
input.get(), static_cast<uint8_t>(PaintOpType::kLastpaintoptype) + 1,
input.get(), static_cast<uint8_t>(PaintOpType::kLastPaintOpType) + 1,
serialized_size);
EXPECT_FALSE(PaintOp::Deserialize(input.get(), bytes_written, output,
std::size(output), &bytes_read,
@ -3185,7 +3185,7 @@ TEST(PaintOpBufferTest, ReplacesImagesFromProviderOOP) {
PlaybackParams params(nullptr);
testing::Sequence s;
if (op.GetType() == PaintOpType::kDrawimage) {
if (op.GetType() == PaintOpType::kDrawImage) {
// Save/scale/image/restore from DrawImageop.
EXPECT_CALL(canvas, willSave()).InSequence(s);
EXPECT_CALL(canvas, didScale(1.0f / expected_scale.width(),
@ -3196,13 +3196,13 @@ TEST(PaintOpBufferTest, ReplacesImagesFromProviderOOP) {
SkCanvas::kFast_SrcRectConstraint));
EXPECT_CALL(canvas, willRestore()).InSequence(s);
op.Raster(&canvas, params);
} else if (op.GetType() == PaintOpType::kDrawimagerect) {
} else if (op.GetType() == PaintOpType::kDrawImageRect) {
EXPECT_CALL(canvas, onDrawImageRect2(NonLazyImage(),
MatchesRect(rect, expected_scale),
SkRect::MakeWH(10, 10), _, _,
SkCanvas::kFast_SrcRectConstraint));
op.Raster(&canvas, params);
} else if (op.GetType() == PaintOpType::kDrawoval) {
} else if (op.GetType() == PaintOpType::kDrawOval) {
EXPECT_CALL(canvas, onDrawOval(SkRect::MakeWH(10, 10),
MatchesShader(flags, expected_scale)));
op.Raster(&canvas, params);
@ -3595,7 +3595,7 @@ TEST(PaintOpBufferTest, CustomData) {
PaintOpBuffer new_buffer = std::move(buffer);
EXPECT_EQ(buffer.size(), 0u);
EXPECT_EQ(new_buffer.size(), 1u);
EXPECT_EQ(new_buffer.GetFirstOp().GetType(), PaintOpType::kCustomdata);
EXPECT_EQ(new_buffer.GetFirstOp().GetType(), PaintOpType::kCustomData);
PaintOpBuffer buffer2;
buffer2.push<CustomDataOp>(1234u);
@ -3783,7 +3783,7 @@ TEST(PaintOpBufferTest, RecordShadersCached) {
EXPECT_EQ(buffers[i]->size(), 2u);
for (const PaintOp& base_op : *buffers[i]) {
if (base_op.GetType() != PaintOpType::kDrawrect) {
if (base_op.GetType() != PaintOpType::kDrawRect) {
continue;
}
const auto& op = static_cast<const DrawRectOp&>(base_op);
@ -3984,7 +3984,7 @@ TEST(PaintOpBufferTest, NeedsAdditionalInvalidationForLCDText) {
EXPECT_FALSE(buffer2.has_save_layer_alpha_ops());
EXPECT_TRUE(buffer2.has_effects_preventing_lcd_text_for_save_layer_alpha());
// Neither buffer has effects preventing lcd text for kSavelayeralpha.
// Neither buffer has effects preventing lcd text for kSaveLayerAlpha.
EXPECT_FALSE(buffer1.NeedsAdditionalInvalidationForLCDText(buffer2));
EXPECT_FALSE(buffer2.NeedsAdditionalInvalidationForLCDText(buffer1));
@ -3993,7 +3993,7 @@ TEST(PaintOpBufferTest, NeedsAdditionalInvalidationForLCDText) {
PaintOpBuffer buffer3;
buffer3.push<DrawRecordOp>(record2);
EXPECT_TRUE(buffer3.has_effects_preventing_lcd_text_for_save_layer_alpha());
// Neither buffer has both DrawText and kSavelayeralpha.
// Neither buffer has both DrawText and kSaveLayerAlpha.
EXPECT_FALSE(buffer1.NeedsAdditionalInvalidationForLCDText(buffer3));
EXPECT_FALSE(buffer3.NeedsAdditionalInvalidationForLCDText(buffer1));
EXPECT_FALSE(
@ -4015,7 +4015,7 @@ TEST(PaintOpBufferTest, NeedsAdditionalInvalidationForLCDText) {
EXPECT_TRUE(buffer3.has_draw_text_ops());
EXPECT_TRUE(buffer3.has_save_layer_alpha_ops());
EXPECT_TRUE(buffer3.has_effects_preventing_lcd_text_for_save_layer_alpha());
// Both have DrawText and kSavelayeralpha, and have different
// Both have DrawText and kSaveLayerAlpha, and have different
// has_effects_preventing_lcd_text_for_save_layer_alpha().
EXPECT_TRUE(
record1.buffer().NeedsAdditionalInvalidationForLCDText(buffer3));
@ -4026,7 +4026,7 @@ TEST(PaintOpBufferTest, NeedsAdditionalInvalidationForLCDText) {
}
// A regression test for crbug.com/1195276. Ensure that PlaybackParams works
// with kSetmatrix operations.
// with kSetMatrix operations.
TEST(PaintOpBufferTest, SetMatrixOpWithNonIdentityPlaybackParams) {
for (const auto& original_ctm : test_matrices) {
for (const auto& matrix : test_matrices) {

@ -106,7 +106,7 @@ bool PaintOpReader::ReadAndValidateOpHeader(uint8_t* type,
if (*serialized_size % BufferAlignment() != 0) {
return false;
}
if (*type > static_cast<uint8_t>(PaintOpType::kLastpaintoptype)) {
if (*type > static_cast<uint8_t>(PaintOpType::kLastPaintOpType)) {
return false;
}
return true;

@ -267,7 +267,7 @@ std::optional<SkColor4f> SolidColorAnalyzer::DetermineIfSolidColor(
const PaintOp& op = *frame.iter;
PlaybackParams params(nullptr, SkM44(frame.original_ctm));
switch (op.GetType()) {
case PaintOpType::kDrawrecord: {
case PaintOpType::kDrawRecord: {
const auto& record_op = static_cast<const DrawRecordOp&>(op);
stack.emplace_back(PaintOpBuffer::CompositeIterator(
record_op.record.buffer(), nullptr),
@ -276,16 +276,16 @@ std::optional<SkColor4f> SolidColorAnalyzer::DetermineIfSolidColor(
}
// Any of the following ops result in non solid content.
case PaintOpType::kDrawdrrect:
case PaintOpType::kDrawimage:
case PaintOpType::kDrawimagerect:
case PaintOpType::kDrawirect:
case PaintOpType::kDrawline:
case PaintOpType::kDrawoval:
case PaintOpType::kDrawpath:
case PaintOpType::kDrawDRRect:
case PaintOpType::kDrawImage:
case PaintOpType::kDrawImageRect:
case PaintOpType::kDrawIRect:
case PaintOpType::kDrawLine:
case PaintOpType::kDrawOval:
case PaintOpType::kDrawPath:
return std::nullopt;
// TODO(vmpstr): Add more tests on exceeding max_ops_to_analyze.
case PaintOpType::kDrawrrect: {
case PaintOpType::kDrawRRect: {
if (++num_draw_ops > max_ops_to_analyze)
return std::nullopt;
const auto& rrect_op = static_cast<const DrawRRectOp&>(op);
@ -293,20 +293,20 @@ std::optional<SkColor4f> SolidColorAnalyzer::DetermineIfSolidColor(
&is_transparent, &color);
break;
}
case PaintOpType::kDrawskottie:
case PaintOpType::kDrawslug:
case PaintOpType::kDrawtextblob:
case PaintOpType::kDrawSkottie:
case PaintOpType::kDrawSlug:
case PaintOpType::kDrawTextBlob:
// Anything that has to do a save layer is probably not solid. As it will
// likely need more than one draw op.
// TODO(vmpstr): We could investigate handling these.
case PaintOpType::kSavelayer:
case PaintOpType::kSavelayeralpha:
case PaintOpType::kSaveLayer:
case PaintOpType::kSaveLayerAlpha:
// Complex clips will probably result in non solid color as it might not
// cover the canvas.
// TODO(vmpstr): We could investigate handling these.
case PaintOpType::kClippath:
case PaintOpType::kClipPath:
return std::nullopt;
case PaintOpType::kCliprrect: {
case PaintOpType::kClipRRect: {
const auto& rrect_op = static_cast<const ClipRRectOp&>(op);
bool does_cover_canvas =
CheckIfRRectClipCoversCanvas(canvas, rrect_op.rrect);
@ -316,7 +316,7 @@ std::optional<SkColor4f> SolidColorAnalyzer::DetermineIfSolidColor(
return std::nullopt;
break;
}
case PaintOpType::kDrawrect: {
case PaintOpType::kDrawRect: {
if (++num_draw_ops > max_ops_to_analyze)
return std::nullopt;
const auto& rect_op = static_cast<const DrawRectOp&>(op);
@ -324,7 +324,7 @@ std::optional<SkColor4f> SolidColorAnalyzer::DetermineIfSolidColor(
&is_transparent, &color);
break;
}
case PaintOpType::kDrawcolor: {
case PaintOpType::kDrawColor: {
if (++num_draw_ops > max_ops_to_analyze)
return std::nullopt;
const auto& color_op = static_cast<const DrawColorOp&>(op);
@ -332,7 +332,7 @@ std::optional<SkColor4f> SolidColorAnalyzer::DetermineIfSolidColor(
&is_transparent, &color);
break;
}
case PaintOpType::kCliprect: {
case PaintOpType::kClipRect: {
// SolidColorAnalyzer uses an SkNoDrawCanvas which uses an
// SkNoPixelsDevice which says (without looking) that the canvas's
// clip is always a rect. So, if this clip could result in not
@ -346,15 +346,15 @@ std::optional<SkColor4f> SolidColorAnalyzer::DetermineIfSolidColor(
// Don't affect the canvas, so ignore.
case PaintOpType::kAnnotate:
case PaintOpType::kCustomdata:
case PaintOpType::kSetnodeid:
case PaintOpType::kCustomData:
case PaintOpType::kSetNodeId:
case PaintOpType::kNoop:
break;
// The rest of the ops should only affect our state canvas.
case PaintOpType::kConcat:
case PaintOpType::kScale:
case PaintOpType::kSetmatrix:
case PaintOpType::kSetMatrix:
case PaintOpType::kRestore:
case PaintOpType::kRotate:
case PaintOpType::kSave:

@ -44,190 +44,170 @@ class PaintOpHelper {
static std::string ToString(const PaintOp& base_op) {
std::ostringstream str;
str << std::boolalpha;
str << std::boolalpha << base_op.GetType() << "(";
switch (base_op.GetType()) {
case PaintOpType::kAnnotate: {
const auto& op = static_cast<const AnnotateOp&>(base_op);
str << "AnnotateOp(type=" << ToString(op.annotation_type)
<< ", rect=" << ToString(op.rect) << ", data=" << ToString(op.data)
<< ")";
str << "type=" << ToString(op.annotation_type)
<< ", rect=" << ToString(op.rect) << ", data=" << ToString(op.data);
break;
}
case PaintOpType::kClippath: {
case PaintOpType::kClipPath: {
const auto& op = static_cast<const ClipPathOp&>(base_op);
str << "ClipPathOp(path=" << ToString(op.path)
<< ", op=" << ToString(op.op) << ", antialias=" << op.antialias
<< ", use_cache=" << (op.use_cache == UsePaintCache::kEnabled)
<< ")";
str << "path=" << ToString(op.path) << ", op=" << ToString(op.op)
<< ", antialias=" << op.antialias
<< ", use_cache=" << (op.use_cache == UsePaintCache::kEnabled);
break;
}
case PaintOpType::kCliprect: {
case PaintOpType::kClipRect: {
const auto& op = static_cast<const ClipRectOp&>(base_op);
str << "ClipRectOp(rect=" << ToString(op.rect)
<< ", op=" << ToString(op.op) << ", antialias=" << op.antialias
<< ")";
str << "rect=" << ToString(op.rect) << ", op=" << ToString(op.op)
<< ", antialias=" << op.antialias;
break;
}
case PaintOpType::kCliprrect: {
case PaintOpType::kClipRRect: {
const auto& op = static_cast<const ClipRRectOp&>(base_op);
str << "ClipRRectOp(rrect=" << ToString(op.rrect)
<< ", op=" << ToString(op.op) << ", antialias=" << op.antialias
<< ")";
str << "rrect=" << ToString(op.rrect) << ", op=" << ToString(op.op)
<< ", antialias=" << op.antialias;
break;
}
case PaintOpType::kConcat: {
const auto& op = static_cast<const ConcatOp&>(base_op);
str << "ConcatOp(matrix=" << ToString(op.matrix) << ")";
str << "matrix=" << ToString(op.matrix);
break;
}
case PaintOpType::kCustomdata: {
case PaintOpType::kCustomData: {
const auto& op = static_cast<const CustomDataOp&>(base_op);
str << "CustomDataOp(id=" << ToString(op.id) << ")";
str << "id=" << ToString(op.id);
break;
}
case PaintOpType::kDrawcolor: {
case PaintOpType::kDrawColor: {
const auto& op = static_cast<const DrawColorOp&>(base_op);
str << "DrawColorOp(color=" << ToString(op.color)
<< ", mode=" << ToString(op.mode) << ")";
str << "color=" << ToString(op.color) << ", mode=" << ToString(op.mode);
break;
}
case PaintOpType::kDrawdrrect: {
case PaintOpType::kDrawDRRect: {
const auto& op = static_cast<const DrawDRRectOp&>(base_op);
str << "DrawDRRectOp(outer=" << ToString(op.outer)
str << "outer=" << ToString(op.outer)
<< ", inner=" << ToString(op.inner)
<< ", flags=" << ToString(op.flags) << ")";
<< ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kDrawimage: {
case PaintOpType::kDrawImage: {
const auto& op = static_cast<const DrawImageOp&>(base_op);
str << "DrawImageOp(image=" << ToString(op.image)
<< ", left=" << ToString(op.left) << ", top=" << ToString(op.top)
<< ", flags=" << ToString(op.flags) << ")";
str << "image=" << ToString(op.image) << ", left=" << ToString(op.left)
<< ", top=" << ToString(op.top) << ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kDrawimagerect: {
case PaintOpType::kDrawImageRect: {
const auto& op = static_cast<const DrawImageRectOp&>(base_op);
str << "DrawImageRectOp(image=" << ToString(op.image)
<< ", src=" << ToString(op.src) << ", dst=" << ToString(op.dst)
str << "image=" << ToString(op.image) << ", src=" << ToString(op.src)
<< ", dst=" << ToString(op.dst)
<< ", constraint=" << ToString(op.constraint)
<< ", flags=" << ToString(op.flags) << ")";
<< ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kDrawirect: {
case PaintOpType::kDrawIRect: {
const auto& op = static_cast<const DrawIRectOp&>(base_op);
str << "DrawIRectOp(rect=" << ToString(op.rect)
<< ", flags=" << ToString(op.flags) << ")";
str << "rect=" << ToString(op.rect) << ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kDrawline: {
case PaintOpType::kDrawLine: {
const auto& op = static_cast<const DrawLineOp&>(base_op);
str << "DrawLineOp(x0=" << ToString(op.x0) << ", y0=" << ToString(op.y0)
str << "x0=" << ToString(op.x0) << ", y0=" << ToString(op.y0)
<< ", x1=" << ToString(op.x1) << ", y1=" << ToString(op.y1)
<< ", flags=" << ToString(op.flags) << ")";
<< ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kDrawoval: {
case PaintOpType::kDrawOval: {
const auto& op = static_cast<const DrawOvalOp&>(base_op);
str << "DrawOvalOp(oval=" << ToString(op.oval)
<< ", flags=" << ToString(op.flags) << ")";
str << "oval=" << ToString(op.oval) << ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kDrawpath: {
case PaintOpType::kDrawPath: {
const auto& op = static_cast<const DrawPathOp&>(base_op);
str << "DrawPathOp(path=" << ToString(op.path)
<< ", flags=" << ToString(op.flags)
<< ", use_cache=" << (op.use_cache == UsePaintCache::kEnabled)
<< ")";
str << "path=" << ToString(op.path) << ", flags=" << ToString(op.flags)
<< ", use_cache=" << (op.use_cache == UsePaintCache::kEnabled);
break;
}
case PaintOpType::kDrawrecord: {
case PaintOpType::kDrawRecord: {
const auto& op = static_cast<const DrawRecordOp&>(base_op);
str << "DrawRecordOp(record=" << ToString(op.record) << ")";
str << "record=" << ToString(op.record);
break;
}
case PaintOpType::kDrawrect: {
case PaintOpType::kDrawRect: {
const auto& op = static_cast<const DrawRectOp&>(base_op);
str << "DrawRectOp(rect=" << ToString(op.rect)
<< ", flags=" << ToString(op.flags) << ")";
str << "rect=" << ToString(op.rect) << ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kDrawrrect: {
case PaintOpType::kDrawRRect: {
const auto& op = static_cast<const DrawRRectOp&>(base_op);
str << "DrawRRectOp(rrect=" << ToString(op.rrect)
<< ", flags=" << ToString(op.flags) << ")";
str << "rrect=" << ToString(op.rrect)
<< ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kDrawskottie: {
case PaintOpType::kDrawSkottie: {
const auto& op = static_cast<const DrawSkottieOp&>(base_op);
str << "DrawSkottieOp("
<< "skottie=" << ToString(op.skottie)
<< ", dst=" << ToString(op.dst) << ", t=" << op.t << ")";
str << "skottie=" << ToString(op.skottie)
<< ", dst=" << ToString(op.dst) << ", t=" << op.t;
break;
}
case PaintOpType::kDrawtextblob: {
case PaintOpType::kDrawTextBlob: {
const auto& op = static_cast<const DrawTextBlobOp&>(base_op);
str << "DrawTextBlobOp(blob=" << ToString(op.blob)
<< ", x=" << ToString(op.x) << ", y=" << ToString(op.y)
<< ", flags=" << ToString(op.flags) << ")";
str << "blob=" << ToString(op.blob) << ", x=" << ToString(op.x)
<< ", y=" << ToString(op.y) << ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kDrawslug: {
case PaintOpType::kDrawSlug: {
const auto& op = static_cast<const DrawSlugOp&>(base_op);
str << "DrawSlugOp(flags=" << ToString(op.flags) << ")";
str << "flags=" << ToString(op.flags);
break;
}
case PaintOpType::kNoop: {
str << "NoopOp()";
case PaintOpType::kNoop:
break;
}
case PaintOpType::kRestore: {
str << "RestoreOp()";
case PaintOpType::kRestore:
break;
}
case PaintOpType::kRotate: {
const auto& op = static_cast<const RotateOp&>(base_op);
str << "RotateOp(degrees=" << ToString(op.degrees) << ")";
str << "degrees=" << ToString(op.degrees);
break;
}
case PaintOpType::kSave: {
str << "SaveOp()";
case PaintOpType::kSave:
break;
}
case PaintOpType::kSavelayer: {
case PaintOpType::kSaveLayer: {
const auto& op = static_cast<const SaveLayerOp&>(base_op);
str << "SaveLayerOp(bounds=" << ToString(op.bounds)
<< ", flags=" << ToString(op.flags) << ")";
str << "bounds=" << ToString(op.bounds)
<< ", flags=" << ToString(op.flags);
break;
}
case PaintOpType::kSavelayeralpha: {
case PaintOpType::kSaveLayerAlpha: {
const auto& op = static_cast<const SaveLayerAlphaOp&>(base_op);
str << "SaveLayerAlphaOp(bounds=" << ToString(op.bounds)
<< ", alpha=" << ToString(op.alpha) << ")";
str << "bounds=" << ToString(op.bounds)
<< ", alpha=" << ToString(op.alpha);
break;
}
case PaintOpType::kScale: {
const auto& op = static_cast<const ScaleOp&>(base_op);
str << "ScaleOp(sx=" << ToString(op.sx) << ", sy=" << ToString(op.sy)
<< ")";
str << "sx=" << ToString(op.sx) << ", sy=" << ToString(op.sy);
break;
}
case PaintOpType::kSetmatrix: {
case PaintOpType::kSetMatrix: {
const auto& op = static_cast<const SetMatrixOp&>(base_op);
str << "SetMatrixOp(matrix=" << ToString(op.matrix) << ")";
str << "matrix=" << ToString(op.matrix);
break;
}
case PaintOpType::kTranslate: {
const auto& op = static_cast<const TranslateOp&>(base_op);
str << "TranslateOp(dx=" << ToString(op.dx)
<< ", dy=" << ToString(op.dy) << ")";
str << "dx=" << ToString(op.dx) << ", dy=" << ToString(op.dy);
break;
}
case PaintOpType::kSetnodeid: {
case PaintOpType::kSetNodeId: {
const auto& op = static_cast<const SetNodeIdOp&>(base_op);
str << "SetNodeIdOp(id=" << op.node_id << ")";
str << "id=" << op.node_id;
break;
}
}
str << ")";
return str.str();
}

@ -60,7 +60,7 @@ class OpConverterAndTracker {
const cc::PaintOp* ConvertAndTrack(const cc::PaintOp& op) {
converted_op_.emplace<absl::monostate>();
switch (op.GetType()) {
case cc::PaintOpType::kDrawtextblob: {
case cc::PaintOpType::kDrawTextBlob: {
const auto& text_blob_op = static_cast<const cc::DrawTextBlobOp&>(op);
tracker_->AddGlyphs(text_blob_op.blob.get());
break;
@ -74,7 +74,7 @@ class OpConverterAndTracker {
// Delete the op. We no longer need it.
return nullptr;
}
case cc::PaintOpType::kCustomdata: {
case cc::PaintOpType::kCustomData: {
const auto& custom_op = static_cast<const cc::CustomDataOp&>(op);
tracker_->TransformClipForFrame(custom_op.id);
break;
@ -83,11 +83,11 @@ class OpConverterAndTracker {
tracker_->Save();
break;
}
case cc::PaintOpType::kSavelayer: {
case cc::PaintOpType::kSaveLayer: {
tracker_->Save();
break;
}
case cc::PaintOpType::kSavelayeralpha: {
case cc::PaintOpType::kSaveLayerAlpha: {
tracker_->Save();
break;
}
@ -95,7 +95,7 @@ class OpConverterAndTracker {
tracker_->Restore();
break;
}
case cc::PaintOpType::kSetmatrix: {
case cc::PaintOpType::kSetMatrix: {
const auto& matrix_op = static_cast<const cc::SetMatrixOp&>(op);
tracker_->SetMatrix(matrix_op.matrix.asM33());
break;
@ -120,7 +120,7 @@ class OpConverterAndTracker {
tracker_->Translate(translate_op.dx, translate_op.dy);
break;
}
case cc::PaintOpType::kDrawimage: {
case cc::PaintOpType::kDrawImage: {
const auto& image_op = static_cast<const cc::DrawImageOp&>(op);
if (image_op.image.IsTextureBacked()) {
converted_op_.emplace<cc::DrawImageOp>(
@ -130,7 +130,7 @@ class OpConverterAndTracker {
}
break;
}
case cc::PaintOpType::kDrawimagerect: {
case cc::PaintOpType::kDrawImageRect: {
const auto& image_op = static_cast<const cc::DrawImageRectOp&>(op);
if (image_op.image.IsTextureBacked()) {
converted_op_.emplace<cc::DrawImageRectOp>(

@ -13593,14 +13593,14 @@ void RecursiveCollectTextRunDOMNodeIds(
DOMNodeId dom_node_id,
std::vector<TextRunDOMNodeIdInfo>* text_runs) {
for (const cc::PaintOp& op : paint_record) {
if (op.GetType() == cc::PaintOpType::kDrawrecord) {
if (op.GetType() == cc::PaintOpType::kDrawRecord) {
const auto& draw_record_op = static_cast<const cc::DrawRecordOp&>(op);
RecursiveCollectTextRunDOMNodeIds(draw_record_op.record, dom_node_id,
text_runs);
} else if (op.GetType() == cc::PaintOpType::kSetnodeid) {
} else if (op.GetType() == cc::PaintOpType::kSetNodeId) {
const auto& set_node_id_op = static_cast<const cc::SetNodeIdOp&>(op);
dom_node_id = set_node_id_op.node_id;
} else if (op.GetType() == cc::PaintOpType::kDrawtextblob) {
} else if (op.GetType() == cc::PaintOpType::kDrawTextBlob) {
const auto& draw_text_op = static_cast<const cc::DrawTextBlobOp&>(op);
SkTextBlob::Iter iter(*draw_text_op.blob);
SkTextBlob::Iter::Run run;

@ -279,11 +279,11 @@ size_t CountDrawImagesWithConstraint(const cc::PaintRecord& record,
SkCanvas::SrcRectConstraint constraint) {
size_t count = 0;
for (const cc::PaintOp& op : record) {
if (op.GetType() == cc::PaintOpType::kDrawimagerect) {
if (op.GetType() == cc::PaintOpType::kDrawImageRect) {
const auto& image_op = static_cast<const cc::DrawImageRectOp&>(op);
if (image_op.constraint == constraint)
++count;
} else if (op.GetType() == cc::PaintOpType::kDrawrecord) {
} else if (op.GetType() == cc::PaintOpType::kDrawRecord) {
const auto& record_op = static_cast<const cc::DrawRecordOp&>(op);
count += CountDrawImagesWithConstraint(record_op.record, constraint);
}

@ -15,10 +15,10 @@ namespace {
const cc::DrawImageRectOp* FirstDrawImageRectOp(const cc::PaintRecord& record) {
for (const cc::PaintOp& op : record) {
if (op.GetType() == cc::PaintOpType::kDrawimagerect) {
if (op.GetType() == cc::PaintOpType::kDrawImageRect) {
const auto& image_op = static_cast<const cc::DrawImageRectOp&>(op);
return &image_op;
} else if (op.GetType() == cc::PaintOpType::kDrawrecord) {
} else if (op.GetType() == cc::PaintOpType::kDrawRecord) {
const auto& record_op = static_cast<const cc::DrawRecordOp&>(op);
if (const auto* image_op = FirstDrawImageRectOp(record_op.record)) {
return image_op;

@ -27,7 +27,7 @@ void ExtractLinks(const PaintRecord& record, std::vector<GURL>* links) {
links->push_back(GURL(
std::string(reinterpret_cast<const char*>(annotate_op.data->data()),
annotate_op.data->size())));
} else if (op.GetType() == cc::PaintOpType::kDrawrecord) {
} else if (op.GetType() == cc::PaintOpType::kDrawRecord) {
const auto& record_op = static_cast<const cc::DrawRecordOp&>(op);
ExtractLinks(record_op.record, links);
}

@ -187,7 +187,7 @@ TEST_F(TextPainterBaseTest, CachedTextBlob) {
ASSERT_TRUE(item);
auto* op = static_cast<const cc::DrawTextBlobOp*>(
&item->GetPaintRecord().GetFirstOp());
ASSERT_EQ(cc::PaintOpType::kDrawtextblob, op->GetType());
ASSERT_EQ(cc::PaintOpType::kDrawTextBlob, op->GetType());
cc::PaintFlags flags = op->flags;
sk_sp<SkTextBlob> blob = op->blob;
@ -199,7 +199,7 @@ TEST_F(TextPainterBaseTest, CachedTextBlob) {
ASSERT_TRUE(item);
op = static_cast<const cc::DrawTextBlobOp*>(
&item->GetPaintRecord().GetFirstOp());
ASSERT_EQ(cc::PaintOpType::kDrawtextblob, op->GetType());
ASSERT_EQ(cc::PaintOpType::kDrawTextBlob, op->GetType());
EXPECT_FALSE(flags.EqualsForTesting(op->flags));
flags = op->flags;
EXPECT_EQ(blob, op->blob);
@ -213,7 +213,7 @@ TEST_F(TextPainterBaseTest, CachedTextBlob) {
ASSERT_TRUE(item);
op = static_cast<const cc::DrawTextBlobOp*>(
&item->GetPaintRecord().GetFirstOp());
ASSERT_EQ(cc::PaintOpType::kDrawtextblob, op->GetType());
ASSERT_EQ(cc::PaintOpType::kDrawTextBlob, op->GetType());
EXPECT_TRUE(flags.EqualsForTesting(op->flags));
EXPECT_NE(blob, op->blob);
blob = op->blob;
@ -226,7 +226,7 @@ TEST_F(TextPainterBaseTest, CachedTextBlob) {
ASSERT_TRUE(item);
op = static_cast<const cc::DrawTextBlobOp*>(
&item->GetPaintRecord().GetFirstOp());
ASSERT_EQ(cc::PaintOpType::kDrawtextblob, op->GetType());
ASSERT_EQ(cc::PaintOpType::kDrawTextBlob, op->GetType());
EXPECT_TRUE(flags.EqualsForTesting(op->flags));
EXPECT_NE(blob, op->blob);
@ -238,7 +238,7 @@ TEST_F(TextPainterBaseTest, CachedTextBlob) {
ASSERT_TRUE(item);
op = static_cast<const cc::DrawTextBlobOp*>(
&item->GetPaintRecord().GetFirstOp());
ASSERT_EQ(cc::PaintOpType::kDrawtextblob, op->GetType());
ASSERT_EQ(cc::PaintOpType::kDrawTextBlob, op->GetType());
EXPECT_FALSE(flags.EqualsForTesting(op->flags));
}

@ -31,7 +31,7 @@ void ExtractLinks(const PaintRecord& record,
reinterpret_cast<const char*>(annotate_op.data->data()),
annotate_op.data->size())),
annotate_op.rect));
} else if (op.GetType() == cc::PaintOpType::kDrawrecord) {
} else if (op.GetType() == cc::PaintOpType::kDrawRecord) {
const auto& record_op = static_cast<const cc::DrawRecordOp&>(op);
ExtractLinks(record_op.record, links);
}
@ -41,17 +41,17 @@ void ExtractLinks(const PaintRecord& record,
size_t CountImagesOfType(const PaintRecord& record, cc::ImageType image_type) {
size_t count = 0;
for (const cc::PaintOp& op : record) {
if (op.GetType() == cc::PaintOpType::kDrawimage) {
if (op.GetType() == cc::PaintOpType::kDrawImage) {
const auto& image_op = static_cast<const cc::DrawImageOp&>(op);
if (image_op.image.GetImageHeaderMetadata()->image_type == image_type) {
++count;
}
} else if (op.GetType() == cc::PaintOpType::kDrawimagerect) {
} else if (op.GetType() == cc::PaintOpType::kDrawImageRect) {
const auto& image_op = static_cast<const cc::DrawImageRectOp&>(op);
if (image_op.image.GetImageHeaderMetadata()->image_type == image_type) {
++count;
}
} else if (op.GetType() == cc::PaintOpType::kDrawrecord) {
} else if (op.GetType() == cc::PaintOpType::kDrawRecord) {
const auto& record_op = static_cast<const cc::DrawRecordOp&>(op);
count += CountImagesOfType(record_op.record, image_type);
}

@ -506,7 +506,7 @@ size_t CountPaintOpType(const cc::PaintRecord& record, cc::PaintOpType type) {
}
if (op.GetType() == type) {
++count;
} else if (op.GetType() == cc::PaintOpType::kDrawrecord) {
} else if (op.GetType() == cc::PaintOpType::kDrawRecord) {
const auto& record_op = static_cast<const cc::DrawRecordOp&>(op);
count += CountPaintOpType(record_op.record, type);
}
@ -545,7 +545,7 @@ TEST_F(SVGImageSimTest, SpriteSheetCulling) {
// Initially, only the green circle should be recorded.
PaintRecord record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the height so one green circle and three blue circles are visible,
// and ensure four circles are recorded.
@ -553,7 +553,7 @@ TEST_F(SVGImageSimTest, SpriteSheetCulling) {
div->setAttribute(html_names::kStyleAttr, AtomicString("height: 200px;"));
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the background position so only the three blue circles are visible,
// and ensure three circles are recorded.
@ -562,7 +562,7 @@ TEST_F(SVGImageSimTest, SpriteSheetCulling) {
AtomicString("height: 200px; background-position-y: -200px;"));
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(3U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(3U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
}
// Tests the culling of invisible sprites from a larger sprite sheet where the
@ -597,8 +597,8 @@ TEST_F(SVGImageSimTest, SpriteSheetCullingBorderRadius) {
// Initially, only the green circle should be recorded.
PaintRecord record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawrrect));
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawRRect));
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the height so one green circle and three blue circles are visible,
// and ensure four circles are recorded.
@ -606,8 +606,8 @@ TEST_F(SVGImageSimTest, SpriteSheetCullingBorderRadius) {
div->setAttribute(html_names::kStyleAttr, AtomicString("height: 200px;"));
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawrrect));
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawRRect));
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
}
// Similar to `SpriteSheetCulling` but using a full-sized sprite sheet <img>
@ -649,7 +649,7 @@ TEST_F(SVGImageSimTest, ClippedAbsoluteImageSpriteSheetCulling) {
// Initially, only the green circle should be recorded.
PaintRecord record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the div's height so one green circle and three blue circles are
// visible, and ensure four circles are recorded.
@ -658,7 +658,7 @@ TEST_F(SVGImageSimTest, ClippedAbsoluteImageSpriteSheetCulling) {
AtomicString("height: 200px;"));
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the image's position so only the three blue circles are visible,
// and ensure three circles are recorded.
@ -667,7 +667,7 @@ TEST_F(SVGImageSimTest, ClippedAbsoluteImageSpriteSheetCulling) {
AtomicString("top: -200px;"));
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(3U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(3U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
}
// Similar to `SpriteSheetCulling` but using a full-sized sprite sheet <img>
@ -708,7 +708,7 @@ TEST_F(SVGImageSimTest, ClippedStaticImageSpriteSheetCulling) {
// Initially, only the green circle should be recorded.
PaintRecord record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the div's height so one green circle and three blue circles are
// visible, and ensure four circles are recorded.
@ -717,7 +717,7 @@ TEST_F(SVGImageSimTest, ClippedStaticImageSpriteSheetCulling) {
AtomicString("height: 200px;"));
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the image's position so only the three blue circles are visible,
// and ensure three circles are recorded.
@ -726,7 +726,7 @@ TEST_F(SVGImageSimTest, ClippedStaticImageSpriteSheetCulling) {
AtomicString("margin-top: -200px;"));
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(3U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(3U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the div's position to be fractional and ensure only three blue
// circles are still recorded.
@ -734,7 +734,7 @@ TEST_F(SVGImageSimTest, ClippedStaticImageSpriteSheetCulling) {
AtomicString("margin-left: 0.5px; height: 200px;"));
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(3U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(3U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
}
// Similar to `SpriteSheetCulling` but using a regular scrolling interest rect
@ -778,7 +778,7 @@ TEST_F(SVGImageSimTest, InterestRectDoesNotCullImageSpriteSheet) {
// apply because the scrolling interest rect is not for a specific sprite
// within the image, and all circles should be recorded.
PaintRecord record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the div's width and height so that it creates a cull rect that clips
// to just a single circle, and ensure just one circle is recorded.
@ -787,7 +787,7 @@ TEST_F(SVGImageSimTest, InterestRectDoesNotCullImageSpriteSheet) {
AtomicString("width: 100px; height: 200px;"));
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
// Adjust the div's width and height so that it no longer creates a cull rect
// that clips to a sprite within the image, so the optimization in
@ -796,7 +796,7 @@ TEST_F(SVGImageSimTest, InterestRectDoesNotCullImageSpriteSheet) {
div_element->removeAttribute(html_names::kStyleAttr);
Compositor().BeginFrame();
record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(4U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
}
// Tests the culling of non-drawing items from a larger sprite sheet.
@ -844,7 +844,7 @@ TEST_F(SVGImageSimTest, SpriteSheetNonDrawingCulling) {
// translation paint ops from the <g> elements used to position the red
// circles.
PaintRecord record = GetDocument().View()->GetPaintRecord();
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawoval));
EXPECT_EQ(1U, CountPaintOpType(record, cc::PaintOpType::kDrawOval));
EXPECT_EQ(0U, CountPaintOpType(record, cc::PaintOpType::kTranslate));
}

@ -135,13 +135,13 @@ DrawingDisplayItem::BackgroundColorInfo DrawingDisplayItem::BackgroundColor()
}
SkRect item_rect;
switch (op.GetType()) {
case cc::PaintOpType::kDrawrect:
case cc::PaintOpType::kDrawRect:
item_rect = static_cast<const cc::DrawRectOp&>(op).rect;
break;
case cc::PaintOpType::kDrawirect:
case cc::PaintOpType::kDrawIRect:
item_rect = SkRect::Make(static_cast<const cc::DrawIRectOp&>(op).rect);
break;
case cc::PaintOpType::kDrawrrect:
case cc::PaintOpType::kDrawRRect:
item_rect = static_cast<const cc::DrawRRectOp&>(op).rrect.rect();
may_be_solid_color = false;
break;
@ -189,11 +189,11 @@ gfx::Rect DrawingDisplayItem::CalculateRectKnownToBeOpaqueForRecord(
break;
// Deal with the common pattern of clipped bleed avoiding images like:
// kSave, kCliprect, kDraw..., kRestore.
// kSave, kClipRect, kDraw..., kRestore.
if (op.GetType() == cc::PaintOpType::kSave) {
continue;
}
if (op.GetType() == cc::PaintOpType::kCliprect) {
if (op.GetType() == cc::PaintOpType::kClipRect) {
clip_rect.Intersect(gfx::ToEnclosedRect(
gfx::SkRectToRectF(static_cast<const cc::ClipRectOp&>(op).rect)));
continue;
@ -203,7 +203,7 @@ gfx::Rect DrawingDisplayItem::CalculateRectKnownToBeOpaqueForRecord(
break;
gfx::Rect op_opaque_rect;
if (op.GetType() == cc::PaintOpType::kDrawrecord) {
if (op.GetType() == cc::PaintOpType::kDrawRecord) {
op_opaque_rect = CalculateRectKnownToBeOpaqueForRecord(
static_cast<const cc::DrawRecordOp&>(op).record);
} else {
@ -218,11 +218,11 @@ gfx::Rect DrawingDisplayItem::CalculateRectKnownToBeOpaqueForRecord(
}
switch (op.GetType()) {
case cc::PaintOpType::kDrawrect:
case cc::PaintOpType::kDrawRect:
op_opaque_rect = gfx::ToEnclosedRect(
gfx::SkRectToRectF(static_cast<const cc::DrawRectOp&>(op).rect));
break;
case cc::PaintOpType::kDrawrrect: {
case cc::PaintOpType::kDrawRRect: {
const SkRRect& rrect = static_cast<const cc::DrawRRectOp&>(op).rrect;
SkVector top_left = rrect.radii(SkRRect::kUpperLeft_Corner);
SkVector top_right = rrect.radii(SkRRect::kUpperRight_Corner);
@ -243,11 +243,11 @@ gfx::Rect DrawingDisplayItem::CalculateRectKnownToBeOpaqueForRecord(
op_opaque_rect = ToEnclosedRect(contained);
break;
}
case cc::PaintOpType::kDrawirect:
case cc::PaintOpType::kDrawIRect:
op_opaque_rect =
gfx::SkIRectToRect(static_cast<const cc::DrawIRectOp&>(op).rect);
break;
case cc::PaintOpType::kDrawimage: {
case cc::PaintOpType::kDrawImage: {
const auto& draw_image_op = static_cast<const cc::DrawImageOp&>(op);
const auto& image = draw_image_op.image;
if (!image.IsOpaque())
@ -256,7 +256,7 @@ gfx::Rect DrawingDisplayItem::CalculateRectKnownToBeOpaqueForRecord(
image.width(), image.height());
break;
}
case cc::PaintOpType::kDrawimagerect: {
case cc::PaintOpType::kDrawImageRect: {
const auto& draw_image_rect_op =
static_cast<const cc::DrawImageRectOp&>(op);
const auto& image = draw_image_rect_op.image;
@ -296,19 +296,19 @@ gfx::Rect DrawingDisplayItem::TightenVisualRect(const gfx::Rect& visual_rect,
gfx::Rect item_rect;
switch (op.GetType()) {
case cc::PaintOpType::kDrawrect:
case cc::PaintOpType::kDrawRect:
item_rect = gfx::ToEnclosingRect(
gfx::SkRectToRectF(static_cast<const cc::DrawRectOp&>(op).rect));
break;
case cc::PaintOpType::kDrawirect:
case cc::PaintOpType::kDrawIRect:
item_rect =
gfx::SkIRectToRect(static_cast<const cc::DrawIRectOp&>(op).rect);
break;
case cc::PaintOpType::kDrawrrect:
case cc::PaintOpType::kDrawRRect:
item_rect = gfx::ToEnclosingRect(gfx::SkRectToRectF(
static_cast<const cc::DrawRRectOp&>(op).rrect.rect()));
break;
// TODO(pdr): Support image PaintOpTypes such as kDrawimage{rect}.
// TODO(pdr): Support image PaintOpTypes such as kDrawImage{rect}.
// TODO(pdr): Consider checking PaintOpType::kDrawtextblob too.
default:
return visual_rect;

@ -214,7 +214,7 @@ sk_sp<SkTextBlob> PaintController::CachedTextBlob() const {
return nullptr;
}
const cc::PaintOp& op = record.GetFirstOp();
if (op.GetType() != cc::PaintOpType::kDrawtextblob) {
if (op.GetType() != cc::PaintOpType::kDrawTextBlob) {
return nullptr;
}
return static_cast<const cc::DrawTextBlobOp&>(op).blob;

@ -34,7 +34,7 @@ const T* FindPaintOp(const cc::PaintRecord& paint_record,
if (op.GetType() == paint_op_type)
return static_cast<const T*>(&op);
if (op.GetType() == cc::PaintOpType::kDrawrecord) {
if (op.GetType() == cc::PaintOpType::kDrawRecord) {
const T* record_op_result = FindPaintOp<T>(
static_cast<const cc::DrawRecordOp&>(op).record, paint_op_type);
if (record_op_result)