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