| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkSpriteBlitter.h" | 8 #include "SkSpriteBlitter.h" |
| 9 #include "SkSpanProcs.h" | 9 #include "SkSpanProcs.h" |
| 10 #include "SkTemplates.h" | 10 #include "SkTemplates.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 typedef SkSpriteBlitter INHERITED; | 29 typedef SkSpriteBlitter INHERITED; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 32 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 33 | 33 |
| 34 class Sprite_F16 : public Sprite_4f { | 34 class Sprite_F16 : public Sprite_4f { |
| 35 public: | 35 public: |
| 36 Sprite_F16(const SkPixmap& src, const SkPaint& paint) : INHERITED(src, paint
) { | 36 Sprite_F16(const SkPixmap& src, const SkPaint& paint) : INHERITED(src, paint
) { |
| 37 uint32_t flags = SkXfermode::kDstIsFloat16_D64Flag; | 37 uint32_t flags = 0; |
| 38 if (src.isOpaque()) { | 38 if (src.isOpaque()) { |
| 39 flags |= SkXfermode::kSrcIsOpaque_D64Flag; | 39 flags |= SkXfermode::kSrcIsOpaque_F16Flag; |
| 40 } | 40 } |
| 41 fWriter = SkXfermode::GetD64Proc(fXfer, flags); | 41 fWriter = SkXfermode::GetF16Proc(fXfer, flags); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void blitRect(int x, int y, int width, int height) override { | 44 void blitRect(int x, int y, int width, int height) override { |
| 45 SkASSERT(width > 0 && height > 0); | 45 SkASSERT(width > 0 && height > 0); |
| 46 uint64_t* SK_RESTRICT dst = fDst.writable_addr64(x, y); | 46 uint64_t* SK_RESTRICT dst = fDst.writable_addr64(x, y); |
| 47 size_t dstRB = fDst.rowBytes(); | 47 size_t dstRB = fDst.rowBytes(); |
| 48 | 48 |
| 49 for (int bottom = y + height; y < bottom; ++y) { | 49 for (int bottom = y + height; y < bottom; ++y) { |
| 50 fLoader(fSource, x - fLeft, y - fTop, fBuffer, width); | 50 fLoader(fSource, x - fLeft, y - fTop, fBuffer, width); |
| 51 fFilter(*fPaint, fBuffer, width); | 51 fFilter(*fPaint, fBuffer, width); |
| 52 fWriter(fXfer, dst, fBuffer, width, nullptr); | 52 fWriter(fXfer, dst, fBuffer, width, nullptr); |
| 53 dst = (uint64_t* SK_RESTRICT)((char*)dst + dstRB); | 53 dst = (uint64_t* SK_RESTRICT)((char*)dst + dstRB); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 SkXfermode::D64Proc fWriter; | 58 SkXfermode::F16Proc fWriter; |
| 59 | 59 |
| 60 typedef Sprite_4f INHERITED; | 60 typedef Sprite_4f INHERITED; |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 | 63 |
| 64 SkSpriteBlitter* SkSpriteBlitter::ChooseF16(const SkPixmap& source, const SkPain
t& paint, | 64 SkSpriteBlitter* SkSpriteBlitter::ChooseF16(const SkPixmap& source, const SkPain
t& paint, |
| 65 SkTBlitterAllocator* allocator) { | 65 SkTBlitterAllocator* allocator) { |
| 66 SkASSERT(allocator != nullptr); | 66 SkASSERT(allocator != nullptr); |
| 67 | 67 |
| 68 if (paint.getMaskFilter() != nullptr) { | 68 if (paint.getMaskFilter() != nullptr) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 switch (source.colorType()) { | 122 switch (source.colorType()) { |
| 123 case kN32_SkColorType: | 123 case kN32_SkColorType: |
| 124 case kRGBA_F16_SkColorType: | 124 case kRGBA_F16_SkColorType: |
| 125 return allocator->createT<Sprite_sRGB>(source, paint); | 125 return allocator->createT<Sprite_sRGB>(source, paint); |
| 126 default: | 126 default: |
| 127 return nullptr; | 127 return nullptr; |
| 128 } | 128 } |
| 129 } | 129 } |
| OLD | NEW |