Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / skia / ext / opacity_draw_filter.cc
blob10ed9e8f6c15f06ca3230711a0a71287a912ef85
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "skia/ext/opacity_draw_filter.h"
6 #include "third_party/skia/include/core/SkPaint.h"
8 namespace skia {
10 OpacityDrawFilter::OpacityDrawFilter(float opacity,
11 bool disable_image_filtering)
12 : alpha_(SkScalarRoundToInt(opacity * 255)),
13 disable_image_filtering_(disable_image_filtering) {}
15 OpacityDrawFilter::~OpacityDrawFilter() {}
17 bool OpacityDrawFilter::filter(SkPaint* paint, Type type) {
18 if (alpha_ < 255)
19 paint->setAlpha(alpha_);
20 if (disable_image_filtering_)
21 paint->setFilterQuality(kNone_SkFilterQuality);
22 return true;
25 } // namespace skia