| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 return allocator->createT<Sprite_F16>(source, paint); | 75 return allocator->createT<Sprite_F16>(source, paint); |
| 76 default: | 76 default: |
| 77 return nullptr; | 77 return nullptr; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 81 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 82 | 82 |
| 83 class Sprite_sRGB : public Sprite_4f { | 83 class Sprite_sRGB : public Sprite_4f { |
| 84 public: | 84 public: |
| 85 Sprite_sRGB(const SkPixmap& src, const SkPaint& paint) : INHERITED(src, pain
t) { | 85 Sprite_sRGB(const SkPixmap& src, const SkPaint& paint, SkColorProfileType ds
tPt) : INHERITED(src, paint) { |
| 86 uint32_t flags = SkXfermode::kDstIsSRGB_D32Flag; | 86 uint32_t flags = 0; |
| 87 if (kSRGB_SkColorProfileType == dstPt) { |
| 88 flags |= SkXfermode::kDstIsSRGB_D32Flag; |
| 89 } |
| 87 if (src.isOpaque()) { | 90 if (src.isOpaque()) { |
| 88 flags |= SkXfermode::kSrcIsOpaque_D32Flag; | 91 flags |= SkXfermode::kSrcIsOpaque_D32Flag; |
| 89 } | 92 } |
| 90 fWriter = SkXfermode::GetD32Proc(fXfer, flags); | 93 fWriter = SkXfermode::GetD32Proc(fXfer, flags); |
| 91 } | 94 } |
| 92 | 95 |
| 93 void blitRect(int x, int y, int width, int height) override { | 96 void blitRect(int x, int y, int width, int height) override { |
| 94 SkASSERT(width > 0 && height > 0); | 97 SkASSERT(width > 0 && height > 0); |
| 95 uint32_t* SK_RESTRICT dst = fDst.writable_addr32(x, y); | 98 uint32_t* SK_RESTRICT dst = fDst.writable_addr32(x, y); |
| 96 size_t dstRB = fDst.rowBytes(); | 99 size_t dstRB = fDst.rowBytes(); |
| 97 | 100 |
| 98 for (int bottom = y + height; y < bottom; ++y) { | 101 for (int bottom = y + height; y < bottom; ++y) { |
| 99 fLoader(fSource, x - fLeft, y - fTop, fBuffer, width); | 102 fLoader(fSource, x - fLeft, y - fTop, fBuffer, width); |
| 100 fFilter(*fPaint, fBuffer, width); | 103 fFilter(*fPaint, fBuffer, width); |
| 101 fWriter(fXfer, dst, fBuffer, width, nullptr); | 104 fWriter(fXfer, dst, fBuffer, width, nullptr); |
| 102 dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB); | 105 dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB); |
| 103 } | 106 } |
| 104 } | 107 } |
| 105 | 108 |
| 106 protected: | 109 protected: |
| 107 SkXfermode::D32Proc fWriter; | 110 SkXfermode::D32Proc fWriter; |
| 108 | 111 |
| 109 private: | 112 private: |
| 110 typedef Sprite_4f INHERITED; | 113 typedef Sprite_4f INHERITED; |
| 111 }; | 114 }; |
| 112 | 115 |
| 113 | 116 |
| 114 SkSpriteBlitter* SkSpriteBlitter::ChooseS32(const SkPixmap& source, const SkPain
t& paint, | 117 SkSpriteBlitter* SkSpriteBlitter::ChooseNew32(const SkPixmap& source, const SkPa
int& paint, |
| 115 SkTBlitterAllocator* allocator) { | 118 SkTBlitterAllocator* allocator, SkCo
lorProfileType dstPt) { |
| 116 SkASSERT(allocator != nullptr); | 119 SkASSERT(allocator != nullptr); |
| 117 | 120 |
| 118 if (paint.getMaskFilter() != nullptr) { | 121 if (paint.getMaskFilter() != nullptr) { |
| 119 return nullptr; | 122 return nullptr; |
| 120 } | 123 } |
| 121 | 124 |
| 122 switch (source.colorType()) { | 125 switch (source.colorType()) { |
| 123 case kN32_SkColorType: | 126 case kN32_SkColorType: |
| 124 case kRGBA_F16_SkColorType: | 127 case kRGBA_F16_SkColorType: |
| 125 return allocator->createT<Sprite_sRGB>(source, paint); | 128 return allocator->createT<Sprite_sRGB>(source, paint, dstPt); |
| 126 default: | 129 default: |
| 127 return nullptr; | 130 return nullptr; |
| 128 } | 131 } |
| 129 } | 132 } |
| OLD | NEW |