OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkBitmapHeap.h" | 10 #include "SkBitmapHeap.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkGPipe.h" | 13 #include "SkGPipe.h" |
14 #include "SkGPipePriv.h" | 14 #include "SkGPipePriv.h" |
15 #include "SkReader32.h" | 15 #include "SkReader32.h" |
16 #include "SkStream.h" | 16 #include "SkStream.h" |
17 | 17 |
18 #include "SkAnnotation.h" | 18 #include "SkAnnotation.h" |
19 #include "SkColorFilter.h" | 19 #include "SkColorFilter.h" |
20 #include "SkDrawLooper.h" | 20 #include "SkDrawLooper.h" |
21 #include "SkImageFilter.h" | 21 #include "SkImageFilter.h" |
22 #include "SkMaskFilter.h" | 22 #include "SkMaskFilter.h" |
23 #include "SkReadBuffer.h" | |
24 #include "SkPatchUtils.h" | 23 #include "SkPatchUtils.h" |
25 #include "SkPathEffect.h" | 24 #include "SkPathEffect.h" |
26 #include "SkRasterizer.h" | 25 #include "SkRasterizer.h" |
| 26 #include "SkReadBuffer.h" |
27 #include "SkRRect.h" | 27 #include "SkRRect.h" |
| 28 #include "SkRSXform.h" |
28 #include "SkShader.h" | 29 #include "SkShader.h" |
29 #include "SkTextBlob.h" | 30 #include "SkTextBlob.h" |
30 #include "SkTypeface.h" | 31 #include "SkTypeface.h" |
31 #include "SkXfermode.h" | 32 #include "SkXfermode.h" |
32 | 33 |
33 static SkFlattenable::Type paintflat_to_flattype(PaintFlats pf) { | 34 static SkFlattenable::Type paintflat_to_flattype(PaintFlats pf) { |
34 static const uint8_t gEffectTypesInPaintFlatsOrder[] = { | 35 static const uint8_t gEffectTypesInPaintFlatsOrder[] = { |
35 SkFlattenable::kSkColorFilter_Type, | 36 SkFlattenable::kSkColorFilter_Type, |
36 SkFlattenable::kSkDrawLooper_Type, | 37 SkFlattenable::kSkDrawLooper_Type, |
37 SkFlattenable::kSkImageFilter_Type, | 38 SkFlattenable::kSkImageFilter_Type, |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 if (flags & kDrawVertices_HasIndices_DrawOpFlag) { | 473 if (flags & kDrawVertices_HasIndices_DrawOpFlag) { |
473 indexCount = reader->readU32(); | 474 indexCount = reader->readU32(); |
474 indices = skipAlign<uint16_t>(reader, indexCount); | 475 indices = skipAlign<uint16_t>(reader, indexCount); |
475 } | 476 } |
476 if (state->shouldDraw()) { | 477 if (state->shouldDraw()) { |
477 canvas->drawVertices(vmode, vertexCount, verts, texs, colors, xfer, | 478 canvas->drawVertices(vmode, vertexCount, verts, texs, colors, xfer, |
478 indices, indexCount, state->paint()); | 479 indices, indexCount, state->paint()); |
479 } | 480 } |
480 } | 481 } |
481 | 482 |
| 483 static void drawAtlas_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, Sk
GPipeState* state) { |
| 484 unsigned flags = DrawOp_unpackFlags(op32); |
| 485 |
| 486 const SkPaint* paint = NULL; |
| 487 if (flags & kDrawAtlas_HasPaint_DrawOpFlag) { |
| 488 paint = &state->paint(); |
| 489 } |
| 490 const int slot = reader->readU32(); |
| 491 const SkImage* atlas = state->getImage(slot); |
| 492 const int count = reader->readU32(); |
| 493 SkXfermode::Mode mode = (SkXfermode::Mode)reader->readU32(); |
| 494 const SkRSXform* xform = skip<SkRSXform>(reader, count); |
| 495 const SkRect* tex = skip<SkRect>(reader, count); |
| 496 const SkColor* colors = NULL; |
| 497 if (flags & kDrawAtlas_HasColors_DrawOpFlag) { |
| 498 colors = skip<SkColor>(reader, count); |
| 499 } |
| 500 const SkRect* cull = NULL; |
| 501 if (flags & kDrawAtlas_HasCull_DrawOpFlag) { |
| 502 cull = skip<SkRect>(reader, 1); |
| 503 } |
| 504 |
| 505 if (state->shouldDraw()) { |
| 506 canvas->drawAtlas(atlas, xform, tex, colors, count, mode, cull, paint); |
| 507 } |
| 508 } |
| 509 |
482 /////////////////////////////////////////////////////////////////////////////// | 510 /////////////////////////////////////////////////////////////////////////////// |
483 | 511 |
484 static void drawText_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, | 512 static void drawText_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
485 SkGPipeState* state) { | 513 SkGPipeState* state) { |
486 size_t len = reader->readU32(); | 514 size_t len = reader->readU32(); |
487 const void* text = reader->skip(SkAlign4(len)); | 515 const void* text = reader->skip(SkAlign4(len)); |
488 const SkScalar* xy = skip<SkScalar>(reader, 2); | 516 const SkScalar* xy = skip<SkScalar>(reader, 2); |
489 if (state->shouldDraw()) { | 517 if (state->shouldDraw()) { |
490 canvas->drawText(text, len, xy[0], xy[1], state->paint()); | 518 canvas->drawText(text, len, xy[0], xy[1], state->paint()); |
491 } | 519 } |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 | 852 |
825 typedef void (*ReadProc)(SkCanvas*, SkReader32*, uint32_t op32, SkGPipeState*); | 853 typedef void (*ReadProc)(SkCanvas*, SkReader32*, uint32_t op32, SkGPipeState*); |
826 | 854 |
827 static const ReadProc gReadTable[] = { | 855 static const ReadProc gReadTable[] = { |
828 skip_rp, | 856 skip_rp, |
829 clipPath_rp, | 857 clipPath_rp, |
830 clipRegion_rp, | 858 clipRegion_rp, |
831 clipRect_rp, | 859 clipRect_rp, |
832 clipRRect_rp, | 860 clipRRect_rp, |
833 concat_rp, | 861 concat_rp, |
| 862 drawAtlas_rp, |
834 drawBitmap_rp, | 863 drawBitmap_rp, |
835 drawBitmapNine_rp, | 864 drawBitmapNine_rp, |
836 drawBitmapRect_rp, | 865 drawBitmapRect_rp, |
837 drawDRRect_rp, | 866 drawDRRect_rp, |
838 drawImage_rp, | 867 drawImage_rp, |
839 drawImageRect_rp, | 868 drawImageRect_rp, |
840 drawOval_rp, | 869 drawOval_rp, |
841 drawPaint_rp, | 870 drawPaint_rp, |
842 drawPatch_rp, | 871 drawPatch_rp, |
843 drawPath_rp, | 872 drawPath_rp, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 status = kReadAtom_Status; | 993 status = kReadAtom_Status; |
965 break; | 994 break; |
966 } | 995 } |
967 } | 996 } |
968 | 997 |
969 if (bytesRead) { | 998 if (bytesRead) { |
970 *bytesRead = reader.offset(); | 999 *bytesRead = reader.offset(); |
971 } | 1000 } |
972 return status; | 1001 return status; |
973 } | 1002 } |
OLD | NEW |