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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/filters/SkiaImageFilterBuilder.cpp

Issue 2743363006: Clean up cc/paint interfaces (Closed)
Patch Set: Rebase Created 3 years, 9 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 (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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 populateSourceGraphicImageFilters(sourceGraphic, std::move(filter), 109 populateSourceGraphicImageFilters(sourceGraphic, std::move(filter),
110 sourceGraphic->operatingColorSpace()); 110 sourceGraphic->operatingColorSpace());
111 } 111 }
112 112
113 static float kMaxMaskBufferSize = 113 static float kMaxMaskBufferSize =
114 50.f * 1024.f * 1024.f / 4.f; // 50MB / 4 bytes per pixel 114 50.f * 1024.f * 1024.f / 4.f; // 50MB / 4 bytes per pixel
115 115
116 sk_sp<SkImageFilter> buildBoxReflectFilter(const BoxReflection& reflection, 116 sk_sp<SkImageFilter> buildBoxReflectFilter(const BoxReflection& reflection,
117 sk_sp<SkImageFilter> input) { 117 sk_sp<SkImageFilter> input) {
118 sk_sp<SkImageFilter> maskedInput; 118 sk_sp<SkImageFilter> maskedInput;
119 if (PaintRecord* maskRecord = reflection.mask()) { 119 if (sk_sp<PaintRecord> maskRecord = reflection.mask()) {
120 // Since PaintRecords can't be serialized to the browser process, first 120 // Since PaintRecords can't be serialized to the browser process, first
121 // raster the mask to a bitmap, then encode it in an SkImageSource, which 121 // raster the mask to a bitmap, then encode it in an SkImageSource, which
122 // can be serialized. 122 // can be serialized.
123 SkBitmap bitmap; 123 SkBitmap bitmap;
124 const SkRect cullRect = maskRecord->cullRect(); 124 const SkRect cullRect = maskRecord->cullRect();
125 if (static_cast<float>(cullRect.width()) * 125 if (static_cast<float>(cullRect.width()) *
126 static_cast<float>(cullRect.height()) < 126 static_cast<float>(cullRect.height()) <
127 kMaxMaskBufferSize) { 127 kMaxMaskBufferSize) {
128 bitmap.allocPixels( 128 bitmap.allocPixels(
129 SkImageInfo::MakeN32Premul(cullRect.width(), cullRect.height())); 129 SkImageInfo::MakeN32Premul(cullRect.width(), cullRect.height()));
(...skipping 11 matching lines...) Expand all
141 SkBlendMode::kSrcIn, 141 SkBlendMode::kSrcIn,
142 SkOffsetImageFilter::Make(cullRect.x(), cullRect.y(), 142 SkOffsetImageFilter::Make(cullRect.x(), cullRect.y(),
143 SkImageSource::Make(image)), 143 SkImageSource::Make(image)),
144 input, &cropRect); 144 input, &cropRect);
145 } else { 145 } else {
146 // If the buffer is excessively big, give up and make an 146 // If the buffer is excessively big, give up and make an
147 // SkPictureImageFilter anyway, even if it might not render. 147 // SkPictureImageFilter anyway, even if it might not render.
148 SkImageFilter::CropRect cropRect(maskRecord->cullRect()); 148 SkImageFilter::CropRect cropRect(maskRecord->cullRect());
149 maskedInput = SkXfermodeImageFilter::Make( 149 maskedInput = SkXfermodeImageFilter::Make(
150 SkBlendMode::kSrcOver, 150 SkBlendMode::kSrcOver,
151 SkPictureImageFilter::Make(sk_ref_sp(ToSkPicture(maskRecord))), input, 151 SkPictureImageFilter::Make(ToSkPicture(maskRecord)), input,
danakj 2017/03/16 20:06:16 move()
152 &cropRect); 152 &cropRect);
153 } 153 }
154 } else { 154 } else {
155 maskedInput = input; 155 maskedInput = input;
156 } 156 }
157 sk_sp<SkImageFilter> flipImageFilter = SkImageFilter::MakeMatrixFilter( 157 sk_sp<SkImageFilter> flipImageFilter = SkImageFilter::MakeMatrixFilter(
158 reflection.reflectionMatrix(), kLow_SkFilterQuality, 158 reflection.reflectionMatrix(), kLow_SkFilterQuality,
159 std::move(maskedInput)); 159 std::move(maskedInput));
160 return SkXfermodeImageFilter::Make(SkBlendMode::kSrcOver, 160 return SkXfermodeImageFilter::Make(SkBlendMode::kSrcOver,
161 std::move(flipImageFilter), 161 std::move(flipImageFilter),
162 std::move(input), nullptr); 162 std::move(input), nullptr);
163 } 163 }
164 164
165 } // namespace SkiaImageFilterBuilder 165 } // namespace SkiaImageFilterBuilder
166 } // namespace blink 166 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698