forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland Wire up Opacity on Fuchsia (flutter#14559)
This reverts commit 6ea69a0. On top of the revert, it reverted a commit in the PR: flutter#14024 This reverts commit ea67e5b.
- Loading branch information
1 parent
a11abf1
commit 19a6215
Showing
43 changed files
with
498 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2013 The Flutter 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 "flutter/flow/layers/elevated_container_layer.h" | ||
|
||
namespace flutter { | ||
namespace { | ||
|
||
float ClampElevation(float elevation, | ||
float parent_elevation, | ||
float max_elevation) { | ||
// TODO(mklim): Deal with bounds overflow more elegantly. We'd like to be | ||
// able to have developers specify the behavior here to alternatives besides | ||
// clamping, like normalization on some arbitrary curve. | ||
float clamped_elevation = elevation; | ||
if (max_elevation > -1 && (parent_elevation + elevation) > max_elevation) { | ||
// Clamp the local z coordinate at our max bound. Take into account the | ||
// parent z position here to fix clamping in cases where the child is | ||
// overflowing because of its parents. | ||
clamped_elevation = max_elevation - parent_elevation; | ||
} | ||
|
||
return clamped_elevation; | ||
} | ||
|
||
} // namespace | ||
|
||
ElevatedContainerLayer::ElevatedContainerLayer(float elevation) | ||
: elevation_(elevation), clamped_elevation_(elevation) {} | ||
|
||
void ElevatedContainerLayer::Preroll(PrerollContext* context, | ||
const SkMatrix& matrix) { | ||
TRACE_EVENT0("flutter", "ElevatedContainerLayer::Preroll"); | ||
|
||
// Track total elevation as we walk the tree, in order to deal with bounds | ||
// overflow in z. | ||
parent_elevation_ = context->total_elevation; | ||
clamped_elevation_ = ClampElevation(elevation_, parent_elevation_, | ||
context->frame_physical_depth); | ||
context->total_elevation += clamped_elevation_; | ||
|
||
ContainerLayer::Preroll(context, matrix); | ||
|
||
// Restore the elevation for our parent. | ||
context->total_elevation = parent_elevation_; | ||
} | ||
|
||
} // namespace flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2013 The Flutter 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 FLUTTER_FLOW_LAYERS_ELEVATED_CONTAINER_LAYER_H_ | ||
#define FLUTTER_FLOW_LAYERS_ELEVATED_CONTAINER_LAYER_H_ | ||
|
||
#include "flutter/flow/layers/container_layer.h" | ||
|
||
namespace flutter { | ||
|
||
class ElevatedContainerLayer : public ContainerLayer { | ||
public: | ||
ElevatedContainerLayer(float elevation); | ||
~ElevatedContainerLayer() override = default; | ||
|
||
void Preroll(PrerollContext* context, const SkMatrix& matrix) override; | ||
|
||
float elevation() const { return clamped_elevation_; } | ||
float total_elevation() const { | ||
return parent_elevation_ + clamped_elevation_; | ||
} | ||
|
||
private: | ||
float parent_elevation_ = 0.0f; | ||
float elevation_ = 0.0f; | ||
float clamped_elevation_ = 0.0f; | ||
|
||
FML_DISALLOW_COPY_AND_ASSIGN(ElevatedContainerLayer); | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_FLOW_LAYERS_ELEVATED_CONTAINER_LAYER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2013 The Flutter 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 "flutter/flow/layers/fuchsia_system_composited_layer.h" | ||
|
||
namespace flutter { | ||
|
||
FuchsiaSystemCompositedLayer::FuchsiaSystemCompositedLayer(SkColor color, | ||
float elevation) | ||
: ElevatedContainerLayer(elevation), color_(color) {} | ||
|
||
void FuchsiaSystemCompositedLayer::UpdateScene(SceneUpdateContext& context) { | ||
FML_DCHECK(needs_system_composite()); | ||
|
||
// Retained rendering: speedup by reusing a retained entity node if | ||
// possible. When an entity node is reused, no paint layer is added to the | ||
// frame so we won't call Paint. | ||
LayerRasterCacheKey key(unique_id(), context.Matrix()); | ||
if (context.HasRetainedNode(key)) { | ||
TRACE_EVENT_INSTANT0("flutter", "retained layer cache hit"); | ||
const scenic::EntityNode& retained_node = context.GetRetainedNode(key); | ||
FML_DCHECK(context.top_entity()); | ||
FML_DCHECK(retained_node.session() == context.session()); | ||
context.top_entity()->embedder_node().AddChild(retained_node); | ||
return; | ||
} | ||
|
||
TRACE_EVENT_INSTANT0("flutter", "retained cache miss, creating"); | ||
// If we can't find an existing retained surface, create one. | ||
SceneUpdateContext::Frame frame(context, rrect_, color_, elevation(), this); | ||
for (auto& layer : layers()) { | ||
if (layer->needs_painting()) { | ||
frame.AddPaintLayer(layer.get()); | ||
} | ||
} | ||
|
||
ContainerLayer::UpdateScene(context); | ||
} | ||
|
||
} // namespace flutter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2013 The Flutter 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 FLUTTER_FLOW_LAYERS_FUCHSIA_SYSTEM_COMPOSITED_LAYER_H_ | ||
#define FLUTTER_FLOW_LAYERS_FUCHSIA_SYSTEM_COMPOSITED_LAYER_H_ | ||
|
||
#include "flutter/flow/layers/elevated_container_layer.h" | ||
#include "flutter/flow/scene_update_context.h" | ||
|
||
namespace flutter { | ||
|
||
class FuchsiaSystemCompositedLayer : public ElevatedContainerLayer { | ||
public: | ||
static bool can_system_composite() { return true; } | ||
|
||
FuchsiaSystemCompositedLayer(SkColor color, float elevation); | ||
|
||
void UpdateScene(SceneUpdateContext& context) override; | ||
|
||
void set_dimensions(SkRRect rrect) { rrect_ = rrect; } | ||
|
||
SkColor color() const { return color_; } | ||
|
||
private: | ||
SkRRect rrect_ = SkRRect::MakeEmpty(); | ||
SkColor color_ = SK_ColorTRANSPARENT; | ||
|
||
FML_DISALLOW_COPY_AND_ASSIGN(FuchsiaSystemCompositedLayer); | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // FLUTTER_FLOW_LAYERS_FUCHSIA_SYSTEM_COMPOSITED_LAYER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.