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" | 23 #include "SkReadBuffer.h" |
| 24 #include "SkPatchUtils.h" |
24 #include "SkPathEffect.h" | 25 #include "SkPathEffect.h" |
25 #include "SkRasterizer.h" | 26 #include "SkRasterizer.h" |
26 #include "SkRRect.h" | 27 #include "SkRRect.h" |
27 #include "SkShader.h" | 28 #include "SkShader.h" |
28 #include "SkTypeface.h" | 29 #include "SkTypeface.h" |
29 #include "SkXfermode.h" | 30 #include "SkXfermode.h" |
30 | 31 |
31 static SkFlattenable::Type paintflat_to_flattype(PaintFlats pf) { | 32 static SkFlattenable::Type paintflat_to_flattype(PaintFlats pf) { |
32 static const uint8_t gEffectTypesInPaintFlatsOrder[] = { | 33 static const uint8_t gEffectTypesInPaintFlatsOrder[] = { |
33 SkFlattenable::kSkColorFilter_Type, | 34 SkFlattenable::kSkColorFilter_Type, |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 SkRRect outer, inner; | 400 SkRRect outer, inner; |
400 reader->readRRect(&outer); | 401 reader->readRRect(&outer); |
401 reader->readRRect(&inner); | 402 reader->readRRect(&inner); |
402 if (state->shouldDraw()) { | 403 if (state->shouldDraw()) { |
403 canvas->drawDRRect(outer, inner, state->paint()); | 404 canvas->drawDRRect(outer, inner, state->paint()); |
404 } | 405 } |
405 } | 406 } |
406 | 407 |
407 static void drawPatch_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, | 408 static void drawPatch_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
408 SkGPipeState* state) { | 409 SkGPipeState* state) { |
409 SkPatch patch; | 410 |
410 reader->readPatch(&patch); | 411 unsigned flags = DrawOp_unpackFlags(op32); |
| 412 |
| 413 const SkPoint* cubics = skip<SkPoint>(reader, SkPatchUtils::kNumCtrlPts); |
| 414 |
| 415 const SkColor* colors = NULL; |
| 416 if (flags & kDrawVertices_HasColors_DrawOpFlag) { |
| 417 colors = skip<SkColor>(reader, SkPatchUtils::kNumCorners); |
| 418 } |
| 419 const SkPoint* texCoords = NULL; |
| 420 if (flags & kDrawVertices_HasTexs_DrawOpFlag) { |
| 421 texCoords = skip<SkPoint>(reader, SkPatchUtils::kNumCorners); |
| 422 } |
| 423 SkAutoTUnref<SkXfermode> xfer; |
| 424 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) { |
| 425 int mode = reader->readInt(); |
| 426 if (mode < 0 || mode > SkXfermode::kLastMode) { |
| 427 mode = SkXfermode::kModulate_Mode; |
| 428 } |
| 429 xfer.reset(SkXfermode::Create((SkXfermode::Mode)mode)); |
| 430 } |
411 if (state->shouldDraw()) { | 431 if (state->shouldDraw()) { |
412 canvas->drawPatch(patch, state->paint()); | 432 canvas->drawPatch(cubics, colors, texCoords, xfer, state->paint()); |
413 } | 433 } |
414 } | 434 } |
415 | 435 |
416 static void drawPath_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, | 436 static void drawPath_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
417 SkGPipeState* state) { | 437 SkGPipeState* state) { |
418 SkPath path; | 438 SkPath path; |
419 reader->readPath(&path); | 439 reader->readPath(&path); |
420 if (state->shouldDraw()) { | 440 if (state->shouldDraw()) { |
421 canvas->drawPath(path, state->paint()); | 441 canvas->drawPath(path, state->paint()); |
422 } | 442 } |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 status = kReadAtom_Status; | 927 status = kReadAtom_Status; |
908 break; | 928 break; |
909 } | 929 } |
910 } | 930 } |
911 | 931 |
912 if (bytesRead) { | 932 if (bytesRead) { |
913 *bytesRead = reader.offset(); | 933 *bytesRead = reader.offset(); |
914 } | 934 } |
915 return status; | 935 return status; |
916 } | 936 } |
OLD | NEW |