Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -43017,6 +43017,8 @@ ORIGIN: ../../../flutter/impeller/core/platform.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/platform.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/range.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/range.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/raw_ptr.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/raw_ptr.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/resource_binder.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/resource_binder.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/core/runtime_types.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -45946,6 +45948,8 @@ FILE: ../../../flutter/impeller/core/platform.cc
FILE: ../../../flutter/impeller/core/platform.h
FILE: ../../../flutter/impeller/core/range.cc
FILE: ../../../flutter/impeller/core/range.h
FILE: ../../../flutter/impeller/core/raw_ptr.cc
FILE: ../../../flutter/impeller/core/raw_ptr.h
FILE: ../../../flutter/impeller/core/resource_binder.cc
FILE: ../../../flutter/impeller/core/resource_binder.h
FILE: ../../../flutter/impeller/core/runtime_types.cc
Expand Down
2 changes: 2 additions & 0 deletions impeller/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ impeller_component("core") {
"platform.h",
"range.cc",
"range.h",
"raw_ptr.cc",
"raw_ptr.h",
"resource_binder.cc",
"resource_binder.h",
"runtime_types.cc",
Expand Down
11 changes: 11 additions & 0 deletions impeller/core/raw_ptr.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// 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 "impeller/core/raw_ptr.h"

namespace impeller {

//

}
84 changes: 84 additions & 0 deletions impeller/core/raw_ptr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// 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_IMPELLER_CORE_RAW_PTR_H_
#define FLUTTER_IMPELLER_CORE_RAW_PTR_H_

#include <memory>

namespace impeller {

/// @brief A wrapper around a raw ptr that adds additional unopt mode only
/// checks.
template <typename T>
class raw_ptr {
public:
explicit raw_ptr(const std::shared_ptr<T>& ptr)
: ptr_(ptr.get())
#if !NDEBUG
,
weak_ptr_(ptr)
#endif
{
}

raw_ptr() : ptr_(nullptr) {}

T* operator->() {
#if !NDEBUG
FML_CHECK(weak_ptr_.lock());
#endif
return ptr_;
}

const T* operator->() const {
#if !NDEBUG
FML_CHECK(weak_ptr_.lock());
#endif
return ptr_;
}

T* get() {
#if !NDEBUG
FML_CHECK(weak_ptr_.lock());
#endif
return ptr_;
}

T& operator*() {
#if !NDEBUG
FML_CHECK(weak_ptr_.lock());
#endif
return *ptr_;
}

const T& operator*() const {
#if !NDEBUG
FML_CHECK(weak_ptr_.lock());
#endif
return *ptr_;
}

template <class U>
inline bool operator==(raw_ptr<U> const& other) const {
return ptr_ == other.ptr_;
}

template <class U>
inline bool operator!=(raw_ptr<U> const& other) const {
return !(*this == other);
}

explicit operator bool() const { return !!ptr_; }

private:
T* ptr_;
#if !NDEBUG
std::weak_ptr<T> weak_ptr_;
#endif
};

} // namespace impeller

#endif // FLUTTER_IMPELLER_CORE_RAW_PTR_H_
3 changes: 1 addition & 2 deletions impeller/entity/contents/color_source_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class ColorSourceContents : public Contents {
using PipelineBuilderMethod = std::shared_ptr<Pipeline<PipelineDescriptor>> (
impeller::ContentContext::*)(ContentContextOptions) const;
using PipelineBuilderCallback =
std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>(
ContentContextOptions)>;
std::function<PipelineRef(ContentContextOptions)>;
using CreateGeometryCallback =
std::function<GeometryResult(const ContentContext& renderer,
const Entity& entity,
Expand Down
5 changes: 2 additions & 3 deletions impeller/entity/contents/content_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ void ContentContext::SetWireframe(bool wireframe) {
wireframe_ = wireframe;
}

std::shared_ptr<Pipeline<PipelineDescriptor>>
ContentContext::GetCachedRuntimeEffectPipeline(
PipelineRef ContentContext::GetCachedRuntimeEffectPipeline(
const std::string& unique_entrypoint_name,
const ContentContextOptions& options,
const std::function<std::shared_ptr<Pipeline<PipelineDescriptor>>()>&
Expand All @@ -580,7 +579,7 @@ ContentContext::GetCachedRuntimeEffectPipeline(
if (it == runtime_effect_pipelines_.end()) {
it = runtime_effect_pipelines_.insert(it, {key, create_callback()});
}
return it->second;
return raw_ptr(it->second);
}

void ContentContext::ClearCachedRuntimeEffectPipeline(
Expand Down
Loading
Loading