Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: src/effects/SkBlurImageFilter.cpp

Issue 395603002: Simplify flattening to just write enough to call the factory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkBlurDrawLooper.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The Android Open Source Project 2 * Copyright 2011 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
11 #include "SkReadBuffer.h" 11 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h" 12 #include "SkWriteBuffer.h"
13 #include "SkGpuBlurUtils.h" 13 #include "SkGpuBlurUtils.h"
14 #include "SkBlurImage_opts.h" 14 #include "SkBlurImage_opts.h"
15 #if SK_SUPPORT_GPU 15 #if SK_SUPPORT_GPU
16 #include "GrContext.h" 16 #include "GrContext.h"
17 #endif 17 #endif
18 18
19 // This rather arbitrary-looking value results in a maximum box blur kernel size 19 // This rather arbitrary-looking value results in a maximum box blur kernel size
20 // of 1000 pixels on the raster path, which matches the WebKit and Firefox 20 // of 1000 pixels on the raster path, which matches the WebKit and Firefox
21 // implementations. Since the GPU path does not compute a box blur, putting 21 // implementations. Since the GPU path does not compute a box blur, putting
22 // the limit on sigma ensures consistent behaviour between the GPU and 22 // the limit on sigma ensures consistent behaviour between the GPU and
23 // raster paths. 23 // raster paths.
24 #define MAX_SIGMA SkIntToScalar(532) 24 #define MAX_SIGMA SkIntToScalar(532)
25 25
26 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
26 SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer) 27 SkBlurImageFilter::SkBlurImageFilter(SkReadBuffer& buffer)
27 : INHERITED(1, buffer) { 28 : INHERITED(1, buffer) {
28 fSigma.fWidth = buffer.readScalar(); 29 fSigma.fWidth = buffer.readScalar();
29 fSigma.fHeight = buffer.readScalar(); 30 fSigma.fHeight = buffer.readScalar();
30 buffer.validate(SkScalarIsFinite(fSigma.fWidth) && 31 buffer.validate(SkScalarIsFinite(fSigma.fWidth) &&
31 SkScalarIsFinite(fSigma.fHeight) && 32 SkScalarIsFinite(fSigma.fHeight) &&
32 (fSigma.fWidth >= 0) && 33 (fSigma.fWidth >= 0) &&
33 (fSigma.fHeight >= 0)); 34 (fSigma.fHeight >= 0));
34 } 35 }
36 #endif
35 37
36 SkBlurImageFilter::SkBlurImageFilter(SkScalar sigmaX, 38 SkBlurImageFilter::SkBlurImageFilter(SkScalar sigmaX,
37 SkScalar sigmaY, 39 SkScalar sigmaY,
38 SkImageFilter* input, 40 SkImageFilter* input,
39 const CropRect* cropRect) 41 const CropRect* cropRect)
40 : INHERITED(1, &input, cropRect), fSigma(SkSize::Make(sigmaX, sigmaY)) { 42 : INHERITED(1, &input, cropRect), fSigma(SkSize::Make(sigmaX, sigmaY)) {
41 SkASSERT(sigmaX >= 0 && sigmaY >= 0); 43 SkASSERT(sigmaX >= 0 && sigmaY >= 0);
42 } 44 }
43 45
46 SkFlattenable* SkBlurImageFilter::CreateProc(SkReadBuffer& buffer) {
47 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1);
48 SkScalar sigmaX = buffer.readScalar();
49 SkScalar sigmaY = buffer.readScalar();
50 return Create(sigmaX, sigmaY, common.getInput(0), &common.cropRect());
51 }
52
44 void SkBlurImageFilter::flatten(SkWriteBuffer& buffer) const { 53 void SkBlurImageFilter::flatten(SkWriteBuffer& buffer) const {
45 this->INHERITED::flatten(buffer); 54 this->INHERITED::flatten(buffer);
46 buffer.writeScalar(fSigma.fWidth); 55 buffer.writeScalar(fSigma.fWidth);
47 buffer.writeScalar(fSigma.fHeight); 56 buffer.writeScalar(fSigma.fHeight);
48 } 57 }
49 58
50 enum BlurDirection { 59 enum BlurDirection {
51 kX, kY 60 kX, kY
52 }; 61 };
53 62
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 true, 291 true,
283 sigma.x(), 292 sigma.x(),
284 sigma.y())); 293 sigma.y()));
285 WrapTexture(tex, rect.width(), rect.height(), result); 294 WrapTexture(tex, rect.width(), rect.height(), result);
286 return true; 295 return true;
287 #else 296 #else
288 SkDEBUGFAIL("Should not call in GPU-less build"); 297 SkDEBUGFAIL("Should not call in GPU-less build");
289 return false; 298 return false;
290 #endif 299 #endif
291 } 300 }
OLDNEW
« no previous file with comments | « src/effects/SkBlurDrawLooper.cpp ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698