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

Side by Side Diff: src/effects/SkMatrixImageFilter.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: revised understanding : input filter count is requred, but elements may be null Created 6 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The Android Open Source Project 2 * Copyright 2014 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 "SkMatrixImageFilter.h" 8 #include "SkMatrixImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 11 matching lines...) Expand all
22 fTransform(transform), 22 fTransform(transform),
23 fFilterLevel(filterLevel) { 23 fFilterLevel(filterLevel) {
24 } 24 }
25 25
26 SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform, 26 SkMatrixImageFilter* SkMatrixImageFilter::Create(const SkMatrix& transform,
27 SkPaint::FilterLevel filterLeve l, 27 SkPaint::FilterLevel filterLeve l,
28 SkImageFilter* input) { 28 SkImageFilter* input) {
29 return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterLevel, input)); 29 return SkNEW_ARGS(SkMatrixImageFilter, (transform, filterLevel, input));
30 } 30 }
31 31
32 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
32 SkMatrixImageFilter::SkMatrixImageFilter(SkReadBuffer& buffer) 33 SkMatrixImageFilter::SkMatrixImageFilter(SkReadBuffer& buffer)
33 : INHERITED(1, buffer) { 34 : INHERITED(1, buffer) {
34 buffer.readMatrix(&fTransform); 35 buffer.readMatrix(&fTransform);
35 fFilterLevel = static_cast<SkPaint::FilterLevel>(buffer.readInt()); 36 fFilterLevel = static_cast<SkPaint::FilterLevel>(buffer.readInt());
36 } 37 }
38 #endif
39
40 SkFlattenable* SkMatrixImageFilter::CreateProc(SkReadBuffer& buffer) {
41 Common common;
42 if (!common.unflatten(buffer, 1)) {
43 return NULL;
44 }
45 SkMatrix matrix;
46 buffer.readMatrix(&matrix);
47 SkPaint::FilterLevel level = static_cast<SkPaint::FilterLevel>(buffer.readIn t());
48 return Create(matrix, level, common.inputAt(0));
49 }
37 50
38 void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const { 51 void SkMatrixImageFilter::flatten(SkWriteBuffer& buffer) const {
39 this->INHERITED::flatten(buffer); 52 this->flattenCommon(buffer);
40 buffer.writeMatrix(fTransform); 53 buffer.writeMatrix(fTransform);
41 buffer.writeInt(fFilterLevel); 54 buffer.writeInt(fFilterLevel);
42 } 55 }
43 56
44 SkMatrixImageFilter::~SkMatrixImageFilter() { 57 SkMatrixImageFilter::~SkMatrixImageFilter() {
45 } 58 }
46 59
47 bool SkMatrixImageFilter::onFilterImage(Proxy* proxy, 60 bool SkMatrixImageFilter::onFilterImage(Proxy* proxy,
48 const SkBitmap& source, 61 const SkBitmap& source,
49 const Context& ctx, 62 const Context& ctx,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 matrix.mapRect(&floatBounds, SkRect::Make(src)); 130 matrix.mapRect(&floatBounds, SkRect::Make(src));
118 SkIRect bounds; 131 SkIRect bounds;
119 floatBounds.roundOut(&bounds); 132 floatBounds.roundOut(&bounds);
120 if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { 133 if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) {
121 return false; 134 return false;
122 } 135 }
123 136
124 *dst = bounds; 137 *dst = bounds;
125 return true; 138 return true;
126 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698