From 42ddcd49060f64be57f00e651650154f9b4f3a08 Mon Sep 17 00:00:00 2001 From: mtklein Date: Fri, 21 Nov 2014 08:48:35 -0800 Subject: [PATCH] All the small packing tweaks mentioned in the bug. BUG=skia:3144 Review URL: https://codereview.chromium.org/748063002 --- src/core/SkRecordDraw.cpp | 9 ++++++++- src/core/SkRecorder.cpp | 16 +++++++++++----- src/core/SkRecords.h | 18 +++++++++++------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp index aa2593f..7e35d8a 100644 --- a/src/core/SkRecordDraw.cpp +++ b/src/core/SkRecordDraw.cpp @@ -103,7 +103,11 @@ 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)); DRAW(DrawBitmapRectToRect, - drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, r.flags)); + drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, + SkCanvas::kNone_DrawBitmapRectFlag)); +DRAW(DrawBitmapRectToRectBleed, + drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, + SkCanvas::kBleed_DrawBitmapRectFlag)); DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint)); DRAW(DrawImage, drawImage(r.image, r.left, r.top, r.paint)); DRAW(DrawImageRect, drawImageRect(r.image, r.src, r.dst, r.paint)); @@ -415,6 +419,9 @@ private: Bounds bounds(const DrawBitmapRectToRect& op) const { return this->adjustAndMap(op.dst, op.paint); } + Bounds bounds(const DrawBitmapRectToRectBleed& op) const { + return this->adjustAndMap(op.dst, op.paint); + } Bounds bounds(const DrawBitmapNine& op) const { return this->adjustAndMap(op.dst, op.paint); } diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp index 33d89d9..3252e59 100644 --- a/src/core/SkRecorder.cpp +++ b/src/core/SkRecorder.cpp @@ -152,7 +152,7 @@ void SkRecorder::drawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint) { - APPEND(DrawPoints, delay_copy(paint), mode, count, this->copy(pts, count)); + APPEND(DrawPoints, delay_copy(paint), mode, SkToUInt(count), this->copy(pts, count)); } void SkRecorder::drawRect(const SkRect& rect, const SkPaint& paint) { @@ -192,8 +192,14 @@ void SkRecorder::drawBitmapRectToRect(const SkBitmap& bitmap, const SkRect& dst, const SkPaint* paint, DrawBitmapRectFlags flags) { + if (kBleed_DrawBitmapRectFlag == flags) { + APPEND(DrawBitmapRectToRectBleed, + this->copy(paint), delay_copy(bitmap), this->copy(src), dst); + return; + } + SkASSERT(kNone_DrawBitmapRectFlag == flags); APPEND(DrawBitmapRectToRect, - this->copy(paint), delay_copy(bitmap), this->copy(src), dst, flags); + this->copy(paint), delay_copy(bitmap), this->copy(src), dst); } void SkRecorder::drawBitmapMatrix(const SkBitmap& bitmap, @@ -246,9 +252,9 @@ void SkRecorder::onDrawPosTextH(const void* text, size_t byteLength, APPEND(DrawPosTextH, delay_copy(paint), this->copy((const char*)text, byteLength), - byteLength, - this->copy(xpos, points), - constY); + SkToUInt(byteLength), + constY, + this->copy(xpos, points)); } void SkRecorder::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, diff --git a/src/core/SkRecords.h b/src/core/SkRecords.h index da0c884..d6308a9 100644 --- a/src/core/SkRecords.h +++ b/src/core/SkRecords.h @@ -45,6 +45,7 @@ namespace SkRecords { M(DrawBitmapMatrix) \ M(DrawBitmapNine) \ M(DrawBitmapRectToRect) \ + M(DrawBitmapRectToRectBleed) \ M(DrawDrawable) \ M(DrawImage) \ M(DrawImageRect) \ @@ -239,11 +240,14 @@ RECORD4(DrawBitmapNine, Optional, paint, ImmutableBitmap, bitmap, SkIRect, center, SkRect, dst); -RECORD5(DrawBitmapRectToRect, Optional, paint, +RECORD4(DrawBitmapRectToRect, Optional, paint, ImmutableBitmap, bitmap, Optional, src, - SkRect, dst, - SkCanvas::DrawBitmapRectFlags, flags); + SkRect, dst); +RECORD4(DrawBitmapRectToRectBleed, Optional, paint, + ImmutableBitmap, bitmap, + Optional, src, + SkRect, dst); RECORD3(DrawDRRect, SkPaint, paint, SkRRect, outer, SkRRect, inner); RECORD2(DrawDrawable, SkRect, worstCaseBounds, int32_t, index); RECORD4(DrawImage, Optional, paint, @@ -260,16 +264,16 @@ RECORD2(DrawPath, SkPaint, paint, SkPath, path); RECORD3(DrawPicture, Optional, paint, RefBox, picture, Optional, matrix); -RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, size_t, count, SkPoint*, pts); +RECORD4(DrawPoints, SkPaint, paint, SkCanvas::PointMode, mode, unsigned, count, SkPoint*, pts); RECORD4(DrawPosText, SkPaint, paint, PODArray, text, size_t, byteLength, PODArray, pos); RECORD5(DrawPosTextH, SkPaint, paint, PODArray, text, - size_t, byteLength, - PODArray, xpos, - SkScalar, y); + unsigned, byteLength, + SkScalar, y, + PODArray, xpos); RECORD2(DrawRRect, SkPaint, paint, SkRRect, rrect); RECORD2(DrawRect, SkPaint, paint, SkRect, rect); RECORD4(DrawSprite, Optional, paint, ImmutableBitmap, bitmap, int, left, int, top); -- 2.7.4