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 | |
688 /////////////////////////////////////////////////////////////////////////////// | 654 /////////////////////////////////////////////////////////////////////////////// |
689 | 655 |
690 static void drawData_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, | 656 static void drawData_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
691 SkGPipeState* state) { | 657 SkGPipeState* state) { |
692 // since we don't have a paint, we can use data for our (small) sizes | 658 // since we don't have a paint, we can use data for our (small) sizes |
693 size_t size = DrawOp_unpackData(op32); | 659 size_t size = DrawOp_unpackData(op32); |
694 if (0 == size) { | 660 if (0 == size) { |
695 size = reader->readU32(); | 661 size = reader->readU32(); |
696 } | 662 } |
697 const void* data = reader->skip(SkAlign4(size)); | 663 const void* data = reader->skip(SkAlign4(size)); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 clipRect_rp, | 824 clipRect_rp, |
859 clipRRect_rp, | 825 clipRRect_rp, |
860 concat_rp, | 826 concat_rp, |
861 drawBitmap_rp, | 827 drawBitmap_rp, |
862 drawBitmapMatrix_rp, | 828 drawBitmapMatrix_rp, |
863 drawBitmapNine_rp, | 829 drawBitmapNine_rp, |
864 drawBitmapRect_rp, | 830 drawBitmapRect_rp, |
865 drawClear_rp, | 831 drawClear_rp, |
866 drawData_rp, | 832 drawData_rp, |
867 drawDRRect_rp, | 833 drawDRRect_rp, |
868 drawImage_rp, | |
869 drawImageRect_rp, | |
870 drawOval_rp, | 834 drawOval_rp, |
871 drawPaint_rp, | 835 drawPaint_rp, |
872 drawPatch_rp, | 836 drawPatch_rp, |
873 drawPath_rp, | 837 drawPath_rp, |
874 drawPicture_rp, | 838 drawPicture_rp, |
875 drawPoints_rp, | 839 drawPoints_rp, |
876 drawPosText_rp, | 840 drawPosText_rp, |
877 drawPosTextH_rp, | 841 drawPosTextH_rp, |
878 drawRect_rp, | 842 drawRect_rp, |
879 drawRRect_rp, | 843 drawRRect_rp, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 status = kReadAtom_Status; | 957 status = kReadAtom_Status; |
994 break; | 958 break; |
995 } | 959 } |
996 } | 960 } |
997 | 961 |
998 if (bytesRead) { | 962 if (bytesRead) { |
999 *bytesRead = reader.offset(); | 963 *bytesRead = reader.offset(); |
1000 } | 964 } |
1001 return status; | 965 return status; |
1002 } | 966 } |
OLD | NEW |