forked from firka/flutter
Fix some clang-tidy lints for Linux host_debug (flutter/engine#29734)
This commit is contained in:
@@ -9,4 +9,5 @@ Checks: "google-*,\
|
||||
# to prevent new warnings being introduced.
|
||||
# https://github.com/flutter/flutter/issues/93279
|
||||
WarningsAsErrors: "clang-analyzer-osx.*,\
|
||||
google-objc-*"
|
||||
google-objc-*,\
|
||||
google-explicit-constructor"
|
||||
|
||||
@@ -71,7 +71,7 @@ struct DLOp {
|
||||
struct Set##name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kSet##name; \
|
||||
\
|
||||
Set##name##Op(bool value) : value(value) {} \
|
||||
explicit Set##name##Op(bool value) : value(value) {} \
|
||||
\
|
||||
const bool value; \
|
||||
\
|
||||
@@ -85,17 +85,17 @@ DEFINE_SET_BOOL_OP(InvertColors)
|
||||
#undef DEFINE_SET_BOOL_OP
|
||||
|
||||
// 4 byte header + 4 byte payload packs into minimum 8 bytes
|
||||
#define DEFINE_SET_ENUM_OP(name) \
|
||||
struct SetStroke##name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kSetStroke##name; \
|
||||
\
|
||||
SetStroke##name##Op(SkPaint::name value) : value(value) {} \
|
||||
\
|
||||
const SkPaint::name value; \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
dispatcher.setStroke##name(value); \
|
||||
} \
|
||||
#define DEFINE_SET_ENUM_OP(name) \
|
||||
struct SetStroke##name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kSetStroke##name; \
|
||||
\
|
||||
explicit SetStroke##name##Op(SkPaint::name value) : value(value) {} \
|
||||
\
|
||||
const SkPaint::name value; \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
dispatcher.setStroke##name(value); \
|
||||
} \
|
||||
};
|
||||
DEFINE_SET_ENUM_OP(Cap)
|
||||
DEFINE_SET_ENUM_OP(Join)
|
||||
@@ -162,26 +162,26 @@ struct SetBlendModeOp final : DLOp {
|
||||
// Set: 4 byte header + an sk_sp (ptr) uses 16 bytes due to the
|
||||
// alignment of the ptr.
|
||||
// (4 bytes unused)
|
||||
#define DEFINE_SET_CLEAR_SKREF_OP(name, field) \
|
||||
struct Clear##name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kClear##name; \
|
||||
\
|
||||
Clear##name##Op() {} \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
dispatcher.set##name(nullptr); \
|
||||
} \
|
||||
}; \
|
||||
struct Set##name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kSet##name; \
|
||||
\
|
||||
Set##name##Op(sk_sp<Sk##name> field) : field(std::move(field)) {} \
|
||||
\
|
||||
sk_sp<Sk##name> field; \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
dispatcher.set##name(field); \
|
||||
} \
|
||||
#define DEFINE_SET_CLEAR_SKREF_OP(name, field) \
|
||||
struct Clear##name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kClear##name; \
|
||||
\
|
||||
Clear##name##Op() {} \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
dispatcher.set##name(nullptr); \
|
||||
} \
|
||||
}; \
|
||||
struct Set##name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kSet##name; \
|
||||
\
|
||||
explicit Set##name##Op(sk_sp<Sk##name> field) : field(std::move(field)) {} \
|
||||
\
|
||||
sk_sp<Sk##name> field; \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
dispatcher.set##name(field); \
|
||||
} \
|
||||
};
|
||||
DEFINE_SET_CLEAR_SKREF_OP(Blender, blender)
|
||||
DEFINE_SET_CLEAR_SKREF_OP(Shader, shader)
|
||||
@@ -198,7 +198,7 @@ DEFINE_SET_CLEAR_SKREF_OP(PathEffect, effect)
|
||||
struct SetMaskBlurFilter##name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kSetMaskBlurFilter##name; \
|
||||
\
|
||||
SetMaskBlurFilter##name##Op(SkScalar sigma) : sigma(sigma) {} \
|
||||
explicit SetMaskBlurFilter##name##Op(SkScalar sigma) : sigma(sigma) {} \
|
||||
\
|
||||
SkScalar sigma; \
|
||||
\
|
||||
@@ -432,17 +432,17 @@ struct DrawColorOp final : DLOp {
|
||||
// (4 bytes unused)
|
||||
// SkOval is same as SkRect
|
||||
// SkRRect is 52 more bytes, which packs efficiently into 56 bytes total
|
||||
#define DEFINE_DRAW_1ARG_OP(op_name, arg_type, arg_name) \
|
||||
struct Draw##op_name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kDraw##op_name; \
|
||||
\
|
||||
Draw##op_name##Op(arg_type arg_name) : arg_name(arg_name) {} \
|
||||
\
|
||||
const arg_type arg_name; \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
dispatcher.draw##op_name(arg_name); \
|
||||
} \
|
||||
#define DEFINE_DRAW_1ARG_OP(op_name, arg_type, arg_name) \
|
||||
struct Draw##op_name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kDraw##op_name; \
|
||||
\
|
||||
explicit Draw##op_name##Op(arg_type arg_name) : arg_name(arg_name) {} \
|
||||
\
|
||||
const arg_type arg_name; \
|
||||
\
|
||||
void dispatch(Dispatcher& dispatcher) const { \
|
||||
dispatcher.draw##op_name(arg_name); \
|
||||
} \
|
||||
};
|
||||
DEFINE_DRAW_1ARG_OP(Rect, SkRect, rect)
|
||||
DEFINE_DRAW_1ARG_OP(Oval, SkRect, oval)
|
||||
@@ -518,7 +518,7 @@ struct DrawArcOp final : DLOp {
|
||||
struct Draw##name##Op final : DLOp { \
|
||||
static const auto kType = DisplayListOpType::kDraw##name; \
|
||||
\
|
||||
Draw##name##Op(uint32_t count) : count(count) {} \
|
||||
explicit Draw##name##Op(uint32_t count) : count(count) {} \
|
||||
\
|
||||
const uint32_t count; \
|
||||
\
|
||||
@@ -868,7 +868,7 @@ void DisplayList::Dispatch(Dispatcher& dispatcher,
|
||||
uint8_t* ptr,
|
||||
uint8_t* end) const {
|
||||
while (ptr < end) {
|
||||
auto op = (const DLOp*)ptr;
|
||||
auto op = reinterpret_cast<const DLOp*>(ptr);
|
||||
ptr += op->size;
|
||||
FML_DCHECK(ptr <= end);
|
||||
switch (op->type) {
|
||||
@@ -890,7 +890,7 @@ void DisplayList::Dispatch(Dispatcher& dispatcher,
|
||||
|
||||
static void DisposeOps(uint8_t* ptr, uint8_t* end) {
|
||||
while (ptr < end) {
|
||||
auto op = (const DLOp*)ptr;
|
||||
auto op = reinterpret_cast<const DLOp*>(ptr);
|
||||
ptr += op->size;
|
||||
FML_DCHECK(ptr <= end);
|
||||
switch (op->type) {
|
||||
@@ -922,8 +922,8 @@ static bool CompareOps(uint8_t* ptrA,
|
||||
uint8_t* bulkStartA = ptrA;
|
||||
uint8_t* bulkStartB = ptrB;
|
||||
while (ptrA < endA && ptrB < endB) {
|
||||
auto opA = (const DLOp*)ptrA;
|
||||
auto opB = (const DLOp*)ptrB;
|
||||
auto opA = reinterpret_cast<const DLOp*>(ptrA);
|
||||
auto opB = reinterpret_cast<const DLOp*>(ptrB);
|
||||
if (opA->type != opB->type || opA->size != opB->size) {
|
||||
return false;
|
||||
}
|
||||
@@ -1047,7 +1047,7 @@ void* DisplayListBuilder::Push(size_t pod, int op_inc, Args&&... args) {
|
||||
memset(storage_.get() + used_, 0, allocated_ - used_);
|
||||
}
|
||||
FML_DCHECK(used_ + size <= allocated_);
|
||||
auto op = (T*)(storage_.get() + used_);
|
||||
auto op = reinterpret_cast<T*>(storage_.get() + used_);
|
||||
used_ += size;
|
||||
new (op) T{std::forward<Args>(args)...};
|
||||
op->type = T::kType;
|
||||
|
||||
@@ -559,7 +559,7 @@ class DisplayListFlags {
|
||||
|
||||
class DisplayListFlagsBase : protected DisplayListFlags {
|
||||
protected:
|
||||
DisplayListFlagsBase(int flags) : flags_(flags) {}
|
||||
explicit DisplayListFlagsBase(int flags) : flags_(flags) {}
|
||||
|
||||
const int flags_;
|
||||
|
||||
@@ -594,7 +594,8 @@ class DisplayListSpecialGeometryFlags : DisplayListFlagsBase {
|
||||
bool may_have_acute_joins() const { return has_any(kMayHaveAcuteJoins_); }
|
||||
|
||||
private:
|
||||
DisplayListSpecialGeometryFlags(int flags) : DisplayListFlagsBase(flags) {
|
||||
explicit DisplayListSpecialGeometryFlags(int flags)
|
||||
: DisplayListFlagsBase(flags) {
|
||||
FML_DCHECK((flags & kAnySpecialGeometryMask_) == flags);
|
||||
}
|
||||
|
||||
@@ -675,7 +676,7 @@ class DisplayListAttributeFlags : DisplayListFlagsBase {
|
||||
bool is_flood() const { return has_any(kFloodsSurface_); }
|
||||
|
||||
private:
|
||||
DisplayListAttributeFlags(int flags)
|
||||
explicit DisplayListAttributeFlags(int flags)
|
||||
: DisplayListFlagsBase(flags),
|
||||
special_flags_(flags & kAnySpecialGeometryMask_) {
|
||||
FML_DCHECK((flags & kIsAnyGeometryMask_) == kIsNonGeometric_ ||
|
||||
@@ -694,7 +695,7 @@ class DisplayListAttributeFlags : DisplayListFlagsBase {
|
||||
|
||||
const DisplayListAttributeFlags without(int remove) const {
|
||||
FML_DCHECK(has_all(remove));
|
||||
return (flags_ & ~remove);
|
||||
return DisplayListAttributeFlags(flags_ & ~remove);
|
||||
}
|
||||
|
||||
const DisplayListSpecialGeometryFlags special_flags_;
|
||||
|
||||
@@ -244,7 +244,7 @@ static void EmptyDlRenderer(DisplayListBuilder&) {}
|
||||
|
||||
class RenderSurface {
|
||||
public:
|
||||
RenderSurface(sk_sp<SkSurface> surface) : surface_(surface) {}
|
||||
explicit RenderSurface(sk_sp<SkSurface> surface) : surface_(surface) {}
|
||||
~RenderSurface() { sk_free(addr_); }
|
||||
|
||||
SkCanvas* canvas() { return surface_->getCanvas(); }
|
||||
@@ -311,7 +311,7 @@ class RenderEnvironment {
|
||||
const SkPixmap* ref_pixmap() const { return ref_pixmap_; }
|
||||
|
||||
private:
|
||||
RenderEnvironment(const SkImageInfo& info)
|
||||
explicit RenderEnvironment(const SkImageInfo& info)
|
||||
: info_(info), ref_surface_(MakeSurface()) {}
|
||||
|
||||
const SkImageInfo info_;
|
||||
@@ -609,7 +609,7 @@ class TestParameters {
|
||||
|
||||
class CaseParameters {
|
||||
public:
|
||||
CaseParameters(std::string info)
|
||||
explicit CaseParameters(std::string info)
|
||||
: CaseParameters(info, EmptyCvRenderer, EmptyDlRenderer) {}
|
||||
|
||||
CaseParameters(std::string info, CvSetup cv_setup, DlRenderer dl_setup)
|
||||
|
||||
@@ -214,7 +214,7 @@ void ClipBoundsDispatchHelper::restore() {
|
||||
}
|
||||
}
|
||||
void ClipBoundsDispatchHelper::reset(const SkRect* cull_rect) {
|
||||
if ((has_clip_ = ((bool)cull_rect)) && !cull_rect->isEmpty()) {
|
||||
if ((has_clip_ = cull_rect != nullptr) && !cull_rect->isEmpty()) {
|
||||
bounds_ = *cull_rect;
|
||||
} else {
|
||||
bounds_.setEmpty();
|
||||
|
||||
@@ -25,7 +25,8 @@ TEST(MallocMapping, MoveConstructor) {
|
||||
MallocMapping mapping(reinterpret_cast<uint8_t*>(malloc(length)), length);
|
||||
MallocMapping moved = std::move(mapping);
|
||||
|
||||
ASSERT_EQ(nullptr, mapping.GetMapping());
|
||||
ASSERT_EQ(nullptr,
|
||||
mapping.GetMapping()); // NOLINT(clang-analyzer-cplusplus.Move)
|
||||
ASSERT_EQ(0u, mapping.GetSize());
|
||||
ASSERT_NE(nullptr, moved.GetMapping());
|
||||
ASSERT_EQ(length, moved.GetSize());
|
||||
|
||||
@@ -81,6 +81,7 @@ void MessageLoopLinux::Terminate() {
|
||||
// |fml::MessageLoopImpl|
|
||||
void MessageLoopLinux::WakeUp(fml::TimePoint time_point) {
|
||||
bool result = TimerRearm(timer_fd_.get(), time_point);
|
||||
(void)result;
|
||||
FML_DCHECK(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ bool TimerRearm(int fd, fml::TimePoint time_point) {
|
||||
}
|
||||
|
||||
struct itimerspec spec = {};
|
||||
spec.it_value.tv_sec = (time_t)(nano_secs / NSEC_PER_SEC);
|
||||
spec.it_value.tv_sec = static_cast<time_t>(nano_secs / NSEC_PER_SEC);
|
||||
spec.it_value.tv_nsec = nano_secs % NSEC_PER_SEC;
|
||||
spec.it_interval = spec.it_value; // single expiry.
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ class PlatformSemaphore {
|
||||
~PlatformSemaphore() {
|
||||
if (valid_) {
|
||||
int result = ::sem_destroy(&sem_);
|
||||
(void)result;
|
||||
// Can only be EINVAL which should not be possible since we checked for
|
||||
// validity.
|
||||
FML_DCHECK(result == 0);
|
||||
|
||||
@@ -50,7 +50,8 @@ static const std::array<SkSamplingOptions, 4> filter_qualities = {
|
||||
SkSamplingOptions ImageFilter::SamplingFromIndex(int filterQualityIndex) {
|
||||
if (filterQualityIndex < 0) {
|
||||
return filter_qualities.front();
|
||||
} else if (((size_t)filterQualityIndex) >= filter_qualities.size()) {
|
||||
} else if (static_cast<size_t>(filterQualityIndex) >=
|
||||
filter_qualities.size()) {
|
||||
return filter_qualities.back();
|
||||
} else {
|
||||
return filter_qualities[filterQualityIndex];
|
||||
|
||||
@@ -102,7 +102,7 @@ unsigned int BuiltinSkiaCodecImageGenerator::GetPlayCount() const {
|
||||
|
||||
const ImageGenerator::FrameInfo BuiltinSkiaCodecImageGenerator::GetFrameInfo(
|
||||
unsigned int frame_index) const {
|
||||
SkCodec::FrameInfo info;
|
||||
SkCodec::FrameInfo info = {};
|
||||
codec_generator_->getFrameInfo(frame_index, &info);
|
||||
return {
|
||||
.required_frame = info.fRequiredFrame == SkCodec::kNoFrame
|
||||
|
||||
@@ -48,7 +48,7 @@ TEST_F(ShellTest, CreateCompatibleReturnsNullptrForInvalidImage) {
|
||||
|
||||
class FakeImageGenerator : public ImageGenerator {
|
||||
public:
|
||||
FakeImageGenerator(int identifiableFakeWidth)
|
||||
explicit FakeImageGenerator(int identifiableFakeWidth)
|
||||
: info_(SkImageInfo::Make(identifiableFakeWidth,
|
||||
identifiableFakeWidth,
|
||||
SkColorType::kRGBA_8888_SkColorType,
|
||||
|
||||
@@ -43,7 +43,8 @@ class AppSnapshotIsolateConfiguration final : public IsolateConfiguration {
|
||||
|
||||
class KernelIsolateConfiguration : public IsolateConfiguration {
|
||||
public:
|
||||
KernelIsolateConfiguration(std::unique_ptr<const fml::Mapping> kernel)
|
||||
explicit KernelIsolateConfiguration(
|
||||
std::unique_ptr<const fml::Mapping> kernel)
|
||||
: kernel_(std::move(kernel)) {}
|
||||
|
||||
// |IsolateConfiguration|
|
||||
@@ -69,7 +70,7 @@ class KernelIsolateConfiguration : public IsolateConfiguration {
|
||||
|
||||
class KernelListIsolateConfiguration final : public IsolateConfiguration {
|
||||
public:
|
||||
KernelListIsolateConfiguration(
|
||||
explicit KernelListIsolateConfiguration(
|
||||
std::vector<std::future<std::unique_ptr<const fml::Mapping>>>
|
||||
kernel_pieces)
|
||||
: kernel_piece_futures_(std::move(kernel_pieces)) {
|
||||
|
||||
@@ -1367,6 +1367,7 @@ void Shell::OnFrameRasterized(const FrameTiming& timing) {
|
||||
}
|
||||
|
||||
size_t old_count = unreported_timings_.size();
|
||||
(void)old_count;
|
||||
for (auto phase : FrameTiming::kPhases) {
|
||||
unreported_timings_.push_back(
|
||||
timing.Get(phase).ToEpochDelta().ToMicroseconds());
|
||||
|
||||
@@ -1880,7 +1880,7 @@ TEST_F(ShellTest, CanConvertToAndFromMappings) {
|
||||
const size_t buffer_size = 2 << 20;
|
||||
|
||||
uint8_t* buffer = static_cast<uint8_t*>(::malloc(buffer_size));
|
||||
ASSERT_NE(buffer, nullptr);
|
||||
ASSERT_TRUE(buffer != nullptr);
|
||||
ASSERT_TRUE(MemsetPatternSetOrCheck(
|
||||
buffer, buffer_size, MemsetPatternOp::kMemsetPatternOpSetBuffer));
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ static bool GetSwitchValue(const fml::CommandLine& command_line,
|
||||
|
||||
std::unique_ptr<fml::Mapping> GetSymbolMapping(std::string symbol_prefix,
|
||||
std::string native_lib_path) {
|
||||
const uint8_t* mapping;
|
||||
const uint8_t* mapping = nullptr;
|
||||
intptr_t size;
|
||||
|
||||
auto lookup_symbol = [&mapping, &size, symbol_prefix](
|
||||
|
||||
@@ -129,7 +129,7 @@ static SkColorType FirstSupportedColorType(GrDirectContext* context,
|
||||
static sk_sp<SkSurface> WrapOnscreenSurface(GrDirectContext* context,
|
||||
const SkISize& size,
|
||||
intptr_t fbo) {
|
||||
GrGLenum format;
|
||||
GrGLenum format = kUnknown_SkColorType;
|
||||
const SkColorType color_type = FirstSupportedColorType(context, &format);
|
||||
|
||||
GrGLFramebufferInfo framebuffer_info = {};
|
||||
|
||||
@@ -112,7 +112,7 @@ TEST(AndroidExternalViewEmbedder, GetCurrentCanvases) {
|
||||
ASSERT_EQ(SkISize::Make(10, 20), canvases[1]->getBaseLayerSize());
|
||||
}
|
||||
|
||||
TEST(AndroidExternalViewEmbedder, GetCurrentCanvases__CompositeOrder) {
|
||||
TEST(AndroidExternalViewEmbedder, GetCurrentCanvasesCompositeOrder) {
|
||||
auto jni_mock = std::make_shared<JNIMock>();
|
||||
|
||||
auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
|
||||
@@ -248,7 +248,7 @@ TEST(AndroidExternalViewEmbedder, PlatformViewRect) {
|
||||
ASSERT_EQ(SkRect::MakeXYWH(15, 30, 45, 60), embedder->GetViewRect(view_id));
|
||||
}
|
||||
|
||||
TEST(AndroidExternalViewEmbedder, PlatformViewRect__ChangedParams) {
|
||||
TEST(AndroidExternalViewEmbedder, PlatformViewRectChangedParams) {
|
||||
auto jni_mock = std::make_shared<JNIMock>();
|
||||
|
||||
auto android_context = AndroidContext(AndroidRenderingAPI::kSoftware);
|
||||
@@ -488,7 +488,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(AndroidExternalViewEmbedder, SubmitFrame__overlayComposition) {
|
||||
TEST(AndroidExternalViewEmbedder, SubmitFrameOverlayComposition) {
|
||||
auto jni_mock = std::make_shared<JNIMock>();
|
||||
auto android_context =
|
||||
std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
|
||||
@@ -590,7 +590,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame__overlayComposition) {
|
||||
embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger);
|
||||
}
|
||||
|
||||
TEST(AndroidExternalViewEmbedder, SubmitFrame__platformViewWithoutAnyOverlay) {
|
||||
TEST(AndroidExternalViewEmbedder, SubmitFramePlatformViewWithoutAnyOverlay) {
|
||||
auto jni_mock = std::make_shared<JNIMock>();
|
||||
auto android_context =
|
||||
std::make_shared<AndroidContext>(AndroidRenderingAPI::kSoftware);
|
||||
|
||||
@@ -36,7 +36,7 @@ class TestAndroidSurfaceFactory : public AndroidSurfaceFactory {
|
||||
TestSurfaceProducer surface_producer_;
|
||||
};
|
||||
|
||||
TEST(SurfacePool, GetLayer__AllocateOneLayer) {
|
||||
TEST(SurfacePool, GetLayerAllocateOneLayer) {
|
||||
auto pool = std::make_unique<SurfacePool>();
|
||||
|
||||
auto gr_context = GrDirectContext::MakeMock(nullptr);
|
||||
@@ -100,7 +100,7 @@ TEST(SurfacePool, GetUnusedLayers) {
|
||||
ASSERT_EQ(layer, pool->GetUnusedLayers()[0]);
|
||||
}
|
||||
|
||||
TEST(SurfacePool, GetLayer__Recycle) {
|
||||
TEST(SurfacePool, GetLayerRecycle) {
|
||||
auto pool = std::make_unique<SurfacePool>();
|
||||
|
||||
auto gr_context_1 = GrDirectContext::MakeMock(nullptr);
|
||||
@@ -145,7 +145,7 @@ TEST(SurfacePool, GetLayer__Recycle) {
|
||||
layer_2->gr_context_key);
|
||||
}
|
||||
|
||||
TEST(SurfacePool, GetLayer__AllocateTwoLayers) {
|
||||
TEST(SurfacePool, GetLayerAllocateTwoLayers) {
|
||||
auto pool = std::make_unique<SurfacePool>();
|
||||
|
||||
auto gr_context = GrDirectContext::MakeMock(nullptr);
|
||||
@@ -219,7 +219,7 @@ TEST(SurfacePool, DestroyLayers) {
|
||||
ASSERT_TRUE(pool->GetUnusedLayers().empty());
|
||||
}
|
||||
|
||||
TEST(SurfacePool, DestroyLayers__frameSizeChanged) {
|
||||
TEST(SurfacePool, DestroyLayersFrameSizeChanged) {
|
||||
auto pool = std::make_unique<SurfacePool>();
|
||||
auto jni_mock = std::make_shared<JNIMock>();
|
||||
|
||||
|
||||
@@ -231,11 +231,11 @@ size_t StandardCodecSerializer::ReadSize(ByteStreamReader* stream) const {
|
||||
if (byte < 254) {
|
||||
return byte;
|
||||
} else if (byte == 254) {
|
||||
uint16_t value;
|
||||
uint16_t value = 0;
|
||||
stream->ReadBytes(reinterpret_cast<uint8_t*>(&value), 2);
|
||||
return value;
|
||||
} else {
|
||||
uint32_t value;
|
||||
uint32_t value = 0;
|
||||
stream->ReadBytes(reinterpret_cast<uint8_t*>(&value), 4);
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace flutter {
|
||||
namespace {
|
||||
class NSDataMapping : public fml::Mapping {
|
||||
public:
|
||||
NSDataMapping(NSData* data) : data_([data retain]) {}
|
||||
explicit NSDataMapping(NSData* data) : data_([data retain]) {}
|
||||
|
||||
size_t GetSize() const override { return [data_.get() length]; }
|
||||
|
||||
|
||||
@@ -187,6 +187,7 @@ TEST_F(Embedder11yTest, A11yTreeIsConsistent) {
|
||||
std::vector<uint8_t> bytes({2, 1});
|
||||
result = FlutterEngineDispatchSemanticsAction(
|
||||
engine.get(), 42, kFlutterSemanticsActionTap, &bytes[0], bytes.size());
|
||||
ASSERT_EQ(result, FlutterEngineResult::kSuccess);
|
||||
latch.Wait();
|
||||
|
||||
// Disable semantics. Wait for NotifySemanticsEnabled(false).
|
||||
|
||||
@@ -1105,7 +1105,7 @@ TEST_F(EmbedderTest, CanPostTaskToAllNativeThreads) {
|
||||
size_t ui_threads_count = 0;
|
||||
size_t worker_threads_count = 0;
|
||||
|
||||
Captures(size_t count) : latch(count) {}
|
||||
explicit Captures(size_t count) : latch(count) {}
|
||||
};
|
||||
|
||||
Captures captures(engine_threads_count);
|
||||
|
||||
@@ -86,7 +86,7 @@ bool VulkanSurface::CreateVulkanImage(vulkan::VulkanProvider& vulkan_provider,
|
||||
return false;
|
||||
}
|
||||
|
||||
out_vulkan_image->vk_image = {
|
||||
out_vulkan_image->vk_image = vulkan::VulkanHandle<VkImage_T*>{
|
||||
vk_image, [&vulkan_provider = vulkan_provider](VkImage image) {
|
||||
vulkan_provider.vk().DestroyImage(vulkan_provider.vk_device(), image,
|
||||
NULL);
|
||||
@@ -290,11 +290,12 @@ bool VulkanSurface::AllocateDeviceMemory(
|
||||
return false;
|
||||
}
|
||||
|
||||
collection_ = {collection, [&vulkan_provider = vulkan_provider_](
|
||||
VkBufferCollectionFUCHSIAX collection) {
|
||||
vulkan_provider.vk().DestroyBufferCollectionFUCHSIAX(
|
||||
vulkan_provider.vk_device(), collection, nullptr);
|
||||
}};
|
||||
collection_ = vulkan::VulkanHandle<VkBufferCollectionFUCHSIAX_T*>{
|
||||
collection, [&vulkan_provider = vulkan_provider_](
|
||||
VkBufferCollectionFUCHSIAX collection) {
|
||||
vulkan_provider.vk().DestroyBufferCollectionFUCHSIAX(
|
||||
vulkan_provider.vk_device(), collection, nullptr);
|
||||
}};
|
||||
|
||||
VulkanImage vulkan_image;
|
||||
LOG_AND_RETURN(!CreateVulkanImage(vulkan_provider_, size, &vulkan_image),
|
||||
@@ -339,11 +340,12 @@ bool VulkanSurface::AllocateDeviceMemory(
|
||||
return false;
|
||||
}
|
||||
|
||||
vk_memory_ = {vk_memory,
|
||||
[&vulkan_provider = vulkan_provider_](VkDeviceMemory memory) {
|
||||
vulkan_provider.vk().FreeMemory(vulkan_provider.vk_device(),
|
||||
memory, NULL);
|
||||
}};
|
||||
vk_memory_ = vulkan::VulkanHandle<VkDeviceMemory_T*>{
|
||||
vk_memory,
|
||||
[&vulkan_provider = vulkan_provider_](VkDeviceMemory memory) {
|
||||
vulkan_provider.vk().FreeMemory(vulkan_provider.vk_device(), memory,
|
||||
NULL);
|
||||
}};
|
||||
|
||||
vk_memory_info_ = allocation_info;
|
||||
}
|
||||
|
||||
@@ -112,8 +112,9 @@ static gboolean has_action(FlutterSemanticsAction actions,
|
||||
|
||||
// Gets the nth action.
|
||||
static ActionData* get_action(FlAccessibleNode* self, gint index) {
|
||||
if (index < 0 || static_cast<guint>(index) >= self->actions->len)
|
||||
if (index < 0 || static_cast<guint>(index) >= self->actions->len) {
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<ActionData*>(g_ptr_array_index(self->actions, index));
|
||||
}
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ TEST(FlDartProjectTest, DartEntrypointArgs) {
|
||||
EXPECT_EQ(g_strv_length(retrieved_args), 0U);
|
||||
|
||||
GPtrArray* args_array = g_ptr_array_new();
|
||||
g_ptr_array_add(args_array, (gpointer) "arg_one");
|
||||
g_ptr_array_add(args_array, (gpointer) "arg_two");
|
||||
g_ptr_array_add(args_array, (gpointer) "arg_three");
|
||||
g_ptr_array_add(args_array, const_cast<char*>("arg_one"));
|
||||
g_ptr_array_add(args_array, const_cast<char*>("arg_two"));
|
||||
g_ptr_array_add(args_array, const_cast<char*>("arg_three"));
|
||||
g_ptr_array_add(args_array, nullptr);
|
||||
gchar** args = (gchar**)g_ptr_array_free(args_array, false);
|
||||
gchar** args = reinterpret_cast<gchar**>(g_ptr_array_free(args_array, false));
|
||||
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project, args);
|
||||
|
||||
|
||||
@@ -520,8 +520,9 @@ gboolean fl_engine_start(FlEngine* self, GError** error) {
|
||||
fl_settings_plugin_start(self->settings_plugin);
|
||||
|
||||
result = self->embedder_api.UpdateSemanticsEnabled(self->engine, TRUE);
|
||||
if (result != kSuccess)
|
||||
if (result != kSuccess) {
|
||||
g_warning("Failed to enable accessibility features on Flutter engine");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -285,11 +285,11 @@ TEST(FlEngineTest, DartEntrypointArgs) {
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
|
||||
GPtrArray* args_array = g_ptr_array_new();
|
||||
g_ptr_array_add(args_array, (gpointer) "arg_one");
|
||||
g_ptr_array_add(args_array, (gpointer) "arg_two");
|
||||
g_ptr_array_add(args_array, (gpointer) "arg_three");
|
||||
g_ptr_array_add(args_array, const_cast<char*>("arg_one"));
|
||||
g_ptr_array_add(args_array, const_cast<char*>("arg_two"));
|
||||
g_ptr_array_add(args_array, const_cast<char*>("arg_three"));
|
||||
g_ptr_array_add(args_array, nullptr);
|
||||
gchar** args = (gchar**)g_ptr_array_free(args_array, false);
|
||||
gchar** args = reinterpret_cast<gchar**>(g_ptr_array_free(args_array, false));
|
||||
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project, args);
|
||||
|
||||
|
||||
@@ -55,8 +55,9 @@ static void fl_gl_area_unrealize(GtkWidget* widget) {
|
||||
g_clear_object(&self->texture);
|
||||
|
||||
/* Make sure to unset the context if current */
|
||||
if (self->context == gdk_gl_context_get_current())
|
||||
if (self->context == gdk_gl_context_get_current()) {
|
||||
gdk_gl_context_clear_current();
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS(fl_gl_area_parent_class)->unrealize(widget);
|
||||
}
|
||||
@@ -67,10 +68,11 @@ static void fl_gl_area_size_allocate(GtkWidget* widget,
|
||||
gtk_widget_set_allocation(widget, allocation);
|
||||
|
||||
if (gtk_widget_get_has_window(widget)) {
|
||||
if (gtk_widget_get_realized(widget))
|
||||
if (gtk_widget_get_realized(widget)) {
|
||||
gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x,
|
||||
allocation->y, allocation->width,
|
||||
allocation->height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ static char* clone_string(const char* string) {
|
||||
}
|
||||
size_t len = strlen(string);
|
||||
char* result = g_new(char, len + 1);
|
||||
strcpy(result, string);
|
||||
strncpy(result, string, len + 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ static uint64_t event_to_logical_key(const FlKeyEvent* event) {
|
||||
}
|
||||
|
||||
static uint64_t event_to_timestamp(const FlKeyEvent* event) {
|
||||
return kMicrosecondsPerMillisecond * (double)event->time;
|
||||
return kMicrosecondsPerMillisecond * static_cast<double>(event->time);
|
||||
}
|
||||
|
||||
// Returns a newly accocated UTF-8 string from event->keyval that must be
|
||||
@@ -316,8 +316,9 @@ static char* event_to_character(const FlKeyEvent* event) {
|
||||
glong items_written;
|
||||
gchar* result = g_ucs4_to_utf8(&unicodeChar, 1, NULL, &items_written, NULL);
|
||||
if (items_written == 0) {
|
||||
if (result != NULL)
|
||||
if (result != NULL) {
|
||||
g_free(result);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -88,7 +88,7 @@ static FlKeyEmbedderCallRecord* fl_key_embedder_call_record_new(
|
||||
if (event->character != nullptr) {
|
||||
size_t character_length = strlen(event->character);
|
||||
char* clone_character = g_new(char, character_length + 1);
|
||||
strcpy(clone_character, event->character);
|
||||
strncpy(clone_character, event->character, character_length + 1);
|
||||
clone_event->character = clone_character;
|
||||
}
|
||||
self->event = clone_event;
|
||||
|
||||
@@ -15,7 +15,7 @@ static char* clone_string(const char* source) {
|
||||
}
|
||||
size_t length = strlen(source);
|
||||
char* result = g_new(char, length + 1);
|
||||
strcpy(result, source);
|
||||
strncpy(result, source, length + 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -213,8 +213,9 @@ static void fl_keyboard_manager_init(FlKeyboardManager* self) {}
|
||||
static void fl_keyboard_manager_dispose(GObject* object) {
|
||||
FlKeyboardManager* self = FL_KEYBOARD_MANAGER(object);
|
||||
|
||||
if (self->text_input_plugin != nullptr)
|
||||
if (self->text_input_plugin != nullptr) {
|
||||
g_clear_object(&self->text_input_plugin);
|
||||
}
|
||||
g_ptr_array_free(self->responder_list, TRUE);
|
||||
g_ptr_array_set_free_func(self->pending_responds, g_object_unref);
|
||||
g_ptr_array_free(self->pending_responds, TRUE);
|
||||
@@ -234,8 +235,9 @@ gboolean g_ptr_array_find_with_equal_func1(GPtrArray* haystack,
|
||||
guint* index_) {
|
||||
guint i;
|
||||
g_return_val_if_fail(haystack != NULL, FALSE);
|
||||
if (equal_func == NULL)
|
||||
if (equal_func == NULL) {
|
||||
equal_func = g_direct_equal;
|
||||
}
|
||||
for (i = 0; i < haystack->len; i++) {
|
||||
if (equal_func(g_ptr_array_index(haystack, i), needle)) {
|
||||
if (index_ != NULL) {
|
||||
|
||||
@@ -70,8 +70,9 @@ gboolean fl_renderer_start(FlRenderer* self, FlView* view, GError** error) {
|
||||
gdk_gl_context_realize(priv->resource_context, error);
|
||||
}
|
||||
|
||||
if (*error != nullptr)
|
||||
if (*error != nullptr) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,13 +23,15 @@ static gboolean fl_renderer_gl_create_contexts(FlRenderer* renderer,
|
||||
|
||||
*visible = gdk_window_create_gl_context(window, error);
|
||||
|
||||
if (*error != nullptr)
|
||||
if (*error != nullptr) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*resource = gdk_window_create_gl_context(window, error);
|
||||
|
||||
if (*error != nullptr)
|
||||
if (*error != nullptr) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -93,8 +95,9 @@ static gboolean fl_renderer_gl_present_layers(FlRenderer* renderer,
|
||||
size_t layers_count) {
|
||||
FlView* view = fl_renderer_get_view(renderer);
|
||||
GdkGLContext* context = fl_renderer_get_context(renderer);
|
||||
if (!view || !context)
|
||||
if (!view || !context) {
|
||||
return FALSE;
|
||||
}
|
||||
fl_view_begin_frame(view);
|
||||
|
||||
for (size_t i = 0; i < layers_count; ++i) {
|
||||
|
||||
@@ -42,8 +42,9 @@ G_DEFINE_TYPE(FlSettingsPlugin, fl_settings_plugin, G_TYPE_OBJECT)
|
||||
|
||||
// See <https://www.w3.org/TR/WCAG20/#relativeluminancedef>.
|
||||
static gdouble linearize_color_component(gdouble component) {
|
||||
if (component <= 0.03928)
|
||||
if (component <= 0.03928) {
|
||||
return component / 12.92;
|
||||
}
|
||||
return pow((component + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
|
||||
@@ -61,8 +62,9 @@ static Brightness estimate_brightness_for_color(GdkRGBA* color) {
|
||||
// See <https://www.w3.org/TR/WCAG20/#contrast-ratiodef> and
|
||||
// <https://material.io/go/design-theming#color-color-palette>.
|
||||
const gdouble kThreshold = 0.15;
|
||||
if ((relative_luminance + 0.05) * (relative_luminance + 0.05) > kThreshold)
|
||||
if ((relative_luminance + 0.05) * (relative_luminance + 0.05) > kThreshold) {
|
||||
return Brightness::Light;
|
||||
}
|
||||
return Brightness::Dark;
|
||||
}
|
||||
|
||||
@@ -70,8 +72,9 @@ static bool is_dark_theme() {
|
||||
// GTK doesn't have a specific flag for dark themes, so we check if the
|
||||
// style text color is light or dark
|
||||
GList* windows = gtk_window_list_toplevels();
|
||||
if (windows == nullptr)
|
||||
if (windows == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GtkWidget* window = GTK_WIDGET(windows->data);
|
||||
g_list_free(windows);
|
||||
|
||||
@@ -661,10 +661,11 @@ TEST(FlStandardMessageCodecTest, EncodeListNested) {
|
||||
g_autoptr(FlValue) even_numbers = fl_value_new_list();
|
||||
g_autoptr(FlValue) odd_numbers = fl_value_new_list();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (i % 2 == 0)
|
||||
if (i % 2 == 0) {
|
||||
fl_value_append_take(even_numbers, fl_value_new_int(i));
|
||||
else
|
||||
} else {
|
||||
fl_value_append_take(odd_numbers, fl_value_new_int(i));
|
||||
}
|
||||
}
|
||||
g_autoptr(FlValue) value = fl_value_new_list();
|
||||
fl_value_append(value, even_numbers);
|
||||
@@ -758,8 +759,9 @@ TEST(FlStandardMessageCodecTest, EncodeDecodeLargeList) {
|
||||
g_autoptr(FlStandardMessageCodec) codec = fl_standard_message_codec_new();
|
||||
|
||||
g_autoptr(FlValue) value = fl_value_new_list();
|
||||
for (int i = 0; i < 65535; i++)
|
||||
for (int i = 0; i < 65535; i++) {
|
||||
fl_value_append_take(value, fl_value_new_int(i));
|
||||
}
|
||||
|
||||
g_autoptr(GError) error = nullptr;
|
||||
g_autoptr(GBytes) message =
|
||||
|
||||
@@ -375,8 +375,9 @@ static void fl_view_get_preferred_width(GtkWidget* widget,
|
||||
iterator = iterator->next) {
|
||||
FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
|
||||
|
||||
if (!gtk_widget_get_visible(child->widget))
|
||||
if (!gtk_widget_get_visible(child->widget)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
gtk_widget_get_preferred_width(child->widget, &child_min, &child_nat);
|
||||
|
||||
@@ -398,8 +399,9 @@ static void fl_view_get_preferred_height(GtkWidget* widget,
|
||||
iterator = iterator->next) {
|
||||
FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
|
||||
|
||||
if (!gtk_widget_get_visible(child->widget))
|
||||
if (!gtk_widget_get_visible(child->widget)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
gtk_widget_get_preferred_height(child->widget, &child_min, &child_nat);
|
||||
|
||||
@@ -416,17 +418,19 @@ static void fl_view_size_allocate(GtkWidget* widget,
|
||||
gtk_widget_set_allocation(widget, allocation);
|
||||
|
||||
if (gtk_widget_get_has_window(widget)) {
|
||||
if (gtk_widget_get_realized(widget))
|
||||
if (gtk_widget_get_realized(widget)) {
|
||||
gdk_window_move_resize(gtk_widget_get_window(widget), allocation->x,
|
||||
allocation->y, allocation->width,
|
||||
allocation->height);
|
||||
}
|
||||
}
|
||||
|
||||
for (GList* iterator = self->children_list; iterator;
|
||||
iterator = iterator->next) {
|
||||
FlViewChild* child = reinterpret_cast<FlViewChild*>(iterator->data);
|
||||
if (!gtk_widget_get_visible(child->widget))
|
||||
if (!gtk_widget_get_visible(child->widget)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GtkAllocation child_allocation = child->geometry;
|
||||
GtkRequisition child_requisition;
|
||||
@@ -758,10 +762,11 @@ static void fl_view_add_pending_child(FlView* self,
|
||||
GdkRectangle* geometry) {
|
||||
FlViewChild* child = g_new(FlViewChild, 1);
|
||||
child->widget = widget;
|
||||
if (geometry)
|
||||
if (geometry) {
|
||||
child->geometry = *geometry;
|
||||
else
|
||||
} else {
|
||||
child->geometry = {0, 0, 0, 0};
|
||||
}
|
||||
|
||||
self->pending_children_list =
|
||||
g_list_append(self->pending_children_list, child);
|
||||
@@ -796,8 +801,9 @@ void fl_view_add_widget(FlView* view,
|
||||
GList* find_child(GList* list, GtkWidget* widget) {
|
||||
for (GList* i = list; i; i = i->next) {
|
||||
FlViewChild* child = reinterpret_cast<FlViewChild*>(i->data);
|
||||
if (child && child->widget == widget)
|
||||
if (child && child->widget == widget) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -101,15 +101,16 @@ VulkanApplication::VulkanApplication(
|
||||
}
|
||||
|
||||
// Now that we have an instance, set up instance proc table entries.
|
||||
if (!vk.SetupInstanceProcAddresses(instance)) {
|
||||
if (!vk.SetupInstanceProcAddresses(VulkanHandle<VkInstance>(instance))) {
|
||||
FML_DLOG(INFO) << "Could not set up instance proc addresses.";
|
||||
return;
|
||||
}
|
||||
|
||||
instance_ = {instance, [this](VkInstance i) {
|
||||
FML_DLOG(INFO) << "Destroying Vulkan instance";
|
||||
vk.DestroyInstance(i, nullptr);
|
||||
}};
|
||||
instance_ = VulkanHandle<VkInstance>{instance, [this](VkInstance i) {
|
||||
FML_DLOG(INFO)
|
||||
<< "Destroying Vulkan instance";
|
||||
vk.DestroyInstance(i, nullptr);
|
||||
}};
|
||||
|
||||
if (enable_instance_debugging) {
|
||||
auto debug_report = std::make_unique<VulkanDebugReport>(vk, instance_);
|
||||
@@ -178,7 +179,8 @@ std::unique_ptr<VulkanDevice>
|
||||
VulkanApplication::AcquireFirstCompatibleLogicalDevice() const {
|
||||
for (auto device_handle : GetPhysicalDevices()) {
|
||||
auto logical_device = std::make_unique<VulkanDevice>(
|
||||
vk, device_handle, enable_validation_layers_);
|
||||
vk, VulkanHandle<VkPhysicalDevice>(device_handle),
|
||||
enable_validation_layers_);
|
||||
if (logical_device->IsValid()) {
|
||||
return logical_device;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ bool VulkanBackbuffer::CreateSemaphores() {
|
||||
return false;
|
||||
}
|
||||
|
||||
semaphores_[i] = {semaphore, semaphore_collect};
|
||||
semaphores_[i] = VulkanHandle<VkSemaphore>{semaphore, semaphore_collect};
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -90,7 +90,7 @@ bool VulkanBackbuffer::CreateFences() {
|
||||
return false;
|
||||
}
|
||||
|
||||
use_fences_[i] = {fence, fence_collect};
|
||||
use_fences_[i] = VulkanHandle<VkFence>{fence, fence_collect};
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -33,7 +33,7 @@ VulkanCommandBuffer::VulkanCommandBuffer(
|
||||
vk.FreeCommandBuffers(device_, pool_, 1, &buffer);
|
||||
};
|
||||
|
||||
handle_ = {buffer, buffer_collect};
|
||||
handle_ = VulkanHandle<VkCommandBuffer>{buffer, buffer_collect};
|
||||
|
||||
valid_ = true;
|
||||
}
|
||||
|
||||
@@ -209,9 +209,10 @@ VulkanDebugReport::VulkanDebugReport(
|
||||
return;
|
||||
}
|
||||
|
||||
handle_ = {handle, [this](VkDebugReportCallbackEXT handle) {
|
||||
vk.DestroyDebugReportCallbackEXT(application_, handle, nullptr);
|
||||
}};
|
||||
handle_ = VulkanHandle<VkDebugReportCallbackEXT>{
|
||||
handle, [this](VkDebugReportCallbackEXT handle) {
|
||||
vk.DestroyDebugReportCallbackEXT(application_, handle, nullptr);
|
||||
}};
|
||||
|
||||
valid_ = true;
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ VulkanDevice::VulkanDevice(VulkanProcTable& p_vk,
|
||||
return;
|
||||
}
|
||||
|
||||
device_ = {device,
|
||||
[this](VkDevice device) { vk.DestroyDevice(device, nullptr); }};
|
||||
device_ = VulkanHandle<VkDevice>{
|
||||
device, [this](VkDevice device) { vk.DestroyDevice(device, nullptr); }};
|
||||
|
||||
if (!vk.SetupDeviceProcAddresses(device_)) {
|
||||
FML_DLOG(INFO) << "Could not set up device proc addresses.";
|
||||
@@ -120,7 +120,7 @@ VulkanDevice::VulkanDevice(VulkanProcTable& p_vk,
|
||||
return;
|
||||
}
|
||||
|
||||
queue_ = queue;
|
||||
queue_ = VulkanHandle<VkQueue>(queue);
|
||||
|
||||
const VkCommandPoolCreateInfo command_pool_create_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
||||
@@ -137,9 +137,10 @@ VulkanDevice::VulkanDevice(VulkanProcTable& p_vk,
|
||||
return;
|
||||
}
|
||||
|
||||
command_pool_ = {command_pool, [this](VkCommandPool pool) {
|
||||
vk.DestroyCommandPool(device_, pool, nullptr);
|
||||
}};
|
||||
command_pool_ = VulkanHandle<VkCommandPool>{
|
||||
command_pool, [this](VkCommandPool pool) {
|
||||
vk.DestroyCommandPool(device_, pool, nullptr);
|
||||
}};
|
||||
|
||||
valid_ = true;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class VulkanHandle {
|
||||
|
||||
VulkanHandle() : handle_(VK_NULL_HANDLE) {}
|
||||
|
||||
VulkanHandle(Handle handle, const Disposer& disposer = nullptr)
|
||||
explicit VulkanHandle(Handle handle, const Disposer& disposer = nullptr)
|
||||
: handle_(handle), disposer_(disposer) {}
|
||||
|
||||
VulkanHandle(VulkanHandle&& other)
|
||||
@@ -46,8 +46,9 @@ class VulkanHandle {
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator bool() const { return handle_ != VK_NULL_HANDLE; }
|
||||
explicit operator bool() const { return handle_ != VK_NULL_HANDLE; }
|
||||
|
||||
// NOLINTNEXTLINE(google-explicit-constructor)
|
||||
operator Handle() const { return handle_; }
|
||||
|
||||
/// Relinquish responsibility of collecting the underlying handle when this
|
||||
|
||||
@@ -16,7 +16,7 @@ class VulkanCommandBuffer;
|
||||
|
||||
class VulkanImage {
|
||||
public:
|
||||
VulkanImage(VulkanHandle<VkImage> image);
|
||||
explicit VulkanImage(VulkanHandle<VkImage> image);
|
||||
|
||||
~VulkanImage();
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ bool VulkanProcTable::SetupInstanceProcAddresses(
|
||||
return true;
|
||||
}();
|
||||
|
||||
instance_ = {handle, nullptr};
|
||||
instance_ = VulkanHandle<VkInstance>{handle, nullptr};
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ bool VulkanProcTable::SetupDeviceProcAddresses(
|
||||
ACQUIRE_PROC(GetBufferCollectionPropertiesFUCHSIAX, handle);
|
||||
#endif // OS_FUCHSIA
|
||||
#endif // TEST_VULKAN_PROCS
|
||||
device_ = {handle, nullptr};
|
||||
device_ = VulkanHandle<VkDevice>{handle, nullptr};
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -193,13 +193,14 @@ GrVkGetProc VulkanProcTable::CreateSkiaGetProc() const {
|
||||
|
||||
return [this](const char* proc_name, VkInstance instance, VkDevice device) {
|
||||
if (device != VK_NULL_HANDLE) {
|
||||
auto result = AcquireProc(proc_name, {device, nullptr});
|
||||
auto result =
|
||||
AcquireProc(proc_name, VulkanHandle<VkDevice>{device, nullptr});
|
||||
if (result != nullptr) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return AcquireProc(proc_name, {instance, nullptr});
|
||||
return AcquireProc(proc_name, VulkanHandle<VkInstance>{instance, nullptr});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class VulkanProcTable : public fml::RefCountedThreadSafe<VulkanProcTable> {
|
||||
public:
|
||||
using Proto = T;
|
||||
|
||||
Proc(T proc = nullptr) : proc_(proc) {}
|
||||
explicit Proc(T proc = nullptr) : proc_(proc) {}
|
||||
|
||||
~Proc() { proc_ = nullptr; }
|
||||
|
||||
@@ -40,9 +40,9 @@ class VulkanProcTable : public fml::RefCountedThreadSafe<VulkanProcTable> {
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator bool() const { return proc_ != nullptr; }
|
||||
explicit operator bool() const { return proc_ != nullptr; }
|
||||
|
||||
operator T() const { return proc_; }
|
||||
operator T() const { return proc_; } // NOLINT(google-explicit-constructor)
|
||||
|
||||
private:
|
||||
T proc_;
|
||||
@@ -136,7 +136,7 @@ class VulkanProcTable : public fml::RefCountedThreadSafe<VulkanProcTable> {
|
||||
VulkanHandle<VkDevice> device_;
|
||||
|
||||
VulkanProcTable();
|
||||
VulkanProcTable(const char* path);
|
||||
explicit VulkanProcTable(const char* path);
|
||||
~VulkanProcTable();
|
||||
bool OpenLibraryHandle(const char* path);
|
||||
bool SetupLoaderProcAddresses();
|
||||
|
||||
@@ -25,9 +25,10 @@ class VulkanProvider {
|
||||
&fence)) != VK_SUCCESS)
|
||||
return vulkan::VulkanHandle<VkFence>();
|
||||
|
||||
return {fence, [this](VkFence fence) {
|
||||
vk().DestroyFence(vk_device(), fence, nullptr);
|
||||
}};
|
||||
return VulkanHandle<VkFence>{fence, [this](VkFence fence) {
|
||||
vk().DestroyFence(vk_device(), fence,
|
||||
nullptr);
|
||||
}};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ VulkanSurface::VulkanSurface(
|
||||
return;
|
||||
}
|
||||
|
||||
surface_ = {surface, [this](VkSurfaceKHR surface) {
|
||||
vk.DestroySurfaceKHR(application_.GetInstance(), surface,
|
||||
nullptr);
|
||||
}};
|
||||
surface_ = VulkanHandle<VkSurfaceKHR>{
|
||||
surface, [this](VkSurfaceKHR surface) {
|
||||
vk.DestroySurfaceKHR(application_.GetInstance(), surface, nullptr);
|
||||
}};
|
||||
|
||||
valid_ = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user