Start propagating the dynamic-range-limit property to the rendering code
Intent to Prototype: https://groups.google.com/a/chromium.org/g/blink-dev/c/jzSeH70To2s/
Bug: 1470298
Change-Id: Id5cd8c48773b40c8e036532a18fab4eb2e5604b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4802152
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Sami Boukortt <sboukortt@google.com>
Cr-Commit-Position: refs/heads/main@{#1205947}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e53e54a4f3
commit
33131cd496
cc/paint
third_party/blink/renderer
@ -187,6 +187,7 @@ bool PaintFlags::EqualsForTesting(const PaintFlags& other) const {
|
||||
getStrokeJoin() == other.getStrokeJoin() &&
|
||||
getStyle() == other.getStyle() &&
|
||||
getFilterQuality() == other.getFilterQuality() &&
|
||||
getDynamicRangeLimit() == other.getDynamicRangeLimit() &&
|
||||
AreSkFlattenablesEqualForTesting(path_effect_, // IN-TEST
|
||||
other.path_effect_) &&
|
||||
AreSkFlattenablesEqualForTesting(mask_filter_, // IN-TEST
|
||||
|
@ -80,6 +80,18 @@ class CC_PAINT_EXPORT PaintFlags {
|
||||
ALWAYS_INLINE FilterQuality getFilterQuality() const {
|
||||
return static_cast<FilterQuality>(bitfields_.filter_quality_);
|
||||
}
|
||||
enum class DynamicRangeLimit {
|
||||
kStandard,
|
||||
kHigh,
|
||||
kConstrainedHigh,
|
||||
kLast = kConstrainedHigh,
|
||||
};
|
||||
ALWAYS_INLINE void setDynamicRangeLimit(DynamicRangeLimit limit) {
|
||||
bitfields_.dynamic_range_limit_ = static_cast<uint32_t>(limit);
|
||||
}
|
||||
ALWAYS_INLINE DynamicRangeLimit getDynamicRangeLimit() const {
|
||||
return static_cast<DynamicRangeLimit>(bitfields_.dynamic_range_limit_);
|
||||
}
|
||||
ALWAYS_INLINE bool useDarkModeForImage() const {
|
||||
return bitfields_.use_dark_mode_for_image_;
|
||||
}
|
||||
@ -213,6 +225,7 @@ class CC_PAINT_EXPORT PaintFlags {
|
||||
uint32_t join_type_ : 2;
|
||||
uint32_t style_ : 2;
|
||||
uint32_t filter_quality_ : 2;
|
||||
uint32_t dynamic_range_limit_ : 2;
|
||||
// Specifies whether the compositor should use a dark mode filter when
|
||||
// rasterizing image on the draw op with this PaintFlags.
|
||||
uint32_t use_dark_mode_for_image_ : 1;
|
||||
|
@ -913,6 +913,12 @@ InterpolationQuality BackgroundImageGeometry::ImageInterpolationQuality()
|
||||
return box_->StyleRef().GetInterpolationQuality();
|
||||
}
|
||||
|
||||
cc::PaintFlags::DynamicRangeLimit BackgroundImageGeometry::DynamicRangeLimit()
|
||||
const {
|
||||
return static_cast<cc::PaintFlags::DynamicRangeLimit>(
|
||||
box_->StyleRef().DynamicRangeLimit());
|
||||
}
|
||||
|
||||
PhysicalOffset BackgroundImageGeometry::OffsetInBackground(
|
||||
const FillLayer& fill_layer) const {
|
||||
if (ShouldUseFixedAttachment(fill_layer))
|
||||
|
@ -92,6 +92,7 @@ class BackgroundImageGeometry {
|
||||
const Document& ImageDocument() const;
|
||||
const ComputedStyle& ImageStyle(const ComputedStyle& fragment_style) const;
|
||||
InterpolationQuality ImageInterpolationQuality() const;
|
||||
cc::PaintFlags::DynamicRangeLimit DynamicRangeLimit() const;
|
||||
|
||||
bool CanCompositeBackgroundAttachmentFixed() const;
|
||||
|
||||
@ -171,6 +172,7 @@ class BackgroundImageGeometry {
|
||||
// - ImageClient() uses box_ if painting view, otherwise positioning_box_;
|
||||
// - ImageStyle() uses positioning_box_;
|
||||
// - ImageInterpolationQuality() uses box_;
|
||||
// - DynamicRangeLimit() uses box_;
|
||||
// - FillLayers come from box_ if painting view, otherwise positioning_box_.
|
||||
const LayoutBoxModelObject* const box_;
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/graphics_context_state_saver.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_interpolation_quality.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_image_rendering_settings.h"
|
||||
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
|
||||
#include "ui/gfx/geometry/rect_conversions.h"
|
||||
|
||||
@ -1114,14 +1114,15 @@ void BoxPainterBase::PaintFillLayer(const PaintInfo& paint_info,
|
||||
|
||||
scoped_refptr<Image> image;
|
||||
SkBlendMode composite_op = SkBlendMode::kSrcOver;
|
||||
absl::optional<ScopedInterpolationQuality> interpolation_quality_context;
|
||||
absl::optional<ScopedImageRenderingSettings> image_rendering_settings_context;
|
||||
if (fill_layer_info.should_paint_image) {
|
||||
geometry.Calculate(paint_info, bg_layer, scrolled_paint_rect);
|
||||
image = fill_layer_info.image->GetImage(
|
||||
geometry.ImageClient(), geometry.ImageDocument(),
|
||||
geometry.ImageStyle(style_), gfx::SizeF(geometry.TileSize()));
|
||||
interpolation_quality_context.emplace(context,
|
||||
geometry.ImageInterpolationQuality());
|
||||
image_rendering_settings_context.emplace(
|
||||
context, geometry.ImageInterpolationQuality(),
|
||||
geometry.DynamicRangeLimit());
|
||||
|
||||
if (ShouldApplyBlendOperation(fill_layer_info, bg_layer)) {
|
||||
composite_op = WebCoreCompositeToSkiaComposite(bg_layer.Composite(),
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "third_party/blink/renderer/platform/geometry/layout_point.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_interpolation_quality.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_image_rendering_settings.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -76,8 +76,10 @@ void HTMLCanvasPainter::PaintReplaced(const PaintInfo& paint_info,
|
||||
|
||||
BoxDrawingRecorder recorder(context, layout_html_canvas_, paint_info.phase,
|
||||
paint_offset);
|
||||
ScopedInterpolationQuality interpolation_quality_scope(
|
||||
context, InterpolationQualityForCanvas(layout_html_canvas_.StyleRef()));
|
||||
ScopedImageRenderingSettings image_rendering_settings_scope(
|
||||
context, InterpolationQualityForCanvas(layout_html_canvas_.StyleRef()),
|
||||
static_cast<cc::PaintFlags::DynamicRangeLimit>(
|
||||
layout_html_canvas_.StyleRef().DynamicRangeLimit()));
|
||||
canvas->Paint(context, paint_rect, paint_info.ShouldOmitCompositingInfo());
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/path.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/placeholder_image.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_interpolation_quality.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_image_rendering_settings.h"
|
||||
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
|
||||
|
||||
namespace blink {
|
||||
@ -276,8 +276,10 @@ void ImagePainter::PaintIntoRect(GraphicsContext& context,
|
||||
inspector_paint_image_event::Data, layout_image_, src_rect,
|
||||
gfx::RectF(dest_rect));
|
||||
|
||||
ScopedInterpolationQuality interpolation_quality_scope(
|
||||
context, layout_image_.StyleRef().GetInterpolationQuality());
|
||||
ScopedImageRenderingSettings image_rendering_settings_scope(
|
||||
context, layout_image_.StyleRef().GetInterpolationQuality(),
|
||||
static_cast<cc::PaintFlags::DynamicRangeLimit>(
|
||||
layout_image_.StyleRef().DynamicRangeLimit()));
|
||||
|
||||
Node* node = layout_image_.GetNode();
|
||||
auto* image_element = DynamicTo<HTMLImageElement>(node);
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "third_party/blink/renderer/core/style/computed_style.h"
|
||||
#include "third_party/blink/renderer/core/style/nine_piece_image.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_interpolation_quality.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_image_rendering_settings.h"
|
||||
#include "ui/gfx/geometry/outsets.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
@ -120,8 +120,10 @@ void PaintPieces(GraphicsContext& context,
|
||||
// TODO(penglin): We need to make a single classification for the entire grid
|
||||
auto image_auto_dark_mode = ImageAutoDarkMode::Disabled();
|
||||
|
||||
ScopedInterpolationQuality interpolation_quality_scope(
|
||||
context, style.GetInterpolationQuality());
|
||||
ScopedImageRenderingSettings image_rendering_settings_scope(
|
||||
context, style.GetInterpolationQuality(),
|
||||
static_cast<cc::PaintFlags::DynamicRangeLimit>(
|
||||
style.DynamicRangeLimit()));
|
||||
for (NinePiece piece = kMinPiece; piece < kMaxPiece; ++piece) {
|
||||
NinePieceImageGrid::NinePieceDrawInfo draw_info =
|
||||
grid.GetNinePieceDrawInfo(piece);
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "third_party/blink/renderer/core/svg/svg_image_element.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_interpolation_quality.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_image_rendering_settings.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
@ -111,9 +111,11 @@ void SVGImagePainter::PaintForeground(const PaintInfo& paint_info) {
|
||||
PaintTiming& timing = PaintTiming::From(layout_svg_image_.GetDocument());
|
||||
timing.MarkFirstContentfulPaint();
|
||||
|
||||
ScopedInterpolationQuality interpolation_quality_scope(
|
||||
ScopedImageRenderingSettings image_rendering_settings_scope(
|
||||
paint_info.context,
|
||||
layout_svg_image_.StyleRef().GetInterpolationQuality());
|
||||
layout_svg_image_.StyleRef().GetInterpolationQuality(),
|
||||
static_cast<cc::PaintFlags::DynamicRangeLimit>(
|
||||
layout_svg_image_.StyleRef().DynamicRangeLimit()));
|
||||
Image::ImageDecodingMode decode_mode =
|
||||
image_element->GetDecodingModeForPainting(image->paint_image_id());
|
||||
auto image_auto_dark_mode = ImageClassifierHelper::GetImageAutoDarkMode(
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "build/build_config.h"
|
||||
#include "cc/input/overscroll_behavior.h"
|
||||
#include "cc/paint/paint_flags.h"
|
||||
#include "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-blink.h"
|
||||
#include "third_party/blink/renderer/core/animation/css/css_animation_data.h"
|
||||
#include "third_party/blink/renderer/core/animation/css/css_transition_data.h"
|
||||
@ -2854,4 +2855,11 @@ STATIC_ASSERT_ENUM(cc::OverscrollBehavior::Type::kContain,
|
||||
STATIC_ASSERT_ENUM(cc::OverscrollBehavior::Type::kNone,
|
||||
EOverscrollBehavior::kNone);
|
||||
|
||||
STATIC_ASSERT_ENUM(cc::PaintFlags::DynamicRangeLimit::kStandard,
|
||||
EDynamicRangeLimit::kStandard);
|
||||
STATIC_ASSERT_ENUM(cc::PaintFlags::DynamicRangeLimit::kHigh,
|
||||
EDynamicRangeLimit::kHigh);
|
||||
STATIC_ASSERT_ENUM(cc::PaintFlags::DynamicRangeLimit::kConstrainedHigh,
|
||||
EDynamicRangeLimit::kConstrainedHigh);
|
||||
|
||||
} // namespace blink
|
||||
|
@ -284,8 +284,8 @@
|
||||
{
|
||||
name: "DiffNeedsPaintInvalidation",
|
||||
fields_to_diff: ["-webkit-user-modify", "user-select", "image-rendering",
|
||||
"column-rule-style", "column-rule-width", "column-rule-color",
|
||||
"-internal-visited-column-rule-color",
|
||||
"dynamic-range-limit", "column-rule-style", "column-rule-width",
|
||||
"column-rule-color", "-internal-visited-column-rule-color",
|
||||
"-webkit-user-drag", "object-fit", "object-position",
|
||||
"mix-blend-mode", "isolation", "Mask", "MaskBoxImage", "mask", "mask-type",
|
||||
"stop-color", "stop-opacity", "flood-color", "flood-opacity",
|
||||
|
2
third_party/blink/renderer/platform/BUILD.gn
vendored
2
third_party/blink/renderer/platform/BUILD.gn
vendored
@ -1149,7 +1149,7 @@ component("platform") {
|
||||
"graphics/replaying_canvas.cc",
|
||||
"graphics/replaying_canvas.h",
|
||||
"graphics/resource_id_traits.h",
|
||||
"graphics/scoped_interpolation_quality.h",
|
||||
"graphics/scoped_image_rendering_settings.h",
|
||||
"graphics/scoped_raster_timer.cc",
|
||||
"graphics/scoped_raster_timer.h",
|
||||
"graphics/scrollbar_theme_settings.cc",
|
||||
|
@ -258,6 +258,13 @@ class PLATFORM_EXPORT GraphicsContext {
|
||||
return ImmutableState()->GetInterpolationQuality();
|
||||
}
|
||||
|
||||
void SetDynamicRangeLimit(cc::PaintFlags::DynamicRangeLimit limit) {
|
||||
MutableState()->SetDynamicRangeLimit(limit);
|
||||
}
|
||||
cc::PaintFlags::DynamicRangeLimit DynamicRangeLimit() const {
|
||||
return ImmutableState()->GetDynamicRangeLimit();
|
||||
}
|
||||
|
||||
SkSamplingOptions ImageSamplingOptions() const {
|
||||
return cc::PaintFlags::FilterQualityToSkSamplingOptions(
|
||||
static_cast<cc::PaintFlags::FilterQuality>(
|
||||
|
@ -21,6 +21,7 @@ static inline cc::PaintFlags::FilterQuality FilterQualityForPaint(
|
||||
GraphicsContextState::GraphicsContextState()
|
||||
: text_drawing_mode_(kTextModeFill),
|
||||
interpolation_quality_(kInterpolationDefault),
|
||||
dynamic_range_limit_(cc::PaintFlags::DynamicRangeLimit::kHigh),
|
||||
save_count_(0),
|
||||
should_antialias_(true) {
|
||||
stroke_flags_.setStyle(cc::PaintFlags::kStroke_Style);
|
||||
@ -29,8 +30,10 @@ GraphicsContextState::GraphicsContextState()
|
||||
stroke_flags_.setStrokeJoin(cc::PaintFlags::kDefault_Join);
|
||||
stroke_flags_.setStrokeMiter(SkFloatToScalar(stroke_data_.MiterLimit()));
|
||||
stroke_flags_.setFilterQuality(FilterQualityForPaint(interpolation_quality_));
|
||||
stroke_flags_.setDynamicRangeLimit(dynamic_range_limit_);
|
||||
stroke_flags_.setAntiAlias(should_antialias_);
|
||||
fill_flags_.setFilterQuality(FilterQualityForPaint(interpolation_quality_));
|
||||
fill_flags_.setDynamicRangeLimit(dynamic_range_limit_);
|
||||
fill_flags_.setAntiAlias(should_antialias_);
|
||||
}
|
||||
|
||||
@ -40,6 +43,7 @@ GraphicsContextState::GraphicsContextState(const GraphicsContextState& other)
|
||||
stroke_data_(other.stroke_data_),
|
||||
text_drawing_mode_(other.text_drawing_mode_),
|
||||
interpolation_quality_(other.interpolation_quality_),
|
||||
dynamic_range_limit_(other.dynamic_range_limit_),
|
||||
save_count_(0),
|
||||
should_antialias_(other.should_antialias_) {}
|
||||
|
||||
@ -111,6 +115,13 @@ void GraphicsContextState::SetInterpolationQuality(
|
||||
fill_flags_.setFilterQuality(FilterQualityForPaint(quality));
|
||||
}
|
||||
|
||||
void GraphicsContextState::SetDynamicRangeLimit(
|
||||
cc::PaintFlags::DynamicRangeLimit limit) {
|
||||
dynamic_range_limit_ = limit;
|
||||
stroke_flags_.setDynamicRangeLimit(limit);
|
||||
fill_flags_.setDynamicRangeLimit(limit);
|
||||
}
|
||||
|
||||
void GraphicsContextState::SetShouldAntialias(bool should_antialias) {
|
||||
should_antialias_ = should_antialias;
|
||||
stroke_flags_.setAntiAlias(should_antialias);
|
||||
|
@ -112,6 +112,11 @@ class PLATFORM_EXPORT GraphicsContextState final {
|
||||
}
|
||||
void SetInterpolationQuality(InterpolationQuality);
|
||||
|
||||
cc::PaintFlags::DynamicRangeLimit GetDynamicRangeLimit() const {
|
||||
return dynamic_range_limit_;
|
||||
}
|
||||
void SetDynamicRangeLimit(cc::PaintFlags::DynamicRangeLimit limit);
|
||||
|
||||
bool ShouldAntialias() const { return should_antialias_; }
|
||||
void SetShouldAntialias(bool);
|
||||
|
||||
@ -129,6 +134,7 @@ class PLATFORM_EXPORT GraphicsContextState final {
|
||||
TextDrawingModeFlags text_drawing_mode_;
|
||||
|
||||
InterpolationQuality interpolation_quality_;
|
||||
cc::PaintFlags::DynamicRangeLimit dynamic_range_limit_;
|
||||
|
||||
uint16_t save_count_;
|
||||
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "third_party/blink/renderer/platform/graphics/paint/paint_image.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/paint/paint_recorder.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/paint/paint_shader.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/scoped_interpolation_quality.h"
|
||||
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
|
||||
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
|
||||
|
53
third_party/blink/renderer/platform/graphics/scoped_image_rendering_settings.h
vendored
Normal file
53
third_party/blink/renderer/platform/graphics/scoped_image_rendering_settings.h
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright 2017 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_SCOPED_IMAGE_RENDERING_SETTINGS_H_
|
||||
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_SCOPED_IMAGE_RENDERING_SETTINGS_H_
|
||||
|
||||
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/graphics_types.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
// Helper to update the image rendering settings of a GraphicsContext within the
|
||||
// current scope. Be careful when mixing with other GraphicsContext mechanisms
|
||||
// that save/restore state (like GraphicsContextStateSaver or the Save/Restore
|
||||
// methods) to ensure the restoration behavior is the expected one.
|
||||
class ScopedImageRenderingSettings {
|
||||
STACK_ALLOCATED();
|
||||
|
||||
public:
|
||||
ScopedImageRenderingSettings(
|
||||
GraphicsContext& context,
|
||||
InterpolationQuality interpolation_quality,
|
||||
cc::PaintFlags::DynamicRangeLimit dynamic_range_limit)
|
||||
: context_(context),
|
||||
previous_interpolation_quality_(context.ImageInterpolationQuality()),
|
||||
previous_dynamic_range_limit_(context.DynamicRangeLimit()) {
|
||||
if (previous_interpolation_quality_ != interpolation_quality) {
|
||||
context_.SetImageInterpolationQuality(interpolation_quality);
|
||||
}
|
||||
if (previous_dynamic_range_limit_ != dynamic_range_limit) {
|
||||
context_.SetDynamicRangeLimit(dynamic_range_limit);
|
||||
}
|
||||
}
|
||||
|
||||
~ScopedImageRenderingSettings() {
|
||||
if (previous_interpolation_quality_ !=
|
||||
context_.ImageInterpolationQuality()) {
|
||||
context_.SetImageInterpolationQuality(previous_interpolation_quality_);
|
||||
context_.SetDynamicRangeLimit(previous_dynamic_range_limit_);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
GraphicsContext& context_;
|
||||
const InterpolationQuality previous_interpolation_quality_;
|
||||
const cc::PaintFlags::DynamicRangeLimit previous_dynamic_range_limit_;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_SCOPED_IMAGE_RENDERING_SETTINGS_H_
|
@ -1,43 +0,0 @@
|
||||
// Copyright 2017 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_SCOPED_INTERPOLATION_QUALITY_H_
|
||||
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_SCOPED_INTERPOLATION_QUALITY_H_
|
||||
|
||||
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
|
||||
#include "third_party/blink/renderer/platform/graphics/graphics_types.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
|
||||
|
||||
namespace blink {
|
||||
|
||||
// Helper to update the interpolation quality setting of a GraphicsContext
|
||||
// within the current scope. Be careful when mixing with other GraphicsContext
|
||||
// mechanisms that save/restore state (like GraphicsContextStateSaver or the
|
||||
// Save/Restore methods) to ensure the restoration behavior is the expected
|
||||
// one.
|
||||
class ScopedInterpolationQuality {
|
||||
STACK_ALLOCATED();
|
||||
|
||||
public:
|
||||
ScopedInterpolationQuality(GraphicsContext& context,
|
||||
InterpolationQuality interpolation_quality)
|
||||
: context_(context),
|
||||
previous_interpolation_quality_(context.ImageInterpolationQuality()) {
|
||||
if (previous_interpolation_quality_ != interpolation_quality)
|
||||
context_.SetImageInterpolationQuality(interpolation_quality);
|
||||
}
|
||||
|
||||
~ScopedInterpolationQuality() {
|
||||
if (previous_interpolation_quality_ != context_.ImageInterpolationQuality())
|
||||
context_.SetImageInterpolationQuality(previous_interpolation_quality_);
|
||||
}
|
||||
|
||||
private:
|
||||
GraphicsContext& context_;
|
||||
const InterpolationQuality previous_interpolation_quality_;
|
||||
};
|
||||
|
||||
} // namespace blink
|
||||
|
||||
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_SCOPED_INTERPOLATION_QUALITY_H_
|
Reference in New Issue
Block a user