Skip to content

Commit

Permalink
Remove WebBlendMode from WebLayer API, use SkBlendMode directly.
Browse files Browse the repository at this point in the history
Replaces the WebBlendMode enum with a BlendMode enum in graphics_types.h
under platform/graphics/ which is used throughout blink. This type is
kept because the bindings generator requires an enum with matching
names as the CSS property names (namely kNormal instead of kSrcOver).

Then we convert from BlendMode to SkBlendMode in GraphicsLayer in order
to pass it to the WebLayer.

TBR=fserb

Bug: 838693
Change-Id: If306343f4cd51911b46d6e1ca96529789477d29d
Reviewed-on: https://chromium-review.googlesource.com/1038403
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Fernando Serboncini <fserb@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#555943}
  • Loading branch information
danakj authored and Commit Bot committed May 4, 2018
1 parent f335db2 commit b68698e
Show file tree
Hide file tree
Showing 37 changed files with 182 additions and 324 deletions.
1 change: 0 additions & 1 deletion build/check_gn_headers_whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ ash/shell.h
ash/system/devicetype_utils.h
ash/wm/system_modal_container_event_filter_delegate.h
cc/base/ring_buffer.h
cc/blink/web_blend_mode.h
cc/cc_export.h
cc/input/browser_controls_state.h
cc/input/event_listener_properties.h
Expand Down
107 changes: 0 additions & 107 deletions cc/blink/web_blend_mode.h

This file was deleted.

9 changes: 4 additions & 5 deletions cc/blink/web_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "base/trace_event/trace_event_impl.h"
#include "cc/base/region.h"
#include "cc/base/switches.h"
#include "cc/blink/web_blend_mode.h"
#include "cc/layers/layer.h"
#include "cc/layers/layer_position_constraint.h"
#include "cc/layers/touch_action_region.h"
Expand Down Expand Up @@ -112,12 +111,12 @@ float WebLayerImpl::Opacity() const {
return layer_->opacity();
}

void WebLayerImpl::SetBlendMode(blink::WebBlendMode blend_mode) {
layer_->SetBlendMode(BlendModeToSkia(blend_mode));
void WebLayerImpl::SetBlendMode(SkBlendMode blend_mode) {
layer_->SetBlendMode(blend_mode);
}

blink::WebBlendMode WebLayerImpl::BlendMode() const {
return BlendModeFromSkia(layer_->blend_mode());
SkBlendMode WebLayerImpl::BlendMode() const {
return layer_->blend_mode();
}

void WebLayerImpl::SetIsRootForIsolatedGroup(bool isolate) {
Expand Down
4 changes: 2 additions & 2 deletions cc/blink/web_layer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class CC_BLINK_EXPORT WebLayerImpl : public blink::WebLayer {
float Opacity() const override;
void SetContentsOpaqueIsFixed(bool fixed) override;

void SetBlendMode(blink::WebBlendMode blend_mode) override;
blink::WebBlendMode BlendMode() const override;
void SetBlendMode(SkBlendMode blend_mode) override;
SkBlendMode BlendMode() const override;
void SetIsRootForIsolatedGroup(bool root) override;
bool IsRootForIsolatedGroup() override;
void SetHitTestableWithoutDrawsContent(bool should_hit_test) override;
Expand Down
1 change: 0 additions & 1 deletion third_party/blink/public/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ source_set("blink_headers") {
"platform/web_audio_latency_hint.h",
"platform/web_audio_source_provider.h",
"platform/web_audio_source_provider_client.h",
"platform/web_blend_mode.h",
"platform/web_blob_info.h",
"platform/web_blob_registry.h",
"platform/web_browser_controls_state.h",
Expand Down
59 changes: 0 additions & 59 deletions third_party/blink/public/platform/web_blend_mode.h

This file was deleted.

1 change: 0 additions & 1 deletion third_party/blink/public/platform/web_display_item_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_DISPLAY_ITEM_LIST_H_
#define THIRD_PARTY_BLINK_PUBLIC_PLATFORM_WEB_DISPLAY_ITEM_LIST_H_

#include "third_party/blink/public/platform/web_blend_mode.h"
#include "third_party/blink/public/platform/web_vector.h"

#include "cc/paint/paint_record.h"
Expand Down
6 changes: 3 additions & 3 deletions third_party/blink/public/platform/web_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

#include "cc/input/overscroll_behavior.h"
#include "cc/layers/layer.h"
#include "third_party/blink/public/platform/web_blend_mode.h"
#include "third_party/blink/public/platform/web_common.h"
#include "third_party/blink/public/platform/web_rect.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_touch_info.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/skia/include/core/SkBlendMode.h"
#include "third_party/skia/include/core/SkColor.h"

namespace cc {
Expand Down Expand Up @@ -98,8 +98,8 @@ class WebLayer {
// will be addressed once WebLayer is removed.
virtual void SetContentsOpaqueIsFixed(bool) = 0;

virtual void SetBlendMode(WebBlendMode) = 0;
virtual WebBlendMode BlendMode() const = 0;
virtual void SetBlendMode(SkBlendMode) = 0;
virtual SkBlendMode BlendMode() const = 0;

virtual void SetIsRootForIsolatedGroup(bool) = 0;
virtual bool IsRootForIsolatedGroup() = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def calculate_apply_functions_to_declare(self, property_):
property_['custom_apply_args'] = {
'layer_type': 'Background' if 'Background' in property_name else 'Mask',
'fill_type': fill_type,
'fill_type_getter': 'Get' + fill_type if fill_type == "Image" else fill_type
'fill_type_getter': 'Get' + fill_type if fill_type == "Image" or fill_type == "BlendMode" else fill_type
}
property_['should_implement_apply_functions'] = (
property_['is_property'] and
Expand Down
4 changes: 2 additions & 2 deletions third_party/blink/renderer/core/css/CSSProperties.json5
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@
property_methods: ["CSSValueFromComputedStyleInternal"],
field_group: "*",
field_template: "keyword",
include_paths: ["third_party/blink/public/platform/web_blend_mode.h"],
include_paths: ["third_party/blink/renderer/platform/graphics/graphics_types.h"],
keywords: [
"normal", "multiply", "screen", "overlay", "darken", "lighten",
"color-dodge", "color-burn", "hard-light", "soft-light", "difference",
Expand All @@ -2054,7 +2054,7 @@
typedom_types: ["Keyword"],
default_value: "normal",
name_for_methods: "BlendMode",
type_name: "WebBlendMode",
type_name: "BlendMode",
},
{
name: "object-fit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PRIMITIVE_VALUE_MAPPINGS_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSS_PRIMITIVE_VALUE_MAPPINGS_H_

#include "third_party/blink/public/platform/web_blend_mode.h"
#include "third_party/blink/renderer/core/css/css_calculation_value.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_primitive_value.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const CSSValue* BackgroundBlendMode::CSSValueFromComputedStyleInternal(
CSSValueList* list = CSSValueList::CreateCommaSeparated();
for (const FillLayer* curr_layer = &style.BackgroundLayers(); curr_layer;
curr_layer = curr_layer->Next())
list->Append(*CSSIdentifierValue::Create(curr_layer->BlendMode()));
list->Append(*CSSIdentifierValue::Create(curr_layer->GetBlendMode()));
return list;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const CSSValue* MixBlendMode::CSSValueFromComputedStyleInternal(
const LayoutObject*,
Node*,
bool allow_visited_style) const {
return CSSIdentifierValue::Create(style.BlendMode());
return CSSIdentifierValue::Create(style.GetBlendMode());
}

} // namespace CSSLonghand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void CSSToStyleMap::MapFillBlendMode(StyleResolverState&,
return;

const CSSIdentifierValue& identifier_value = ToCSSIdentifierValue(value);
layer->SetBlendMode(identifier_value.ConvertTo<WebBlendMode>());
layer->SetBlendMode(identifier_value.ConvertTo<BlendMode>());
}

void CSSToStyleMap::MapFillOrigin(StyleResolverState&,
Expand Down
2 changes: 1 addition & 1 deletion third_party/blink/renderer/core/layout/layout_box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ LayoutRect LayoutBox::BackgroundRect(BackgroundRectType rect_type) const {
const FillLayer* cur = current;
current = current->Next();
if (rect_type == kBackgroundKnownOpaqueRect) {
if (cur->BlendMode() != WebBlendMode::kNormal ||
if (cur->GetBlendMode() != BlendMode::kNormal ||
cur->Composite() != kCompositeSourceOver)
continue;

Expand Down
5 changes: 3 additions & 2 deletions third_party/blink/renderer/core/layout/layout_tree_as_text.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,9 @@ static void Write(TextStream& ts,

if (layer.GetLayoutObject().Style()->HasBlendMode()) {
ts << " blendMode: "
<< CompositeOperatorName(kCompositeSourceOver,
layer.GetLayoutObject().Style()->BlendMode());
<< CompositeOperatorName(
kCompositeSourceOver,
layer.GetLayoutObject().Style()->GetBlendMode());
}

if (behavior & kLayoutAsTextShowCompositedLayers) {
Expand Down
6 changes: 3 additions & 3 deletions third_party/blink/renderer/core/paint/box_painter_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ bool BoxPainterBase::CalculateFillLayerOcclusionCulling(
// geometry here and pass it down.

// TODO(trchen): Need to check compositing mode as well.
if (current_layer->BlendMode() != WebBlendMode::kNormal)
if (current_layer->GetBlendMode() != BlendMode::kNormal)
is_non_associative = true;

// TODO(trchen): A fill layer cannot paint if the calculated tile size is
Expand Down Expand Up @@ -557,8 +557,8 @@ void BoxPainterBase::PaintFillLayer(const PaintInfo& paint_info,
context.SetColorFilter(kColorFilterLuminanceToAlpha);

// If op != SkBlendMode::kSrcOver, a mask is being painted.
SkBlendMode bg_op = WebCoreCompositeToSkiaComposite(bg_layer.Composite(),
bg_layer.BlendMode());
SkBlendMode bg_op = WebCoreCompositeToSkiaComposite(
bg_layer.Composite(), bg_layer.GetBlendMode());
composite_op = (op == SkBlendMode::kSrcOver) ? bg_op : op;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ void CompositedLayerMapping::UpdateStickyConstraints(
}

void CompositedLayerMapping::UpdateLayerBlendMode(const ComputedStyle& style) {
SetBlendMode(style.BlendMode());
SetBlendMode(style.GetBlendMode());
}

void CompositedLayerMapping::UpdateIsRootForIsolatedGroup() {
Expand Down Expand Up @@ -3041,10 +3041,10 @@ GraphicsLayer* CompositedLayerMapping::ChildForSuperlayers() const {
return graphics_layer_.get();
}

void CompositedLayerMapping::SetBlendMode(WebBlendMode blend_mode) {
void CompositedLayerMapping::SetBlendMode(BlendMode blend_mode) {
if (ancestor_clipping_layer_) {
ancestor_clipping_layer_->SetBlendMode(blend_mode);
graphics_layer_->SetBlendMode(WebBlendMode::kNormal);
graphics_layer_->SetBlendMode(BlendMode::kNormal);
} else {
graphics_layer_->SetBlendMode(blend_mode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "third_party/blink/renderer/platform/geometry/float_point_3d.h"
#include "third_party/blink/renderer/platform/graphics/graphics_layer.h"
#include "third_party/blink/renderer/platform/graphics/graphics_layer_client.h"
#include "third_party/blink/renderer/platform/graphics/graphics_types.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"

namespace blink {
Expand Down Expand Up @@ -263,7 +264,7 @@ class CORE_EXPORT CompositedLayerMapping final : public GraphicsLayerClient {
void UpdateFilters();
void UpdateBackdropFilters();

void SetBlendMode(WebBlendMode);
void SetBlendMode(BlendMode);

bool NeedsGraphicsLayerUpdate() {
return pending_update_scope_ > kGraphicsLayerUpdateNone;
Expand Down
Loading

0 comments on commit b68698e

Please sign in to comment.