Index: skia/ext/opacity_draw_filter.cc |
diff --git a/skia/ext/opacity_draw_filter.cc b/skia/ext/opacity_draw_filter.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1e3c7947277be8cd5618d344fd8a971bdfb8321b |
--- /dev/null |
+++ b/skia/ext/opacity_draw_filter.cc |
@@ -0,0 +1,27 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "skia/ext/opacity_draw_filter.h" |
+#include "third_party/skia/include/core/SkPaint.h" |
+ |
+namespace skia { |
+ |
+OpacityDrawFilter::OpacityDrawFilter(float opacity, |
+ bool disable_image_filtering) |
+ : alpha_(SkScalarRound(opacity * 255)), |
+ disable_image_filtering_(disable_image_filtering) {} |
+ |
+OpacityDrawFilter::~OpacityDrawFilter() {} |
+ |
+bool OpacityDrawFilter::filter(SkPaint* paint, Type type) { |
+ if (alpha_ < 255) |
+ paint->setAlpha(alpha_); |
+ if (disable_image_filtering_) |
+ paint->setFilterLevel(SkPaint::kNone_FilterLevel); |
+ return true; |
+} |
+ |
+} // namespace skia |
+ |
+ |