| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 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 "SkEmbossMaskFilter.h" | 8 #include "SkEmbossMaskFilter.h" |
| 9 #include "SkBlurMaskFilter.h" | 9 #include "SkBlurMaskFilter.h" |
| 10 #include "SkBlurMask.h" | 10 #include "SkBlurMask.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 SkPoint::Length(fLight.fDirection[0], fLight.fDirection[1])); | 105 SkPoint::Length(fLight.fDirection[0], fLight.fDirection[1])); |
| 106 | 106 |
| 107 SkEmbossMask::Emboss(dst, light); | 107 SkEmbossMask::Emboss(dst, light); |
| 108 | 108 |
| 109 // restore original alpha | 109 // restore original alpha |
| 110 memcpy(dst->fImage, src.fImage, src.computeImageSize()); | 110 memcpy(dst->fImage, src.fImage, src.computeImageSize()); |
| 111 | 111 |
| 112 return true; | 112 return true; |
| 113 } | 113 } |
| 114 | 114 |
| 115 SkFlattenable* SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) { | 115 sk_sp<SkFlattenable> SkEmbossMaskFilter::CreateProc(SkReadBuffer& buffer) { |
| 116 Light light; | 116 Light light; |
| 117 if (buffer.readByteArray(&light, sizeof(Light))) { | 117 if (buffer.readByteArray(&light, sizeof(Light))) { |
| 118 light.fPad = 0; // for the font-cache lookup to be clean | 118 light.fPad = 0; // for the font-cache lookup to be clean |
| 119 const SkScalar sigma = buffer.readScalar(); | 119 const SkScalar sigma = buffer.readScalar(); |
| 120 return Create(sigma, light); | 120 return sk_sp<SkFlattenable>(Create(sigma, light)); |
| 121 } | 121 } |
| 122 return nullptr; | 122 return nullptr; |
| 123 } | 123 } |
| 124 | 124 |
| 125 void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const { | 125 void SkEmbossMaskFilter::flatten(SkWriteBuffer& buffer) const { |
| 126 Light tmpLight = fLight; | 126 Light tmpLight = fLight; |
| 127 tmpLight.fPad = 0; // for the font-cache lookup to be clean | 127 tmpLight.fPad = 0; // for the font-cache lookup to be clean |
| 128 buffer.writeByteArray(&tmpLight, sizeof(tmpLight)); | 128 buffer.writeByteArray(&tmpLight, sizeof(tmpLight)); |
| 129 buffer.writeScalar(fBlurSigma); | 129 buffer.writeScalar(fBlurSigma); |
| 130 } | 130 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 142 str->append(") "); | 142 str->append(") "); |
| 143 | 143 |
| 144 str->appendf("ambient: %d specular: %d ", | 144 str->appendf("ambient: %d specular: %d ", |
| 145 fLight.fAmbient, fLight.fSpecular); | 145 fLight.fAmbient, fLight.fSpecular); |
| 146 | 146 |
| 147 str->append("blurSigma: "); | 147 str->append("blurSigma: "); |
| 148 str->appendScalar(fBlurSigma); | 148 str->appendScalar(fBlurSigma); |
| 149 str->append(")"); | 149 str->append(")"); |
| 150 } | 150 } |
| 151 #endif | 151 #endif |
| OLD | NEW |