зеркало из https://github.com/mozilla/moz-skia.git
Support comment groups in SkRecord.
This should fix the failing paint-command-log-nodes.html layout test. BUG=406425 R=tomhudson@chromium.org Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/501533003
This commit is contained in:
Родитель
3e42a46385
Коммит
5f0e82204e
|
@ -71,6 +71,10 @@ DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA));
|
|||
DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA));
|
||||
DRAW(ClipRegion, clipRegion(r.region, r.op));
|
||||
|
||||
DRAW(BeginCommentGroup, beginCommentGroup(r.description));
|
||||
DRAW(AddComment, addComment(r.key, r.value));
|
||||
DRAW(EndCommentGroup, endCommentGroup());
|
||||
|
||||
DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint));
|
||||
DRAW(DrawBitmapMatrix, drawBitmapMatrix(shallow_copy(r.bitmap), r.matrix, r.paint));
|
||||
DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.paint));
|
||||
|
|
|
@ -82,6 +82,13 @@ char* SkRecorder::copy(const char src[], size_t count) {
|
|||
return dst;
|
||||
}
|
||||
|
||||
// As above, assuming and copying a terminating \0.
|
||||
template <>
|
||||
char* SkRecorder::copy(const char* src) {
|
||||
return this->copy(src, strlen(src)+1);
|
||||
}
|
||||
|
||||
|
||||
void SkRecorder::clear(SkColor color) {
|
||||
APPEND(Clear, color);
|
||||
}
|
||||
|
@ -276,3 +283,15 @@ void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
|
|||
INHERITED(onClipRegion, deviceRgn, op);
|
||||
APPEND(ClipRegion, this->devBounds(), delay_copy(deviceRgn), op);
|
||||
}
|
||||
|
||||
void SkRecorder::beginCommentGroup(const char* description) {
|
||||
APPEND(BeginCommentGroup, this->copy(description));
|
||||
}
|
||||
|
||||
void SkRecorder::addComment(const char* key, const char* value) {
|
||||
APPEND(AddComment, this->copy(key), this->copy(value));
|
||||
}
|
||||
|
||||
void SkRecorder::endCommentGroup() {
|
||||
APPEND(EndCommentGroup);
|
||||
}
|
||||
|
|
|
@ -107,6 +107,10 @@ public:
|
|||
void onPushCull(const SkRect& cullRect) SK_OVERRIDE;
|
||||
void onPopCull() SK_OVERRIDE;
|
||||
|
||||
void beginCommentGroup(const char*) SK_OVERRIDE;
|
||||
void addComment(const char*, const char*) SK_OVERRIDE;
|
||||
void endCommentGroup() SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
T* copy(const T*);
|
||||
|
|
|
@ -37,6 +37,9 @@ namespace SkRecords {
|
|||
M(ClipRect) \
|
||||
M(ClipRegion) \
|
||||
M(Clear) \
|
||||
M(BeginCommentGroup) \
|
||||
M(AddComment) \
|
||||
M(EndCommentGroup) \
|
||||
M(DrawBitmap) \
|
||||
M(DrawBitmapMatrix) \
|
||||
M(DrawBitmapNine) \
|
||||
|
@ -211,6 +214,11 @@ RECORD4(ClipRect, SkIRect, devBounds, SkRect, rect, SkRegion::Op, op, bool
|
|||
RECORD3(ClipRegion, SkIRect, devBounds, SkRegion, region, SkRegion::Op, op);
|
||||
|
||||
RECORD1(Clear, SkColor, color);
|
||||
|
||||
RECORD1(BeginCommentGroup, PODArray<char>, description);
|
||||
RECORD2(AddComment, PODArray<char>, key, PODArray<char>, value);
|
||||
RECORD0(EndCommentGroup);
|
||||
|
||||
// While not strictly required, if you have an SkPaint, it's fastest to put it first.
|
||||
RECORD4(DrawBitmap, Optional<SkPaint>, paint,
|
||||
ImmutableBitmap, bitmap,
|
||||
|
|
|
@ -49,6 +49,25 @@ DEF_TEST(Recorder, r) {
|
|||
REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>());
|
||||
}
|
||||
|
||||
// All of Skia will work fine without support for comment groups, but
|
||||
// Chrome's inspector can break. This serves as a simple regression test.
|
||||
DEF_TEST(Recorder_CommentGroups, r) {
|
||||
SkRecord record;
|
||||
SkRecorder recorder(&record, 1920, 1080);
|
||||
|
||||
recorder.beginCommentGroup("test");
|
||||
recorder.addComment("foo", "bar");
|
||||
recorder.addComment("baz", "quux");
|
||||
recorder.endCommentGroup();
|
||||
|
||||
Tally tally;
|
||||
tally.apply(record);
|
||||
|
||||
REPORTER_ASSERT(r, 1 == tally.count<SkRecords::BeginCommentGroup>());
|
||||
REPORTER_ASSERT(r, 2 == tally.count<SkRecords::AddComment>());
|
||||
REPORTER_ASSERT(r, 1 == tally.count<SkRecords::EndCommentGroup>());
|
||||
}
|
||||
|
||||
// Regression test for leaking refs held by optional arguments.
|
||||
DEF_TEST(Recorder_RefLeaking, r) {
|
||||
// We use SaveLayer to test:
|
||||
|
|
Загрузка…
Ссылка в новой задаче