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

Side by Side Diff: src/effects/SkBitmapSource.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 "SkBitmapSource.h" 8 #include "SkBitmapSource.h"
9 #include "SkDevice.h" 9 #include "SkDevice.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 #include "SkFlattenableBuffers.h" 11 #include "SkReadBuffer.h"
12 #include "SkWriteBuffer.h"
12 #include "SkValidationUtils.h" 13 #include "SkValidationUtils.h"
13 14
14 SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap) 15 SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap)
15 : INHERITED(0, 0), 16 : INHERITED(0, 0),
16 fBitmap(bitmap), 17 fBitmap(bitmap),
17 fSrcRect(SkRect::MakeWH(SkIntToScalar(bitmap.width()), 18 fSrcRect(SkRect::MakeWH(SkIntToScalar(bitmap.width()),
18 SkIntToScalar(bitmap.height()))), 19 SkIntToScalar(bitmap.height()))),
19 fDstRect(fSrcRect) { 20 fDstRect(fSrcRect) {
20 } 21 }
21 22
22 SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, co nst SkRect& dstRect) 23 SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, co nst SkRect& dstRect)
23 : INHERITED(0, 0), 24 : INHERITED(0, 0),
24 fBitmap(bitmap), 25 fBitmap(bitmap),
25 fSrcRect(srcRect), 26 fSrcRect(srcRect),
26 fDstRect(dstRect) { 27 fDstRect(dstRect) {
27 } 28 }
28 29
29 SkBitmapSource::SkBitmapSource(SkFlattenableReadBuffer& buffer) 30 SkBitmapSource::SkBitmapSource(SkReadBuffer& buffer)
30 : INHERITED(0, buffer) { 31 : INHERITED(0, buffer) {
31 fBitmap.unflatten(buffer); 32 fBitmap.unflatten(buffer);
32 buffer.readRect(&fSrcRect); 33 buffer.readRect(&fSrcRect);
33 buffer.readRect(&fDstRect); 34 buffer.readRect(&fDstRect);
34 buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect (fDstRect)); 35 buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect (fDstRect));
35 } 36 }
36 37
37 void SkBitmapSource::flatten(SkFlattenableWriteBuffer& buffer) const { 38 void SkBitmapSource::flatten(SkWriteBuffer& buffer) const {
38 this->INHERITED::flatten(buffer); 39 this->INHERITED::flatten(buffer);
39 fBitmap.flatten(buffer); 40 fBitmap.flatten(buffer);
40 buffer.writeRect(fSrcRect); 41 buffer.writeRect(fSrcRect);
41 buffer.writeRect(fDstRect); 42 buffer.writeRect(fDstRect);
42 } 43 }
43 44
44 bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix & matrix, 45 bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix & matrix,
45 SkBitmap* result, SkIPoint* offset) { 46 SkBitmap* result, SkIPoint* offset) {
46 SkRect bounds, dstRect; 47 SkRect bounds, dstRect;
47 fBitmap.getBounds(&bounds); 48 fBitmap.getBounds(&bounds);
(...skipping 27 matching lines...) Expand all
75 76
76 *result = device.get()->accessBitmap(false); 77 *result = device.get()->accessBitmap(false);
77 offset->fX = dstIRect.fLeft; 78 offset->fX = dstIRect.fLeft;
78 offset->fY = dstIRect.fTop; 79 offset->fY = dstIRect.fTop;
79 return true; 80 return true;
80 } 81 }
81 82
82 void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const { 83 void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const {
83 *dst = fDstRect; 84 *dst = fDstRect;
84 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698