OLD | NEW |
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 "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
12 #include "SkSurfaceProps.h" | 12 #include "SkSurfaceProps.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 #include "SkValidationUtils.h" | 14 #include "SkValidationUtils.h" |
15 | 15 |
16 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture) | 16 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture) |
17 : INHERITED(0, 0, NULL) | 17 : INHERITED(0, 0, nullptr) |
18 , fPicture(SkSafeRef(picture)) | 18 , fPicture(SkSafeRef(picture)) |
19 , fCropRect(picture ? picture->cullRect() : SkRect::MakeEmpty()) | 19 , fCropRect(picture ? picture->cullRect() : SkRect::MakeEmpty()) |
20 , fPictureResolution(kDeviceSpace_PictureResolution) | 20 , fPictureResolution(kDeviceSpace_PictureResolution) |
21 , fFilterQuality(kLow_SkFilterQuality) { | 21 , fFilterQuality(kLow_SkFilterQuality) { |
22 } | 22 } |
23 | 23 |
24 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, const SkRec
t& cropRect, | 24 SkPictureImageFilter::SkPictureImageFilter(const SkPicture* picture, const SkRec
t& cropRect, |
25 PictureResolution pictureResolution, | 25 PictureResolution pictureResolution, |
26 SkFilterQuality filterQuality) | 26 SkFilterQuality filterQuality) |
27 : INHERITED(0, 0, NULL) | 27 : INHERITED(0, 0, nullptr) |
28 , fPicture(SkSafeRef(picture)) | 28 , fPicture(SkSafeRef(picture)) |
29 , fCropRect(cropRect) | 29 , fCropRect(cropRect) |
30 , fPictureResolution(pictureResolution) | 30 , fPictureResolution(pictureResolution) |
31 , fFilterQuality(filterQuality) { | 31 , fFilterQuality(filterQuality) { |
32 } | 32 } |
33 | 33 |
34 SkPictureImageFilter::~SkPictureImageFilter() { | 34 SkPictureImageFilter::~SkPictureImageFilter() { |
35 SkSafeUnref(fPicture); | 35 SkSafeUnref(fPicture); |
36 } | 36 } |
37 | 37 |
(...skipping 26 matching lines...) Expand all Loading... |
64 } | 64 } |
65 return CreateForLocalSpace(picture, cropRect, filterQuality); | 65 return CreateForLocalSpace(picture, cropRect, filterQuality); |
66 } | 66 } |
67 return Create(picture, cropRect); | 67 return Create(picture, cropRect); |
68 } | 68 } |
69 | 69 |
70 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { | 70 void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const { |
71 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable
d()) { | 71 if (buffer.isCrossProcess() && SkPicture::PictureIOSecurityPrecautionsEnable
d()) { |
72 buffer.writeBool(false); | 72 buffer.writeBool(false); |
73 } else { | 73 } else { |
74 bool hasPicture = (fPicture != NULL); | 74 bool hasPicture = (fPicture != nullptr); |
75 buffer.writeBool(hasPicture); | 75 buffer.writeBool(hasPicture); |
76 if (hasPicture) { | 76 if (hasPicture) { |
77 fPicture->flatten(buffer); | 77 fPicture->flatten(buffer); |
78 } | 78 } |
79 } | 79 } |
80 buffer.writeRect(fCropRect); | 80 buffer.writeRect(fCropRect); |
81 buffer.writeInt(fPictureResolution); | 81 buffer.writeInt(fPictureResolution); |
82 if (kLocalSpace_PictureResolution == fPictureResolution) { | 82 if (kLocalSpace_PictureResolution == fPictureResolution) { |
83 buffer.writeInt(fFilterQuality); | 83 buffer.writeInt(fFilterQuality); |
84 } | 84 } |
(...skipping 12 matching lines...) Expand all Loading... |
97 if (!bounds.intersect(ctx.clipBounds())) { | 97 if (!bounds.intersect(ctx.clipBounds())) { |
98 return false; | 98 return false; |
99 } | 99 } |
100 | 100 |
101 if (bounds.isEmpty()) { | 101 if (bounds.isEmpty()) { |
102 offset->fX = offset->fY = 0; | 102 offset->fX = offset->fY = 0; |
103 return true; | 103 return true; |
104 } | 104 } |
105 | 105 |
106 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); | 106 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds
.height())); |
107 if (NULL == device.get()) { | 107 if (nullptr == device.get()) { |
108 return false; | 108 return false; |
109 } | 109 } |
110 | 110 |
111 if (kDeviceSpace_PictureResolution == fPictureResolution || | 111 if (kDeviceSpace_PictureResolution == fPictureResolution || |
112 0 == (ctx.ctm().getType() & ~SkMatrix::kTranslate_Mask)) { | 112 0 == (ctx.ctm().getType() & ~SkMatrix::kTranslate_Mask)) { |
113 this->drawPictureAtDeviceResolution(device.get(), bounds, ctx); | 113 this->drawPictureAtDeviceResolution(device.get(), bounds, ctx); |
114 } else { | 114 } else { |
115 this->drawPictureAtLocalResolution(proxy, device.get(), bounds, ctx); | 115 this->drawPictureAtLocalResolution(proxy, device.get(), bounds, ctx); |
116 } | 116 } |
117 | 117 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 str->appendf("crop: (%f,%f,%f,%f) ", | 167 str->appendf("crop: (%f,%f,%f,%f) ", |
168 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB
ottom); | 168 fCropRect.fLeft, fCropRect.fTop, fCropRect.fRight, fCropRect.fB
ottom); |
169 if (fPicture) { | 169 if (fPicture) { |
170 str->appendf("picture: (%f,%f,%f,%f)", | 170 str->appendf("picture: (%f,%f,%f,%f)", |
171 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, | 171 fPicture->cullRect().fLeft, fPicture->cullRect().fTop, |
172 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); | 172 fPicture->cullRect().fRight, fPicture->cullRect().fBottom); |
173 } | 173 } |
174 str->append(")"); | 174 str->append(")"); |
175 } | 175 } |
176 #endif | 176 #endif |
OLD | NEW |