OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 sk_sp<SkImageFilter> filter = | 106 sk_sp<SkImageFilter> filter = |
107 SkPictureImageFilter::Make(std::move(picture), cullRect); | 107 SkPictureImageFilter::Make(std::move(picture), cullRect); |
108 populateSourceGraphicImageFilters(sourceGraphic, std::move(filter), | 108 populateSourceGraphicImageFilters(sourceGraphic, std::move(filter), |
109 sourceGraphic->operatingColorSpace()); | 109 sourceGraphic->operatingColorSpace()); |
110 } | 110 } |
111 | 111 |
112 sk_sp<SkImageFilter> buildBoxReflectFilter(const BoxReflection& reflection, | 112 sk_sp<SkImageFilter> buildBoxReflectFilter(const BoxReflection& reflection, |
113 sk_sp<SkImageFilter> input) { | 113 sk_sp<SkImageFilter> input) { |
114 sk_sp<SkImageFilter> maskedInput; | 114 sk_sp<SkImageFilter> maskedInput; |
115 if (SkPicture* maskPicture = reflection.mask()) { | 115 if (SkPicture* maskPicture = reflection.mask()) { |
116 // Since SkPictures can't be serialized to the browser process, first raster
the mask to a bitmap, then | 116 // Since SkPictures can't be serialized to the browser process, first raster |
117 // encode it in an SkImageSource, which can be serialized. | 117 // the mask to a bitmap, then encode it in an SkImageSource, which can be |
| 118 // serialized. |
118 SkBitmap bitmap; | 119 SkBitmap bitmap; |
119 const SkRect cullRect = maskPicture->cullRect(); | 120 const SkRect cullRect = maskPicture->cullRect(); |
120 bitmap.allocPixels( | 121 bitmap.allocPixels( |
121 SkImageInfo::MakeN32Premul(cullRect.width(), cullRect.height())); | 122 SkImageInfo::MakeN32Premul(cullRect.width(), cullRect.height())); |
122 SkCanvas canvas(bitmap); | 123 SkCanvas canvas(bitmap); |
123 canvas.clear(SK_ColorTRANSPARENT); | 124 canvas.clear(SK_ColorTRANSPARENT); |
124 canvas.translate(-cullRect.x(), -cullRect.y()); | 125 canvas.translate(-cullRect.x(), -cullRect.y()); |
125 canvas.drawPicture(maskPicture); | 126 canvas.drawPicture(maskPicture); |
126 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap); | 127 sk_sp<SkImage> image = SkImage::MakeFromBitmap(bitmap); |
127 | 128 |
(...skipping 11 matching lines...) Expand all Loading... |
139 } | 140 } |
140 sk_sp<SkImageFilter> flipImageFilter = SkImageFilter::MakeMatrixFilter( | 141 sk_sp<SkImageFilter> flipImageFilter = SkImageFilter::MakeMatrixFilter( |
141 reflection.reflectionMatrix(), kLow_SkFilterQuality, | 142 reflection.reflectionMatrix(), kLow_SkFilterQuality, |
142 std::move(maskedInput)); | 143 std::move(maskedInput)); |
143 return SkXfermodeImageFilter::Make(nullptr, std::move(flipImageFilter), | 144 return SkXfermodeImageFilter::Make(nullptr, std::move(flipImageFilter), |
144 std::move(input), nullptr); | 145 std::move(input), nullptr); |
145 } | 146 } |
146 | 147 |
147 } // namespace SkiaImageFilterBuilder | 148 } // namespace SkiaImageFilterBuilder |
148 } // namespace blink | 149 } // namespace blink |
OLD | NEW |