OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 The Android Open Source Project | 2 * Copyright 2013 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 "SkBicubicImageFilter.h" | 8 #include "SkBicubicImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
11 #include "SkFlattenableBuffers.h" | 11 #include "SkReadBuffer.h" |
| 12 #include "SkWriteBuffer.h" |
12 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
13 #include "SkRect.h" | 14 #include "SkRect.h" |
14 #include "SkUnPreMultiply.h" | 15 #include "SkUnPreMultiply.h" |
15 | 16 |
16 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU |
17 #include "effects/GrBicubicEffect.h" | 18 #include "effects/GrBicubicEffect.h" |
18 #include "GrContext.h" | 19 #include "GrContext.h" |
19 #include "GrTexture.h" | 20 #include "GrTexture.h" |
20 #include "SkImageFilterUtils.h" | 21 #include "SkImageFilterUtils.h" |
21 #endif | 22 #endif |
(...skipping 11 matching lines...) Expand all Loading... |
33 : INHERITED(input), | 34 : INHERITED(input), |
34 fScale(scale) { | 35 fScale(scale) { |
35 memcpy(fCoefficients, coefficients, sizeof(fCoefficients)); | 36 memcpy(fCoefficients, coefficients, sizeof(fCoefficients)); |
36 } | 37 } |
37 | 38 |
38 SkBicubicImageFilter* SkBicubicImageFilter::CreateMitchell(const SkSize& scale, | 39 SkBicubicImageFilter* SkBicubicImageFilter::CreateMitchell(const SkSize& scale, |
39 SkImageFilter* input)
{ | 40 SkImageFilter* input)
{ |
40 return SkNEW_ARGS(SkBicubicImageFilter, (scale, gMitchellCoefficients, input
)); | 41 return SkNEW_ARGS(SkBicubicImageFilter, (scale, gMitchellCoefficients, input
)); |
41 } | 42 } |
42 | 43 |
43 SkBicubicImageFilter::SkBicubicImageFilter(SkFlattenableReadBuffer& buffer) | 44 SkBicubicImageFilter::SkBicubicImageFilter(SkReadBuffer& buffer) |
44 : INHERITED(1, buffer) { | 45 : INHERITED(1, buffer) { |
45 SkDEBUGCODE(bool success =) buffer.readScalarArray(fCoefficients, 16); | 46 SkDEBUGCODE(bool success =) buffer.readScalarArray(fCoefficients, 16); |
46 SkASSERT(success); | 47 SkASSERT(success); |
47 fScale.fWidth = buffer.readScalar(); | 48 fScale.fWidth = buffer.readScalar(); |
48 fScale.fHeight = buffer.readScalar(); | 49 fScale.fHeight = buffer.readScalar(); |
49 buffer.validate(SkScalarIsFinite(fScale.fWidth) && | 50 buffer.validate(SkScalarIsFinite(fScale.fWidth) && |
50 SkScalarIsFinite(fScale.fHeight) && | 51 SkScalarIsFinite(fScale.fHeight) && |
51 (fScale.fWidth >= 0) && | 52 (fScale.fWidth >= 0) && |
52 (fScale.fHeight >= 0)); | 53 (fScale.fHeight >= 0)); |
53 } | 54 } |
54 | 55 |
55 void SkBicubicImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 56 void SkBicubicImageFilter::flatten(SkWriteBuffer& buffer) const { |
56 this->INHERITED::flatten(buffer); | 57 this->INHERITED::flatten(buffer); |
57 buffer.writeScalarArray(fCoefficients, 16); | 58 buffer.writeScalarArray(fCoefficients, 16); |
58 buffer.writeScalar(fScale.fWidth); | 59 buffer.writeScalar(fScale.fWidth); |
59 buffer.writeScalar(fScale.fHeight); | 60 buffer.writeScalar(fScale.fHeight); |
60 } | 61 } |
61 | 62 |
62 SkBicubicImageFilter::~SkBicubicImageFilter() { | 63 SkBicubicImageFilter::~SkBicubicImageFilter() { |
63 } | 64 } |
64 | 65 |
65 inline SkPMColor cubicBlend(const SkScalar c[16], SkScalar t, SkPMColor c0, SkPM
Color c1, SkPMColor c2, SkPMColor c3) { | 66 inline SkPMColor cubicBlend(const SkScalar c[16], SkScalar t, SkPMColor c0, SkPM
Color c1, SkPMColor c2, SkPMColor c3) { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 GrPaint paint; | 196 GrPaint paint; |
196 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); | 197 paint.addColorEffect(GrBicubicEffect::Create(srcTexture, fCoefficients))->un
ref(); |
197 SkRect srcRect; | 198 SkRect srcRect; |
198 srcBM.getBounds(&srcRect); | 199 srcBM.getBounds(&srcRect); |
199 context->drawRectToRect(paint, dstRect, srcRect); | 200 context->drawRectToRect(paint, dstRect, srcRect); |
200 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul
t); | 201 return SkImageFilterUtils::WrapTexture(dst, desc.fWidth, desc.fHeight, resul
t); |
201 } | 202 } |
202 #endif | 203 #endif |
203 | 204 |
204 /////////////////////////////////////////////////////////////////////////////// | 205 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |