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

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

Issue 143163005: Revert of Revert "Serialization of SkPictureImageFilter" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/image/SkImage.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 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"
(...skipping 16 matching lines...) Expand all
27 SkSafeRef(fPicture); 27 SkSafeRef(fPicture);
28 } 28 }
29 29
30 SkPictureImageFilter::~SkPictureImageFilter() { 30 SkPictureImageFilter::~SkPictureImageFilter() {
31 SkSafeUnref(fPicture); 31 SkSafeUnref(fPicture);
32 } 32 }
33 33
34 SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer) 34 SkPictureImageFilter::SkPictureImageFilter(SkReadBuffer& buffer)
35 : INHERITED(0, buffer), 35 : INHERITED(0, buffer),
36 fPicture(NULL) { 36 fPicture(NULL) {
37 // FIXME: unflatten picture here. 37 #ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION
38 if (buffer.readBool()) {
39 fPicture = SkPicture::CreateFromBuffer(buffer);
40 }
41 #else
42 buffer.readBool();
43 #endif
38 buffer.readRect(&fRect); 44 buffer.readRect(&fRect);
39 } 45 }
40 46
41 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { 47 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
42 this->INHERITED::flatten(buffer); 48 this->INHERITED::flatten(buffer);
43 // FIXME: flatten picture here. 49 #ifdef SK_ALLOW_PICTUREIMAGEFILTER_SERIALIZATION
50 bool hasPicture = (fPicture != NULL);
51 buffer.writeBool(hasPicture);
52 if (hasPicture) {
53 fPicture->flatten(buffer);
54 }
55 #else
56 buffer.writeBool(false);
57 #endif
44 buffer.writeRect(fRect); 58 buffer.writeRect(fRect);
45 } 59 }
46 60
47 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk Matrix& matrix, 61 bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Sk Matrix& matrix,
48 SkBitmap* result, SkIPoint* offset) const { 62 SkBitmap* result, SkIPoint* offset) const {
49 if (!fPicture) { 63 if (!fPicture) {
50 offset->fX = offset->fY = 0; 64 offset->fX = offset->fY = 0;
51 return true; 65 return true;
52 } 66 }
53 67
(...skipping 17 matching lines...) Expand all
71 85
72 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop)); 86 canvas.translate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop));
73 canvas.concat(matrix); 87 canvas.concat(matrix);
74 canvas.drawPicture(*fPicture); 88 canvas.drawPicture(*fPicture);
75 89
76 *result = device.get()->accessBitmap(false); 90 *result = device.get()->accessBitmap(false);
77 offset->fX = bounds.fLeft; 91 offset->fX = bounds.fLeft;
78 offset->fY = bounds.fTop; 92 offset->fY = bounds.fTop;
79 return true; 93 return true;
80 } 94 }
OLDNEW
« no previous file with comments | « src/core/SkPicturePlayback.cpp ('k') | src/image/SkImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698