| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkCanvas.h" | 8 #include "SkCanvas.h" |
| 9 #include "SkPatchUtils.h" | 9 #include "SkPatchUtils.h" |
| 10 #include "SkPictureData.h" | 10 #include "SkPictureData.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 return (DrawType)op; | 39 return (DrawType)op; |
| 40 } | 40 } |
| 41 | 41 |
| 42 | 42 |
| 43 static const SkRect* get_rect_ptr(SkReader32* reader) { | 43 static const SkRect* get_rect_ptr(SkReader32* reader) { |
| 44 if (reader->readBool()) { | 44 if (reader->readBool()) { |
| 45 return &reader->skipT<SkRect>(); | 45 return &reader->skipT<SkRect>(); |
| 46 } else { | 46 } else { |
| 47 return NULL; | 47 return nullptr; |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 class TextContainer { | 51 class TextContainer { |
| 52 public: | 52 public: |
| 53 size_t length() { return fByteLength; } | 53 size_t length() { return fByteLength; } |
| 54 const void* text() { return (const void*)fText; } | 54 const void* text() { return (const void*)fText; } |
| 55 size_t fByteLength; | 55 size_t fByteLength; |
| 56 const char* fText; | 56 const char* fText; |
| 57 }; | 57 }; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 canvas->concat(matrix); | 157 canvas->concat(matrix); |
| 158 break; | 158 break; |
| 159 } | 159 } |
| 160 case DRAW_ATLAS: { | 160 case DRAW_ATLAS: { |
| 161 const SkPaint* paint = fPictureData->getPaint(reader); | 161 const SkPaint* paint = fPictureData->getPaint(reader); |
| 162 const SkImage* atlas = fPictureData->getImage(reader); | 162 const SkImage* atlas = fPictureData->getImage(reader); |
| 163 const uint32_t flags = reader->readU32(); | 163 const uint32_t flags = reader->readU32(); |
| 164 const int count = reader->readU32(); | 164 const int count = reader->readU32(); |
| 165 const SkRSXform* xform = (const SkRSXform*)reader->skip(count * size
of(SkRSXform)); | 165 const SkRSXform* xform = (const SkRSXform*)reader->skip(count * size
of(SkRSXform)); |
| 166 const SkRect* tex = (const SkRect*)reader->skip(count * sizeof(SkRec
t)); | 166 const SkRect* tex = (const SkRect*)reader->skip(count * sizeof(SkRec
t)); |
| 167 const SkColor* colors = NULL; | 167 const SkColor* colors = nullptr; |
| 168 SkXfermode::Mode mode = SkXfermode::kDst_Mode; | 168 SkXfermode::Mode mode = SkXfermode::kDst_Mode; |
| 169 if (flags & DRAW_ATLAS_HAS_COLORS) { | 169 if (flags & DRAW_ATLAS_HAS_COLORS) { |
| 170 colors = (const SkColor*)reader->skip(count * sizeof(SkColor)); | 170 colors = (const SkColor*)reader->skip(count * sizeof(SkColor)); |
| 171 mode = (SkXfermode::Mode)reader->readU32(); | 171 mode = (SkXfermode::Mode)reader->readU32(); |
| 172 } | 172 } |
| 173 const SkRect* cull = NULL; | 173 const SkRect* cull = nullptr; |
| 174 if (flags & DRAW_ATLAS_HAS_CULL) { | 174 if (flags & DRAW_ATLAS_HAS_CULL) { |
| 175 cull = (const SkRect*)reader->skip(sizeof(SkRect)); | 175 cull = (const SkRect*)reader->skip(sizeof(SkRect)); |
| 176 } | 176 } |
| 177 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, pain
t); | 177 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, pain
t); |
| 178 } break; | 178 } break; |
| 179 case DRAW_BITMAP: { | 179 case DRAW_BITMAP: { |
| 180 const SkPaint* paint = fPictureData->getPaint(reader); | 180 const SkPaint* paint = fPictureData->getPaint(reader); |
| 181 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); | 181 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader)
); |
| 182 const SkPoint& loc = reader->skipT<SkPoint>(); | 182 const SkPoint& loc = reader->skipT<SkPoint>(); |
| 183 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint); | 183 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } break; | 268 } break; |
| 269 case DRAW_PAINT: | 269 case DRAW_PAINT: |
| 270 canvas->drawPaint(*fPictureData->getPaint(reader)); | 270 canvas->drawPaint(*fPictureData->getPaint(reader)); |
| 271 break; | 271 break; |
| 272 case DRAW_PATCH: { | 272 case DRAW_PATCH: { |
| 273 const SkPaint& paint = *fPictureData->getPaint(reader); | 273 const SkPaint& paint = *fPictureData->getPaint(reader); |
| 274 | 274 |
| 275 const SkPoint* cubics = (const SkPoint*)reader->skip(SkPatchUtils::k
NumCtrlPts * | 275 const SkPoint* cubics = (const SkPoint*)reader->skip(SkPatchUtils::k
NumCtrlPts * |
| 276 sizeof(SkPoint)
); | 276 sizeof(SkPoint)
); |
| 277 uint32_t flag = reader->readInt(); | 277 uint32_t flag = reader->readInt(); |
| 278 const SkColor* colors = NULL; | 278 const SkColor* colors = nullptr; |
| 279 if (flag & DRAW_VERTICES_HAS_COLORS) { | 279 if (flag & DRAW_VERTICES_HAS_COLORS) { |
| 280 colors = (const SkColor*)reader->skip(SkPatchUtils::kNumCorners
* sizeof(SkColor)); | 280 colors = (const SkColor*)reader->skip(SkPatchUtils::kNumCorners
* sizeof(SkColor)); |
| 281 } | 281 } |
| 282 const SkPoint* texCoords = NULL; | 282 const SkPoint* texCoords = nullptr; |
| 283 if (flag & DRAW_VERTICES_HAS_TEXS) { | 283 if (flag & DRAW_VERTICES_HAS_TEXS) { |
| 284 texCoords = (const SkPoint*)reader->skip(SkPatchUtils::kNumCorne
rs * | 284 texCoords = (const SkPoint*)reader->skip(SkPatchUtils::kNumCorne
rs * |
| 285 sizeof(SkPoint)); | 285 sizeof(SkPoint)); |
| 286 } | 286 } |
| 287 SkAutoTUnref<SkXfermode> xfer; | 287 SkAutoTUnref<SkXfermode> xfer; |
| 288 if (flag & DRAW_VERTICES_HAS_XFER) { | 288 if (flag & DRAW_VERTICES_HAS_XFER) { |
| 289 int mode = reader->readInt(); | 289 int mode = reader->readInt(); |
| 290 if (mode < 0 || mode > SkXfermode::kLastMode) { | 290 if (mode < 0 || mode > SkXfermode::kLastMode) { |
| 291 mode = SkXfermode::kModulate_Mode; | 291 mode = SkXfermode::kModulate_Mode; |
| 292 } | 292 } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 reader->readMatrix(&matrix); | 411 reader->readMatrix(&matrix); |
| 412 canvas->drawTextOnPath(text.text(), text.length(), path, &matrix, pa
int); | 412 canvas->drawTextOnPath(text.text(), text.length(), path, &matrix, pa
int); |
| 413 } break; | 413 } break; |
| 414 case DRAW_VERTICES: { | 414 case DRAW_VERTICES: { |
| 415 SkAutoTUnref<SkXfermode> xfer; | 415 SkAutoTUnref<SkXfermode> xfer; |
| 416 const SkPaint& paint = *fPictureData->getPaint(reader); | 416 const SkPaint& paint = *fPictureData->getPaint(reader); |
| 417 DrawVertexFlags flags = (DrawVertexFlags)reader->readInt(); | 417 DrawVertexFlags flags = (DrawVertexFlags)reader->readInt(); |
| 418 SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader->readInt()
; | 418 SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader->readInt()
; |
| 419 int vCount = reader->readInt(); | 419 int vCount = reader->readInt(); |
| 420 const SkPoint* verts = (const SkPoint*)reader->skip(vCount * sizeof(
SkPoint)); | 420 const SkPoint* verts = (const SkPoint*)reader->skip(vCount * sizeof(
SkPoint)); |
| 421 const SkPoint* texs = NULL; | 421 const SkPoint* texs = nullptr; |
| 422 const SkColor* colors = NULL; | 422 const SkColor* colors = nullptr; |
| 423 const uint16_t* indices = NULL; | 423 const uint16_t* indices = nullptr; |
| 424 int iCount = 0; | 424 int iCount = 0; |
| 425 if (flags & DRAW_VERTICES_HAS_TEXS) { | 425 if (flags & DRAW_VERTICES_HAS_TEXS) { |
| 426 texs = (const SkPoint*)reader->skip(vCount * sizeof(SkPoint)); | 426 texs = (const SkPoint*)reader->skip(vCount * sizeof(SkPoint)); |
| 427 } | 427 } |
| 428 if (flags & DRAW_VERTICES_HAS_COLORS) { | 428 if (flags & DRAW_VERTICES_HAS_COLORS) { |
| 429 colors = (const SkColor*)reader->skip(vCount * sizeof(SkColor)); | 429 colors = (const SkColor*)reader->skip(vCount * sizeof(SkColor)); |
| 430 } | 430 } |
| 431 if (flags & DRAW_VERTICES_HAS_INDICES) { | 431 if (flags & DRAW_VERTICES_HAS_INDICES) { |
| 432 iCount = reader->readInt(); | 432 iCount = reader->readInt(); |
| 433 indices = (const uint16_t*)reader->skip(iCount * sizeof(uint16_t
)); | 433 indices = (const uint16_t*)reader->skip(iCount * sizeof(uint16_t
)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 case TRANSLATE: { | 479 case TRANSLATE: { |
| 480 SkScalar dx = reader->readScalar(); | 480 SkScalar dx = reader->readScalar(); |
| 481 SkScalar dy = reader->readScalar(); | 481 SkScalar dy = reader->readScalar(); |
| 482 canvas->translate(dx, dy); | 482 canvas->translate(dx, dy); |
| 483 } break; | 483 } break; |
| 484 default: | 484 default: |
| 485 SkASSERTF(false, "Unknown draw type: %d", op); | 485 SkASSERTF(false, "Unknown draw type: %d", op); |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 | 488 |
| OLD | NEW |