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

Side by Side Diff: src/effects/SkPictureImageFilter.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 2013 The Android Open Source Project 2 * Copyright 2013 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 "SkPictureImageFilter.h" 8 #include "SkPictureImageFilter.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 SkPictureImageFilter::SkPictureImageFilter(SkPicture* picture) 15 SkPictureImageFilter::SkPictureImageFilter(SkPicture* picture)
15 : INHERITED(0, 0), 16 : INHERITED(0, 0),
16 fPicture(picture), 17 fPicture(picture),
17 fRect(SkRect::MakeWH(picture ? SkIntToScalar(picture->width()) : 0, 18 fRect(SkRect::MakeWH(picture ? SkIntToScalar(picture->width()) : 0,
18 picture ? SkIntToScalar(picture->height()) : 0)) { 19 picture ? SkIntToScalar(picture->height()) : 0)) {
19 SkSafeRef(fPicture); 20 SkSafeRef(fPicture);
20 } 21 }
21 22
22 SkPictureImageFilter::SkPictureImageFilter(SkPicture* picture, const SkRect& rec t) 23 SkPictureImageFilter::SkPictureImageFilter(SkPicture* picture, const SkRect& rec t)
23 : INHERITED(0, 0), 24 : INHERITED(0, 0),
24 fPicture(picture), 25 fPicture(picture),
25 fRect(rect) { 26 fRect(rect) {
26 SkSafeRef(fPicture); 27 SkSafeRef(fPicture);
27 } 28 }
28 29
29 SkPictureImageFilter::~SkPictureImageFilter() { 30 SkPictureImageFilter::~SkPictureImageFilter() {
30 SkSafeUnref(fPicture); 31 SkSafeUnref(fPicture);
31 } 32 }
32 33
33 SkPictureImageFilter::SkPictureImageFilter(SkFlattenableReadBuffer& buffer) 34 SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer)
34 : INHERITED(0, buffer), 35 : INHERITED(0, buffer),
35 fPicture(NULL) { 36 fPicture(NULL) {
36 // FIXME: unflatten picture here. 37 // FIXME: unflatten picture here.
37 buffer.readRect(&fRect); 38 buffer.readRect(&fRect);
38 } 39 }
39 40
40 void SkPictureImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { 41 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
41 this->INHERITED::flatten(buffer); 42 this->INHERITED::flatten(buffer);
42 // FIXME: flatten picture here. 43 // FIXME: flatten picture here.
43 buffer.writeRect(fRect); 44 buffer.writeRect(fRect);
44 } 45 }
45 46
46 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk Matrix& matrix, 47 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk Matrix& matrix,
47 SkBitmap* result, SkIPoint* offset) { 48 SkBitmap* result, SkIPoint* offset) {
48 if (!fPicture) { 49 if (!fPicture) {
49 offset->fX = offset->fY = 0; 50 offset->fX = offset->fY = 0;
50 return true; 51 return true;
(...skipping 19 matching lines...) Expand all
70 71
71 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); 72 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));
72 canvas.concat(matrix); 73 canvas.concat(matrix);
73 canvas.drawPicture(*fPicture); 74 canvas.drawPicture(*fPicture);
74 75
75 *result = device.get()->accessBitmap(false); 76 *result = device.get()->accessBitmap(false);
76 offset->fX = bounds.fLeft; 77 offset->fX = bounds.fLeft;
77 offset->fY = bounds.fTop; 78 offset->fY = bounds.fTop;
78 return true; 79 return true;
79 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698