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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 BitmapHolder holder(reader, op32, state); | 636 BitmapHolder holder(reader, op32, state); |
637 unsigned flags = DrawOp_unpackFlags(op32); | 637 unsigned flags = DrawOp_unpackFlags(op32); |
638 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); | 638 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); |
639 bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag); | 639 bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag); |
640 const SkRect* src; | 640 const SkRect* src; |
641 if (hasSrc) { | 641 if (hasSrc) { |
642 src = skip<SkRect>(reader); | 642 src = skip<SkRect>(reader); |
643 } else { | 643 } else { |
644 src = NULL; | 644 src = NULL; |
645 } | 645 } |
646 SkCanvas::DrawBitmapRectFlags dbmrFlags = SkCanvas::kNone_DrawBitmapRectFlag
; | 646 SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint
; |
647 if (flags & kDrawBitmap_Bleed_DrawOpFlag) { | 647 if (flags & kDrawBitmap_Bleed_DrawOpFlag) { |
648 dbmrFlags = (SkCanvas::DrawBitmapRectFlags)(dbmrFlags|SkCanvas::kBleed_D
rawBitmapRectFlag); | 648 constraint = SkCanvas::kFast_SrcRectConstraint; |
649 } | 649 } |
650 const SkRect* dst = skip<SkRect>(reader); | 650 const SkRect* dst = skip<SkRect>(reader); |
651 const SkBitmap* bitmap = holder.getBitmap(); | 651 const SkBitmap* bitmap = holder.getBitmap(); |
652 if (state->shouldDraw()) { | 652 if (state->shouldDraw()) { |
653 canvas->drawBitmapRectToRect(*bitmap, src, *dst, | 653 canvas->drawBitmapRect(*bitmap, src, *dst, hasPaint ? &state->paint() :
NULL, constraint); |
654 hasPaint ? &state->paint() : NULL, dbmrFlag
s); | |
655 } | 654 } |
656 } | 655 } |
657 | 656 |
658 static void drawSprite_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, | 657 static void drawSprite_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
659 SkGPipeState* state) { | 658 SkGPipeState* state) { |
660 BitmapHolder holder(reader, op32, state); | 659 BitmapHolder holder(reader, op32, state); |
661 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra
wOpFlag); | 660 bool hasPaint = SkToBool(DrawOp_unpackFlags(op32) & kDrawBitmap_HasPaint_Dra
wOpFlag); |
662 const SkIPoint* point = skip<SkIPoint>(reader); | 661 const SkIPoint* point = skip<SkIPoint>(reader); |
663 const SkBitmap* bitmap = holder.getBitmap(); | 662 const SkBitmap* bitmap = holder.getBitmap(); |
664 if (state->shouldDraw()) { | 663 if (state->shouldDraw()) { |
(...skipping 17 matching lines...) Expand all Loading... |
682 SkGPipeState* state) { | 681 SkGPipeState* state) { |
683 unsigned slot = DrawOp_unpackData(op32); | 682 unsigned slot = DrawOp_unpackData(op32); |
684 unsigned flags = DrawOp_unpackFlags(op32); | 683 unsigned flags = DrawOp_unpackFlags(op32); |
685 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); | 684 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); |
686 bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag); | 685 bool hasSrc = SkToBool(flags & kDrawBitmap_HasSrcRect_DrawOpFlag); |
687 const SkRect* src = NULL; | 686 const SkRect* src = NULL; |
688 if (hasSrc) { | 687 if (hasSrc) { |
689 src = skip<SkRect>(reader); | 688 src = skip<SkRect>(reader); |
690 } | 689 } |
691 const SkRect* dst = skip<SkRect>(reader); | 690 const SkRect* dst = skip<SkRect>(reader); |
| 691 SkCanvas::SrcRectConstraint constraint = (SkCanvas::SrcRectConstraint)reader
->readInt(); |
| 692 |
692 const SkImage* image = state->getImage(slot); | 693 const SkImage* image = state->getImage(slot); |
693 if (state->shouldDraw()) { | 694 if (state->shouldDraw()) { |
694 canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NUL
L); | 695 canvas->drawImageRect(image, src, *dst, hasPaint ? &state->paint() : NUL
L, constraint); |
695 } | 696 } |
696 } | 697 } |
697 | 698 |
698 static void drawImageNine_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32
, | 699 static void drawImageNine_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32
, |
699 SkGPipeState* state) { | 700 SkGPipeState* state) { |
700 unsigned slot = DrawOp_unpackData(op32); | 701 unsigned slot = DrawOp_unpackData(op32); |
701 unsigned flags = DrawOp_unpackFlags(op32); | 702 unsigned flags = DrawOp_unpackFlags(op32); |
702 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); | 703 bool hasPaint = SkToBool(flags & kDrawBitmap_HasPaint_DrawOpFlag); |
703 const SkIRect* center = skip<SkIRect>(reader); | 704 const SkIRect* center = skip<SkIRect>(reader); |
704 const SkRect* dst = skip<SkRect>(reader); | 705 const SkRect* dst = skip<SkRect>(reader); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 status = kReadAtom_Status; | 1008 status = kReadAtom_Status; |
1008 break; | 1009 break; |
1009 } | 1010 } |
1010 } | 1011 } |
1011 | 1012 |
1012 if (bytesRead) { | 1013 if (bytesRead) { |
1013 *bytesRead = reader.offset(); | 1014 *bytesRead = reader.offset(); |
1014 } | 1015 } |
1015 return status; | 1016 return status; |
1016 } | 1017 } |
OLD | NEW |