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

Unified Diff: skia/ext/opacity_draw_filter.cc

Issue 22867046: Optimize alpha software PictureDrawQuads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test and bring back Ganesh support Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
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..d60ece4e29fb13ae2c883fbf6d8468ed97a32da4
--- /dev/null
+++ b/skia/ext/opacity_draw_filter.cc
@@ -0,0 +1,25 @@
+// 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)
+ : opacity_(opacity), disable_image_filtering_(disable_image_filtering) {}
+
+OpacityDrawFilter::~OpacityDrawFilter() {}
+
+bool OpacityDrawFilter::filter(SkPaint* paint, Type type) {
+ if (opacity_ != 1.f)
+ paint->setAlpha(SkScalarRound(opacity_ * 255));
+ if (disable_image_filtering_)
+ paint->setFilterLevel(SkPaint::kNone_FilterLevel);
+ return true;
+}
+
+} // namespace skia
+
+

Powered by Google App Engine
This is Rietveld 408576698