Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/render_surface_filters.h" | 5 #include "cc/output/render_surface_filters.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "cc/output/filter_operation.h" | 10 #include "cc/output/filter_operation.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 image_filter = CreateMatrixImageFilter(matrix, image_filter); | 256 image_filter = CreateMatrixImageFilter(matrix, image_filter); |
| 257 } else if (image_filter) { | 257 } else if (image_filter) { |
| 258 image_filter = skia::AdoptRef(SkComposeImageFilter::Create( | 258 image_filter = skia::AdoptRef(SkComposeImageFilter::Create( |
| 259 op.image_filter().get(), image_filter.get())); | 259 op.image_filter().get(), image_filter.get())); |
| 260 } else { | 260 } else { |
| 261 image_filter = op.image_filter(); | 261 image_filter = op.image_filter(); |
| 262 } | 262 } |
| 263 break; | 263 break; |
| 264 } | 264 } |
| 265 case FilterOperation::ALPHA_THRESHOLD: { | 265 case FilterOperation::ALPHA_THRESHOLD: { |
| 266 skia::RefPtr<SkImageFilter> alpha_filter = skia::AdoptRef( | 266 // Scale the region by the device_scale_factor to properly handle |
| 267 SkAlphaThresholdFilter::Create( | 267 // HiDPI devices. Since there is no SkRegion scaling, we convert to |
| 268 op.region(), op.amount(), op.outer_threshold())); | 268 // a path, scale the path and then convert back to a SkRegion. |
| 269 SkPath path; | |
| 270 op.region().getBoundaryPath(&path); | |
| 271 SkMatrix scale; | |
| 272 scale.setScale(op.device_scale_factor(), op.device_scale_factor()); | |
| 273 path.transform(scale); | |
| 274 SkRegion clip; | |
| 275 clip.setRect(0, 0, size.width(), size.height()); | |
| 276 SkRegion scaled_shape; | |
| 277 scaled_shape.setPath(path, clip); | |
| 278 | |
| 279 skia::RefPtr<SkImageFilter> alpha_filter = | |
| 280 skia::AdoptRef(SkAlphaThresholdFilter::Create( | |
|
danakj
2014/06/17 21:35:28
Can we just add the scale to this SkAlphaThreshold
garykac
2014/07/10 23:02:24
Done.
| |
| 281 scaled_shape, op.amount(), op.outer_threshold())); | |
|
danakj
2014/06/17 21:42:01
If you put a transform on the ui::Layer with a sca
garykac
2014/07/10 23:02:24
I tested this and we need to pass the layer scale
| |
| 269 if (image_filter.get()) { | 282 if (image_filter.get()) { |
| 270 image_filter = skia::AdoptRef(SkComposeImageFilter::Create( | 283 image_filter = skia::AdoptRef(SkComposeImageFilter::Create( |
| 271 alpha_filter.get(), image_filter.get())); | 284 alpha_filter.get(), image_filter.get())); |
| 272 } else { | 285 } else { |
| 273 image_filter = alpha_filter; | 286 image_filter = alpha_filter; |
| 274 } | 287 } |
| 275 break; | 288 break; |
| 276 } | 289 } |
| 277 } | 290 } |
| 278 } | 291 } |
| 279 return image_filter; | 292 return image_filter; |
| 280 } | 293 } |
| 281 | 294 |
| 282 } // namespace cc | 295 } // namespace cc |
| OLD | NEW |