Pulling these out of other reviews so avoid code review clutter.
R=jvanverth@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/192783002 git-svn-id: http://skia.googlecode.com/svn/trunk@13724 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
dd58422b4b
commit
d7e0fbef5d
@ -111,7 +111,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SkBitmapHeap(ExternalStorage* externalStorage, int32_t heapSize = UNLIMITED_SIZE);
|
SkBitmapHeap(ExternalStorage* externalStorage, int32_t heapSize = UNLIMITED_SIZE);
|
||||||
|
|
||||||
~SkBitmapHeap();
|
virtual ~SkBitmapHeap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a shallow copy of all bitmaps currently in the heap and returns them as an array. The
|
* Makes a shallow copy of all bitmaps currently in the heap and returns them as an array. The
|
||||||
|
@ -505,7 +505,9 @@ private:
|
|||||||
const SkFlatData& scratch = this->resetScratch(element, this->count()+1);
|
const SkFlatData& scratch = this->resetScratch(element, this->count()+1);
|
||||||
|
|
||||||
SkFlatData* candidate = fHash.find(scratch);
|
SkFlatData* candidate = fHash.find(scratch);
|
||||||
if (candidate != NULL) return candidate;
|
if (candidate != NULL) {
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
|
||||||
SkFlatData* detached = this->detachScratch();
|
SkFlatData* detached = this->detachScratch();
|
||||||
fHash.add(detached);
|
fHash.add(detached);
|
||||||
|
@ -965,14 +965,14 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DRAW_BITMAP: {
|
case DRAW_BITMAP: {
|
||||||
const SkPaint* paint = getPaint(reader);
|
const SkPaint* paint = this->getPaint(reader);
|
||||||
const SkBitmap& bitmap = getBitmap(reader);
|
const SkBitmap& bitmap = this->getBitmap(reader);
|
||||||
const SkPoint& loc = reader.skipT<SkPoint>();
|
const SkPoint& loc = reader.skipT<SkPoint>();
|
||||||
canvas.drawBitmap(bitmap, loc.fX, loc.fY, paint);
|
canvas.drawBitmap(bitmap, loc.fX, loc.fY, paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_BITMAP_RECT_TO_RECT: {
|
case DRAW_BITMAP_RECT_TO_RECT: {
|
||||||
const SkPaint* paint = getPaint(reader);
|
const SkPaint* paint = this->getPaint(reader);
|
||||||
const SkBitmap& bitmap = getBitmap(reader);
|
const SkBitmap& bitmap = this->getBitmap(reader);
|
||||||
const SkRect* src = this->getRectPtr(reader); // may be null
|
const SkRect* src = this->getRectPtr(reader); // may be null
|
||||||
const SkRect& dst = reader.skipT<SkRect>(); // required
|
const SkRect& dst = reader.skipT<SkRect>(); // required
|
||||||
SkCanvas::DrawBitmapRectFlags flags;
|
SkCanvas::DrawBitmapRectFlags flags;
|
||||||
@ -980,15 +980,15 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
|||||||
canvas.drawBitmapRectToRect(bitmap, src, dst, paint, flags);
|
canvas.drawBitmapRectToRect(bitmap, src, dst, paint, flags);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_BITMAP_MATRIX: {
|
case DRAW_BITMAP_MATRIX: {
|
||||||
const SkPaint* paint = getPaint(reader);
|
const SkPaint* paint = this->getPaint(reader);
|
||||||
const SkBitmap& bitmap = getBitmap(reader);
|
const SkBitmap& bitmap = this->getBitmap(reader);
|
||||||
SkMatrix matrix;
|
SkMatrix matrix;
|
||||||
this->getMatrix(reader, &matrix);
|
this->getMatrix(reader, &matrix);
|
||||||
canvas.drawBitmapMatrix(bitmap, matrix, paint);
|
canvas.drawBitmapMatrix(bitmap, matrix, paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_BITMAP_NINE: {
|
case DRAW_BITMAP_NINE: {
|
||||||
const SkPaint* paint = getPaint(reader);
|
const SkPaint* paint = this->getPaint(reader);
|
||||||
const SkBitmap& bitmap = getBitmap(reader);
|
const SkBitmap& bitmap = this->getBitmap(reader);
|
||||||
const SkIRect& src = reader.skipT<SkIRect>();
|
const SkIRect& src = reader.skipT<SkIRect>();
|
||||||
const SkRect& dst = reader.skipT<SkRect>();
|
const SkRect& dst = reader.skipT<SkRect>();
|
||||||
canvas.drawBitmapNine(bitmap, src, dst, paint);
|
canvas.drawBitmapNine(bitmap, src, dst, paint);
|
||||||
@ -1002,7 +1002,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
|||||||
// skip handles padding the read out to a multiple of 4
|
// skip handles padding the read out to a multiple of 4
|
||||||
} break;
|
} break;
|
||||||
case DRAW_DRRECT: {
|
case DRAW_DRRECT: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
SkRRect outer, inner;
|
SkRRect outer, inner;
|
||||||
reader.readRRect(&outer);
|
reader.readRRect(&outer);
|
||||||
reader.readRRect(&inner);
|
reader.readRRect(&inner);
|
||||||
@ -1021,35 +1021,35 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
|||||||
canvas.endCommentGroup();
|
canvas.endCommentGroup();
|
||||||
} break;
|
} break;
|
||||||
case DRAW_OVAL: {
|
case DRAW_OVAL: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
canvas.drawOval(reader.skipT<SkRect>(), paint);
|
canvas.drawOval(reader.skipT<SkRect>(), paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_PAINT:
|
case DRAW_PAINT:
|
||||||
canvas.drawPaint(*getPaint(reader));
|
canvas.drawPaint(*this->getPaint(reader));
|
||||||
break;
|
break;
|
||||||
case DRAW_PATH: {
|
case DRAW_PATH: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
canvas.drawPath(getPath(reader), paint);
|
canvas.drawPath(getPath(reader), paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_PICTURE:
|
case DRAW_PICTURE:
|
||||||
canvas.drawPicture(getPicture(reader));
|
canvas.drawPicture(this->getPicture(reader));
|
||||||
break;
|
break;
|
||||||
case DRAW_POINTS: {
|
case DRAW_POINTS: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
SkCanvas::PointMode mode = (SkCanvas::PointMode)reader.readInt();
|
SkCanvas::PointMode mode = (SkCanvas::PointMode)reader.readInt();
|
||||||
size_t count = reader.readInt();
|
size_t count = reader.readInt();
|
||||||
const SkPoint* pts = (const SkPoint*)reader.skip(sizeof(SkPoint) * count);
|
const SkPoint* pts = (const SkPoint*)reader.skip(sizeof(SkPoint) * count);
|
||||||
canvas.drawPoints(mode, count, pts, paint);
|
canvas.drawPoints(mode, count, pts, paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_POS_TEXT: {
|
case DRAW_POS_TEXT: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
getText(reader, &text);
|
getText(reader, &text);
|
||||||
size_t points = reader.readInt();
|
size_t points = reader.readInt();
|
||||||
const SkPoint* pos = (const SkPoint*)reader.skip(points * sizeof(SkPoint));
|
const SkPoint* pos = (const SkPoint*)reader.skip(points * sizeof(SkPoint));
|
||||||
canvas.drawPosText(text.text(), text.length(), pos, paint);
|
canvas.drawPosText(text.text(), text.length(), pos, paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_POS_TEXT_TOP_BOTTOM: {
|
case DRAW_POS_TEXT_TOP_BOTTOM: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
getText(reader, &text);
|
getText(reader, &text);
|
||||||
size_t points = reader.readInt();
|
size_t points = reader.readInt();
|
||||||
const SkPoint* pos = (const SkPoint*)reader.skip(points * sizeof(SkPoint));
|
const SkPoint* pos = (const SkPoint*)reader.skip(points * sizeof(SkPoint));
|
||||||
@ -1060,7 +1060,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case DRAW_POS_TEXT_H: {
|
case DRAW_POS_TEXT_H: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
getText(reader, &text);
|
getText(reader, &text);
|
||||||
size_t xCount = reader.readInt();
|
size_t xCount = reader.readInt();
|
||||||
const SkScalar constY = reader.readScalar();
|
const SkScalar constY = reader.readScalar();
|
||||||
@ -1069,7 +1069,7 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
|||||||
paint);
|
paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_POS_TEXT_H_TOP_BOTTOM: {
|
case DRAW_POS_TEXT_H_TOP_BOTTOM: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
getText(reader, &text);
|
getText(reader, &text);
|
||||||
size_t xCount = reader.readInt();
|
size_t xCount = reader.readInt();
|
||||||
const SkScalar* xpos = (const SkScalar*)reader.skip((3 + xCount) * sizeof(SkScalar));
|
const SkScalar* xpos = (const SkScalar*)reader.skip((3 + xCount) * sizeof(SkScalar));
|
||||||
@ -1082,32 +1082,32 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case DRAW_RECT: {
|
case DRAW_RECT: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
canvas.drawRect(reader.skipT<SkRect>(), paint);
|
canvas.drawRect(reader.skipT<SkRect>(), paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_RRECT: {
|
case DRAW_RRECT: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
SkRRect rrect;
|
SkRRect rrect;
|
||||||
reader.readRRect(&rrect);
|
reader.readRRect(&rrect);
|
||||||
canvas.drawRRect(rrect, paint);
|
canvas.drawRRect(rrect, paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_SPRITE: {
|
case DRAW_SPRITE: {
|
||||||
const SkPaint* paint = getPaint(reader);
|
const SkPaint* paint = this->getPaint(reader);
|
||||||
const SkBitmap& bitmap = getBitmap(reader);
|
const SkBitmap& bitmap = this->getBitmap(reader);
|
||||||
int left = reader.readInt();
|
int left = reader.readInt();
|
||||||
int top = reader.readInt();
|
int top = reader.readInt();
|
||||||
canvas.drawSprite(bitmap, left, top, paint);
|
canvas.drawSprite(bitmap, left, top, paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_TEXT: {
|
case DRAW_TEXT: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
getText(reader, &text);
|
this->getText(reader, &text);
|
||||||
SkScalar x = reader.readScalar();
|
SkScalar x = reader.readScalar();
|
||||||
SkScalar y = reader.readScalar();
|
SkScalar y = reader.readScalar();
|
||||||
canvas.drawText(text.text(), text.length(), x, y, paint);
|
canvas.drawText(text.text(), text.length(), x, y, paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_TEXT_TOP_BOTTOM: {
|
case DRAW_TEXT_TOP_BOTTOM: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
getText(reader, &text);
|
this->getText(reader, &text);
|
||||||
const SkScalar* ptr = (const SkScalar*)reader.skip(4 * sizeof(SkScalar));
|
const SkScalar* ptr = (const SkScalar*)reader.skip(4 * sizeof(SkScalar));
|
||||||
// ptr[0] == x
|
// ptr[0] == x
|
||||||
// ptr[1] == y
|
// ptr[1] == y
|
||||||
@ -1119,16 +1119,16 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case DRAW_TEXT_ON_PATH: {
|
case DRAW_TEXT_ON_PATH: {
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
getText(reader, &text);
|
getText(reader, &text);
|
||||||
const SkPath& path = getPath(reader);
|
const SkPath& path = this->getPath(reader);
|
||||||
SkMatrix matrix;
|
SkMatrix matrix;
|
||||||
this->getMatrix(reader, &matrix);
|
this->getMatrix(reader, &matrix);
|
||||||
canvas.drawTextOnPath(text.text(), text.length(), path, &matrix, paint);
|
canvas.drawTextOnPath(text.text(), text.length(), path, &matrix, paint);
|
||||||
} break;
|
} break;
|
||||||
case DRAW_VERTICES: {
|
case DRAW_VERTICES: {
|
||||||
SkAutoTUnref<SkXfermode> xfer;
|
SkAutoTUnref<SkXfermode> xfer;
|
||||||
const SkPaint& paint = *getPaint(reader);
|
const SkPaint& paint = *this->getPaint(reader);
|
||||||
DrawVertexFlags flags = (DrawVertexFlags)reader.readInt();
|
DrawVertexFlags flags = (DrawVertexFlags)reader.readInt();
|
||||||
SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader.readInt();
|
SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader.readInt();
|
||||||
int vCount = reader.readInt();
|
int vCount = reader.readInt();
|
||||||
@ -1171,8 +1171,8 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
|
|||||||
canvas.save((SkCanvas::SaveFlags) reader.readInt());
|
canvas.save((SkCanvas::SaveFlags) reader.readInt());
|
||||||
break;
|
break;
|
||||||
case SAVE_LAYER: {
|
case SAVE_LAYER: {
|
||||||
const SkRect* boundsPtr = getRectPtr(reader);
|
const SkRect* boundsPtr = this->getRectPtr(reader);
|
||||||
const SkPaint* paint = getPaint(reader);
|
const SkPaint* paint = this->getPaint(reader);
|
||||||
canvas.saveLayer(boundsPtr, paint, (SkCanvas::SaveFlags) reader.readInt());
|
canvas.saveLayer(boundsPtr, paint, (SkCanvas::SaveFlags) reader.readInt());
|
||||||
} break;
|
} break;
|
||||||
case SCALE: {
|
case SCALE: {
|
||||||
|
Loading…
Reference in New Issue
Block a user