forked from firka/flutter
Enables bugprone-unchecked-optional-access for some files (flutter/engine#42428)
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
#include "flutter/flow/testing/layer_test.h"
|
||||
#include "flutter/flow/testing/mock_embedder.h"
|
||||
#include "flutter/flow/testing/mock_layer.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
#include "flutter/flow/raster_cache_util.h"
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
namespace flutter {
|
||||
|
||||
static bool IsDisplayListWorthRasterizing(
|
||||
@@ -152,8 +149,10 @@ bool DisplayListRasterCacheItem::TryToPrepareRasterCache(
|
||||
// display_list or picture_list to calculate the memory they used, we
|
||||
// shouldn't cache the current node if the memory is more significant than the
|
||||
// limit.
|
||||
auto id = GetId();
|
||||
FML_DCHECK(id.has_value());
|
||||
if (cache_state_ == kNone || !context.raster_cache || parent_cached ||
|
||||
!context.raster_cache->GenerateNewCacheInThisFrame()) {
|
||||
!context.raster_cache->GenerateNewCacheInThisFrame() || !id.has_value()) {
|
||||
return false;
|
||||
}
|
||||
SkRect bounds = display_list_->bounds().makeOffset(offset_.x(), offset_.y());
|
||||
@@ -167,11 +166,8 @@ bool DisplayListRasterCacheItem::TryToPrepareRasterCache(
|
||||
// clang-format on
|
||||
};
|
||||
return context.raster_cache->UpdateCacheEntry(
|
||||
GetId().value(), r_context,
|
||||
[display_list = display_list_](DlCanvas* canvas) {
|
||||
id.value(), r_context, [display_list = display_list_](DlCanvas* canvas) {
|
||||
canvas->DrawDisplayList(display_list);
|
||||
});
|
||||
}
|
||||
} // namespace flutter
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
#include "flutter/fml/task_source.h"
|
||||
#include "flutter/fml/thread_local.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
namespace fml {
|
||||
|
||||
const size_t TaskQueueId::kUnmerged = ULONG_MAX;
|
||||
@@ -396,9 +393,9 @@ TaskSource::TopTask MessageLoopTaskQueues::PeekNextTaskUnlocked(
|
||||
// At least one task at the top because PeekNextTaskUnlocked() is called after
|
||||
// HasPendingTasksUnlocked()
|
||||
FML_CHECK(top_task.has_value());
|
||||
// Covered by FML_CHECK.
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
return top_task.value();
|
||||
}
|
||||
|
||||
} // namespace fml
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
#include "impeller/entity/geometry/geometry.h"
|
||||
#include "impeller/geometry/path_builder.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
namespace impeller {
|
||||
|
||||
Canvas::Canvas() {
|
||||
@@ -187,17 +184,17 @@ void Canvas::DrawPaint(const Paint& paint) {
|
||||
bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
|
||||
Scalar corner_radius,
|
||||
const Paint& paint) {
|
||||
if (paint.color_source.GetType() != ColorSource::Type::kColor ||
|
||||
paint.style != Paint::Style::kFill) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!paint.mask_blur_descriptor.has_value() ||
|
||||
paint.mask_blur_descriptor->style != FilterContents::BlurStyle::kNormal) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Paint new_paint = paint;
|
||||
if (new_paint.color_source.GetType() != ColorSource::Type::kColor ||
|
||||
new_paint.style != Paint::Style::kFill) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!new_paint.mask_blur_descriptor.has_value() ||
|
||||
new_paint.mask_blur_descriptor->style !=
|
||||
FilterContents::BlurStyle::kNormal) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For symmetrically mask blurred solid RRects, absorb the mask blur and use
|
||||
// a faster SDF approximation.
|
||||
@@ -530,7 +527,11 @@ void Canvas::DrawTextFrame(const TextFrame& text_frame,
|
||||
entity.SetTransformation(GetCurrentTransformation());
|
||||
|
||||
Entity test;
|
||||
auto cvg = text_contents->GetCoverage(test).value();
|
||||
auto maybe_cvg = text_contents->GetCoverage(test);
|
||||
FML_CHECK(maybe_cvg.has_value());
|
||||
// Covered by FML_CHECK.
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
auto cvg = maybe_cvg.value();
|
||||
color_text_contents->SetTextPosition(cvg.origin + position);
|
||||
|
||||
text_contents->SetOffset(-cvg.origin);
|
||||
@@ -612,8 +613,12 @@ void Canvas::DrawVertices(const std::shared_ptr<VerticesGeometry>& vertices,
|
||||
if (size.has_value()) {
|
||||
src_coverage = Rect::MakeXYWH(0, 0, size->width, size->height);
|
||||
} else {
|
||||
src_coverage = vertices->GetTextureCoordinateCoverge().value_or(
|
||||
vertices->GetCoverage(Matrix{}).value());
|
||||
auto cvg = vertices->GetCoverage(Matrix{});
|
||||
FML_CHECK(cvg.has_value());
|
||||
src_coverage =
|
||||
// Covered by FML_CHECK.
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
vertices->GetTextureCoordinateCoverge().value_or(cvg.value());
|
||||
}
|
||||
src_contents =
|
||||
src_paint.CreateContentsForGeometry(Geometry::MakeRect(src_coverage));
|
||||
@@ -661,5 +666,3 @@ void Canvas::DrawAtlas(const std::shared_ptr<Image>& atlas,
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
#include "impeller/aiks/aiks_context.h"
|
||||
#include "impeller/entity/contents/filters/filter_contents.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
namespace impeller {
|
||||
|
||||
sk_sp<DlImageImpeller> DlImageImpeller::Make(std::shared_ptr<Texture> texture,
|
||||
@@ -40,6 +37,9 @@ sk_sp<DlImageImpeller> DlImageImpeller::MakeFromYUVTextures(
|
||||
std::nullopt, // sampler_descriptor
|
||||
true, // msaa_enabled
|
||||
"MakeYUVToRGBFilter Snapshot"); // label
|
||||
if (!snapshot.has_value()) {
|
||||
return nullptr;
|
||||
}
|
||||
return impeller::DlImageImpeller::Make(snapshot->texture);
|
||||
}
|
||||
|
||||
@@ -94,5 +94,3 @@ size_t DlImageImpeller::GetApproximateByteSize() const {
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
#include "impeller/renderer/command_buffer.h"
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
namespace impeller {
|
||||
|
||||
ContentContextOptions OptionsFromPass(const RenderPass& pass) {
|
||||
@@ -79,6 +76,9 @@ std::optional<Snapshot> Contents::RenderToSnapshot(
|
||||
|
||||
if (coverage_limit.has_value()) {
|
||||
coverage = coverage->Intersection(*coverage_limit);
|
||||
if (!coverage.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
auto texture = renderer.MakeSubpass(
|
||||
@@ -151,5 +151,3 @@ void Contents::SetColorSourceSize(Size size) {
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
@@ -14,9 +14,6 @@
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
#include "impeller/renderer/sampler_library.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
namespace impeller {
|
||||
|
||||
static std::optional<SamplerAddressMode> TileModeToAddressMode(
|
||||
@@ -66,6 +63,9 @@ void TiledTextureContents::SetColorFilter(
|
||||
std::optional<std::shared_ptr<Texture>>
|
||||
TiledTextureContents::CreateFilterTexture(
|
||||
const ContentContext& renderer) const {
|
||||
if (!color_filter_.has_value()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const ColorFilterProc& filter = color_filter_.value();
|
||||
auto color_filter_contents = filter(FilterInput::Make(texture_));
|
||||
auto snapshot = color_filter_contents->RenderToSnapshot(
|
||||
@@ -198,5 +198,3 @@ bool TiledTextureContents::Render(const ContentContext& renderer,
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
@@ -34,9 +34,6 @@
|
||||
#include "impeller/renderer/render_pass.h"
|
||||
#include "impeller/renderer/sampler_library.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
struct ImGui_ImplImpeller_Data {
|
||||
std::shared_ptr<impeller::Context> context;
|
||||
std::shared_ptr<impeller::Texture> font_texture;
|
||||
@@ -97,8 +94,12 @@ bool ImGui_ImplImpeller_Init(
|
||||
auto desc = impeller::PipelineBuilder<impeller::ImguiRasterVertexShader,
|
||||
impeller::ImguiRasterFragmentShader>::
|
||||
MakeDefaultPipelineDescriptor(*context);
|
||||
desc->ClearStencilAttachments();
|
||||
desc->ClearDepthAttachment();
|
||||
IM_ASSERT(desc.has_value() && "Could not create Impeller pipeline");
|
||||
if (desc.has_value()) { // Needed to silence clang-tidy check
|
||||
// bugprone-unchecked-optional-access.
|
||||
desc->ClearStencilAttachments();
|
||||
desc->ClearDepthAttachment();
|
||||
}
|
||||
|
||||
bd->pipeline =
|
||||
context->GetPipelineLibrary()->GetPipeline(std::move(desc)).Get();
|
||||
@@ -272,5 +273,3 @@ void ImGui_ImplImpeller_RenderDrawData(ImDrawData* draw_data,
|
||||
index_buffer_offset += draw_list_idx_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
|
||||
#include "impeller/renderer/capabilities.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
namespace impeller {
|
||||
|
||||
Capabilities::Capabilities() = default;
|
||||
@@ -218,11 +215,9 @@ std::unique_ptr<Capabilities> CapabilitiesBuilder::Build() {
|
||||
supports_read_from_onscreen_texture_, //
|
||||
supports_read_from_resolve_, //
|
||||
supports_decal_tile_mode_, //
|
||||
*default_color_format_, //
|
||||
*default_stencil_format_ //
|
||||
default_color_format_.value_or(PixelFormat::kUnknown), //
|
||||
default_stencil_format_.value_or(PixelFormat::kUnknown) //
|
||||
));
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
#include "third_party/skia/include/gpu/ganesh/SkSurfaceGanesh.h"
|
||||
#include "third_party/skia/include/utils/SkBase64.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
namespace flutter {
|
||||
|
||||
// The rasterizer will tell Skia to purge cached resources that have not been
|
||||
@@ -589,9 +586,10 @@ RasterStatus Rasterizer::DrawToSurfaceUnsafe(
|
||||
(!raster_thread_merger_ || raster_thread_merger_->IsMerged());
|
||||
|
||||
damage = std::make_unique<FrameDamage>();
|
||||
if (frame->framebuffer_info().existing_damage && !force_full_repaint) {
|
||||
auto existing_damage = frame->framebuffer_info().existing_damage;
|
||||
if (existing_damage.has_value() && !force_full_repaint) {
|
||||
damage->SetPreviousLayerTree(last_layer_tree_.get());
|
||||
damage->AddAdditionalDamage(*frame->framebuffer_info().existing_damage);
|
||||
damage->AddAdditionalDamage(existing_damage.value());
|
||||
damage->SetClipAlignment(
|
||||
frame->framebuffer_info().horizontal_clip_alignment,
|
||||
frame->framebuffer_info().vertical_clip_alignment);
|
||||
@@ -870,5 +868,3 @@ Rasterizer::Screenshot::Screenshot(const Screenshot& other) = default;
|
||||
Rasterizer::Screenshot::~Screenshot() = default;
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
#include "flutter/shell/platform/embedder/embedder_render_target.h"
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
|
||||
// TODO(zanderso): https://github.com/flutter/flutter/issues/127701
|
||||
// NOLINTBEGIN(bugprone-unchecked-optional-access)
|
||||
|
||||
namespace flutter {
|
||||
|
||||
EmbedderExternalViewEmbedder::EmbedderExternalViewEmbedder(
|
||||
@@ -227,6 +224,8 @@ void EmbedderExternalViewEmbedder::SubmitFrame(
|
||||
const auto& external_view = pending_views_.at(view_id);
|
||||
if (external_view->HasPlatformView()) {
|
||||
presented_layers.PushPlatformViewLayer(
|
||||
// Covered by HasPlatformView().
|
||||
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
|
||||
external_view->GetViewIdentifier()
|
||||
.platform_view_id.value(), // view id
|
||||
*external_view->GetEmbeddedViewParams() // view params
|
||||
@@ -267,5 +266,3 @@ void EmbedderExternalViewEmbedder::SubmitFrame(
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
// NOLINTEND(bugprone-unchecked-optional-access)
|
||||
|
||||
Reference in New Issue
Block a user