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

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

Issue 134163010: Refactor read and write buffers. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: original write flags were fine Created 6 years, 10 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 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 "SkOffsetImageFilter.h" 8 #include "SkOffsetImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkDevice.h" 11 #include "SkDevice.h"
12 #include "SkFlattenableBuffers.h" 12 #include "SkReadBuffer.h"
13 #include "SkWriteBuffer.h"
13 #include "SkMatrix.h" 14 #include "SkMatrix.h"
14 #include "SkPaint.h" 15 #include "SkPaint.h"
15 16
16 bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, 17 bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
17 const SkMatrix& matrix, 18 const SkMatrix& matrix,
18 SkBitmap* result, 19 SkBitmap* result,
19 SkIPoint* offset) { 20 SkIPoint* offset) {
20 SkImageFilter* input = getInput(0); 21 SkImageFilter* input = getInput(0);
21 SkBitmap src = source; 22 SkBitmap src = source;
22 SkIPoint srcOffset = SkIPoint::Make(0, 0); 23 SkIPoint srcOffset = SkIPoint::Make(0, 0);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm , 78 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm ,
78 SkIRect* dst) { 79 SkIRect* dst) {
79 SkVector vec; 80 SkVector vec;
80 ctm.mapVectors(&vec, &fOffset, 1); 81 ctm.mapVectors(&vec, &fOffset, 1);
81 82
82 *dst = src; 83 *dst = src;
83 dst->offset(SkScalarRoundToInt(vec.fX), SkScalarRoundToInt(vec.fY)); 84 dst->offset(SkScalarRoundToInt(vec.fX), SkScalarRoundToInt(vec.fY));
84 return true; 85 return true;
85 } 86 }
86 87
87 void SkOffsetImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { 88 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const {
88 this->INHERITED::flatten(buffer); 89 this->INHERITED::flatten(buffer);
89 buffer.writePoint(fOffset); 90 buffer.writePoint(fOffset);
90 } 91 }
91 92
92 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter * input, 93 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter * input,
93 const CropRect* cropRect) : INHERITED(i nput, cropRect) { 94 const CropRect* cropRect) : INHERITED(i nput, cropRect) {
94 fOffset.set(dx, dy); 95 fOffset.set(dx, dy);
95 } 96 }
96 97
97 SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer) 98 SkOffsetImageFilter::SkOffsetImageFilter(SkReadBuffer& buffer)
98 : INHERITED(1, buffer) { 99 : INHERITED(1, buffer) {
99 buffer.readPoint(&fOffset); 100 buffer.readPoint(&fOffset);
100 buffer.validate(SkScalarIsFinite(fOffset.fX) && 101 buffer.validate(SkScalarIsFinite(fOffset.fX) &&
101 SkScalarIsFinite(fOffset.fY)); 102 SkScalarIsFinite(fOffset.fY));
102 } 103 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698