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" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 SkRRect outer, inner; | 401 SkRRect outer, inner; |
402 reader->readRRect(&outer); | 402 reader->readRRect(&outer); |
403 reader->readRRect(&inner); | 403 reader->readRRect(&inner); |
404 if (state->shouldDraw()) { | 404 if (state->shouldDraw()) { |
405 canvas->drawDRRect(outer, inner, state->paint()); | 405 canvas->drawDRRect(outer, inner, state->paint()); |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
409 static void drawPatch_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, | 409 static void drawPatch_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
410 SkGPipeState* state) { | 410 SkGPipeState* state) { |
411 | 411 |
412 unsigned flags = DrawOp_unpackFlags(op32); | 412 unsigned flags = DrawOp_unpackFlags(op32); |
413 | 413 |
414 const SkPoint* cubics = skip<SkPoint>(reader, SkPatchUtils::kNumCtrlPts); | 414 const SkPoint* cubics = skip<SkPoint>(reader, SkPatchUtils::kNumCtrlPts); |
415 | 415 |
416 const SkColor* colors = NULL; | 416 const SkColor* colors = NULL; |
417 if (flags & kDrawVertices_HasColors_DrawOpFlag) { | 417 if (flags & kDrawVertices_HasColors_DrawOpFlag) { |
418 colors = skip<SkColor>(reader, SkPatchUtils::kNumCorners); | 418 colors = skip<SkColor>(reader, SkPatchUtils::kNumCorners); |
419 } | 419 } |
420 const SkPoint* texCoords = NULL; | 420 const SkPoint* texCoords = NULL; |
421 if (flags & kDrawVertices_HasTexs_DrawOpFlag) { | 421 if (flags & kDrawVertices_HasTexs_DrawOpFlag) { |
422 texCoords = skip<SkPoint>(reader, SkPatchUtils::kNumCorners); | 422 texCoords = skip<SkPoint>(reader, SkPatchUtils::kNumCorners); |
423 } | 423 } |
424 SkAutoTUnref<SkXfermode> xfer; | 424 SkAutoTUnref<SkXfermode> xfer; |
425 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) { | 425 if (flags & kDrawVertices_HasXfermode_DrawOpFlag) { |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 SkGPipeState* state) { | 644 SkGPipeState* state) { |
645 BitmapHolder holder(reader, op32, state); | 645 BitmapHolder holder(reader, op32, state); |
646 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra
wOpFlag); | 646 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra
wOpFlag); |
647 const SkIPoint* point = skip<SkIPoint>(reader); | 647 const SkIPoint* point = skip<SkIPoint>(reader); |
648 const SkBitmap* bitmap = holder.getBitmap(); | 648 const SkBitmap* bitmap = holder.getBitmap(); |
649 if (state->shouldDraw()) { | 649 if (state->shouldDraw()) { |
650 canvas->drawSprite(*bitmap, point->fX, point->fY, hasPaint ? &state->pai
nt() : NULL); | 650 canvas->drawSprite(*bitmap, point->fX, point->fY, hasPaint ? &state->pai
nt() : NULL); |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
| 654 static void drawImage_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
| 655 SkGPipeState* state) { |
| 656 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra
wOpFlag); |
| 657 // Balances call to ref() in SkGPipeWrite |
| 658 SkAutoTUnref<const SkImage> image (static_cast<const SkImage*>(reader->readP
tr())); |
| 659 |
| 660 SkScalar left = reader->readScalar(); |
| 661 SkScalar top = reader->readScalar(); |
| 662 |
| 663 if (state->shouldDraw()) { |
| 664 canvas->drawImage(image, left, top, hasPaint ? &state->paint() : NULL); |
| 665 } |
| 666 } |
| 667 |
| 668 static void drawImageRect_rp(SkCanvas* canvas, SkReader32* reader, |
| 669 uint32_t op32, SkGPipeState* state) { |
| 670 unsigned flags = DrawOp_unpackFlags(op32); |
| 671 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); |
| 672 bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag); |
| 673 // Balances call to ref() in SkGPipeWrite |
| 674 SkAutoTUnref<const SkImage> image (static_cast<const SkImage*>(reader->readP
tr())); |
| 675 |
| 676 const SkRect* src; |
| 677 if (hasSrc) { |
| 678 src = skip<SkRect>(reader); |
| 679 } else { |
| 680 src = NULL; |
| 681 } |
| 682 const SkRect* dst = skip<SkRect>(reader); |
| 683 if (state->shouldDraw()) { |
| 684 canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NUL
L); |
| 685 } |
| 686 } |
| 687 |
654 /////////////////////////////////////////////////////////////////////////////// | 688 /////////////////////////////////////////////////////////////////////////////// |
655 | 689 |
656 static void drawData_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, | 690 static void drawData_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
657 SkGPipeState* state) { | 691 SkGPipeState* state) { |
658 // since we don't have a paint, we can use data for our (small) sizes | 692 // since we don't have a paint, we can use data for our (small) sizes |
659 size_t size = DrawOp_unpackData(op32); | 693 size_t size = DrawOp_unpackData(op32); |
660 if (0 == size) { | 694 if (0 == size) { |
661 size = reader->readU32(); | 695 size = reader->readU32(); |
662 } | 696 } |
663 const void* data = reader->skip(SkAlign4(size)); | 697 const void* data = reader->skip(SkAlign4(size)); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 clipRect_rp, | 858 clipRect_rp, |
825 clipRRect_rp, | 859 clipRRect_rp, |
826 concat_rp, | 860 concat_rp, |
827 drawBitmap_rp, | 861 drawBitmap_rp, |
828 drawBitmapMatrix_rp, | 862 drawBitmapMatrix_rp, |
829 drawBitmapNine_rp, | 863 drawBitmapNine_rp, |
830 drawBitmapRect_rp, | 864 drawBitmapRect_rp, |
831 drawClear_rp, | 865 drawClear_rp, |
832 drawData_rp, | 866 drawData_rp, |
833 drawDRRect_rp, | 867 drawDRRect_rp, |
| 868 drawImage_rp, |
| 869 drawImageRect_rp, |
834 drawOval_rp, | 870 drawOval_rp, |
835 drawPaint_rp, | 871 drawPaint_rp, |
836 drawPatch_rp, | 872 drawPatch_rp, |
837 drawPath_rp, | 873 drawPath_rp, |
838 drawPicture_rp, | 874 drawPicture_rp, |
839 drawPoints_rp, | 875 drawPoints_rp, |
840 drawPosText_rp, | 876 drawPosText_rp, |
841 drawPosTextH_rp, | 877 drawPosTextH_rp, |
842 drawRect_rp, | 878 drawRect_rp, |
843 drawRRect_rp, | 879 drawRRect_rp, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 status = kReadAtom_Status; | 993 status = kReadAtom_Status; |
958 break; | 994 break; |
959 } | 995 } |
960 } | 996 } |
961 | 997 |
962 if (bytesRead) { | 998 if (bytesRead) { |
963 *bytesRead = reader.offset(); | 999 *bytesRead = reader.offset(); |
964 } | 1000 } |
965 return status; | 1001 return status; |
966 } | 1002 } |
OLD | NEW |