diff options
author | Zeno Albisser <zeno.albisser@digia.com> | 2013-11-21 14:09:57 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2013-11-29 15:14:36 +0100 |
commit | eb32ba6f51d0c21d58cd7d89785285ff8fa64624 (patch) | |
tree | 2c7c940e1dbee81b89d935626110816b494aa32c /chromium/skia/ext | |
parent | 9427c1a0222ebd67efef1a2c7990a0fa5c9aac84 (diff) | |
download | qtwebengine-chromium-eb32ba6f51d0c21d58cd7d89785285ff8fa64624.tar.gz |
Update chromium to branch 1599.
Change-Id: I04e775a946a208bb4500d3b722bcb05c82b9d7cb
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/skia/ext')
-rw-r--r-- | chromium/skia/ext/opacity_draw_filter.cc | 27 | ||||
-rw-r--r-- | chromium/skia/ext/opacity_draw_filter.h | 33 |
2 files changed, 60 insertions, 0 deletions
diff --git a/chromium/skia/ext/opacity_draw_filter.cc b/chromium/skia/ext/opacity_draw_filter.cc new file mode 100644 index 00000000000..7132b5df076 --- /dev/null +++ b/chromium/skia/ext/opacity_draw_filter.cc @@ -0,0 +1,27 @@ +// Copyright 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 + + diff --git a/chromium/skia/ext/opacity_draw_filter.h b/chromium/skia/ext/opacity_draw_filter.h new file mode 100644 index 00000000000..a2a686cad8d --- /dev/null +++ b/chromium/skia/ext/opacity_draw_filter.h @@ -0,0 +1,33 @@ +// Copyright 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. + +#ifndef SKIA_EXT_OPACITY_DRAW_FILTER_H +#define SKIA_EXT_OPACITY_DRAW_FILTER_H + +#include "base/values.h" +#include "third_party/skia/include/core/SkDrawFilter.h" + +class SkPaint; + +namespace skia { + +// This filter allows setting an opacity on every draw call to a canvas, and to +// disable image filtering. Note that the opacity setting is only correct in +// very limited conditions: when there is only zero or one opaque, nonlayer +// draw for every pixel in the surface. +class SK_API OpacityDrawFilter : public SkDrawFilter { + public: + OpacityDrawFilter(float opacity, bool disable_image_filtering); + virtual ~OpacityDrawFilter(); + virtual bool filter(SkPaint* paint, SkDrawFilter::Type type) OVERRIDE; + + private: + int alpha_; + bool disable_image_filtering_; +}; + +} // namespace skia + +#endif // SKIA_EXT_OPACITY_DRAW_FILTER_H + |