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

Side by Side Diff: src/effects/SkColorFilterImageFilter.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
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkColorMatrixFilter.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 2012 The Android Open Source Project 2 * Copyright 2012 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 "SkColorFilterImageFilter.h" 8 #include "SkColorFilterImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect)); 76 return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect));
77 } 77 }
78 78
79 SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf, 79 SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf,
80 SkImageFilter* input, const CropRect* cropRect) 80 SkImageFilter* input, const CropRect* cropRect)
81 : INHERITED(1, &input, cropRect), fColorFilter(cf) { 81 : INHERITED(1, &input, cropRect), fColorFilter(cf) {
82 SkASSERT(cf); 82 SkASSERT(cf);
83 SkSafeRef(cf); 83 SkSafeRef(cf);
84 } 84 }
85 85
86 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING
86 SkColorFilterImageFilter::SkColorFilterImageFilter(SkReadBuffer& buffer) 87 SkColorFilterImageFilter::SkColorFilterImageFilter(SkReadBuffer& buffer)
87 : INHERITED(1, buffer) { 88 : INHERITED(1, buffer) {
88 fColorFilter = buffer.readColorFilter(); 89 fColorFilter = buffer.readColorFilter();
89 } 90 }
91 #endif
92
93 SkFlattenable* SkColorFilterImageFilter::CreateProc(SkReadBuffer& buffer) {
94 Common common;
95 if (!common.unflatten(buffer, 1)) {
96 return NULL;
97 }
98 SkAutoTUnref<SkColorFilter> cf(buffer.readColorFilter());
99 return Create(cf, common.inputAt(0), &common.cropRect());
Stephen White 2014/07/18 15:43:32 I see you've removed the validate() here (which is
reed1 2014/07/18 16:18:47 It is a new question about where/when to perform v
100 }
90 101
91 void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const { 102 void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const {
92 this->INHERITED::flatten(buffer); 103 this->flattenCommon(buffer);
93
94 buffer.writeFlattenable(fColorFilter); 104 buffer.writeFlattenable(fColorFilter);
95 } 105 }
96 106
97 SkColorFilterImageFilter::~SkColorFilterImageFilter() { 107 SkColorFilterImageFilter::~SkColorFilterImageFilter() {
98 SkSafeUnref(fColorFilter); 108 SkSafeUnref(fColorFilter);
99 } 109 }
100 110
101 bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc e, 111 bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc e,
102 const Context& ctx, 112 const Context& ctx,
103 SkBitmap* result, 113 SkBitmap* result,
(...skipping 29 matching lines...) Expand all
133 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const { 143 bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const {
134 if (!cropRectIsSet()) { 144 if (!cropRectIsSet()) {
135 if (filter) { 145 if (filter) {
136 *filter = fColorFilter; 146 *filter = fColorFilter;
137 fColorFilter->ref(); 147 fColorFilter->ref();
138 } 148 }
139 return true; 149 return true;
140 } 150 }
141 return false; 151 return false;
142 } 152 }
OLDNEW
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkColorMatrixFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698