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