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
5 changes: 2 additions & 3 deletions flow/surface_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <limits>

#include "flutter/flow/layers/layer.h"
#include "flutter/fml/logging.h"
#include "flutter/fml/trace_event.h"
#include "third_party/skia/include/utils/SkNWayCanvas.h"
Expand All @@ -25,9 +26,7 @@ SurfaceFrame::SurfaceFrame(sk_sp<SkSurface> surface,
if (surface_) {
canvas_ = surface_->getCanvas();
} else if (display_list_fallback) {
dl_recorder_ = sk_make_sp<DisplayListCanvasRecorder>(
SkRect::MakeWH(std::numeric_limits<SkScalar>::max(),
std::numeric_limits<SkScalar>::max()));
dl_recorder_ = sk_make_sp<DisplayListCanvasRecorder>(kGiantRect);
canvas_ = dl_recorder_.get();
}
}
Expand Down
12 changes: 12 additions & 0 deletions flow/surface_frame_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,16 @@ TEST(FlowTest, SurfaceFrameDoesNotSubmitInDtor) {
surface_frame.reset();
}

TEST(FlowTest, SurfaceFrameDoesNotHaveEmptyCanvas) {
SurfaceFrame::FramebufferInfo framebuffer_info;
SurfaceFrame frame(
/*surface=*/nullptr, framebuffer_info,
/*submit_callback=*/[](const SurfaceFrame&, SkCanvas*) { return true; },
/*context_result=*/nullptr, /*display_list_fallback=*/true);

EXPECT_FALSE(frame.SkiaCanvas()->getLocalClipBounds().isEmpty());
EXPECT_FALSE(
frame.SkiaCanvas()->quickReject(SkRect::MakeLTRB(10, 10, 50, 50)));
}

} // namespace flutter
31 changes: 22 additions & 9 deletions impeller/renderer/backend/metal/render_pass_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -493,18 +493,31 @@ static bool Bind(PassBindingsCache& pass,
if (!mtl_index_buffer) {
return false;
}

FML_DCHECK(command.index_count *
(command.index_type == IndexType::k16bit ? 2 : 4) ==
command.index_buffer.range.length);
// Returns void. All error checking must be done by this point.
[encoder drawIndexedPrimitives:ToMTLPrimitiveType(command.primitive_type)
indexCount:command.index_count
indexType:ToMTLIndexType(command.index_type)
indexBuffer:mtl_index_buffer
indexBufferOffset:command.index_buffer.range.offset
instanceCount:command.instance_count
baseVertex:command.base_vertex
baseInstance:0u];

if (command.instance_count != 1u) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already do an early return if it == 0u above.

#if TARGET_OS_SIMULATOR
VALIDATION_LOG << "iOS Simulator does not support instanced rendering.";
return false;
#endif
[encoder drawIndexedPrimitives:ToMTLPrimitiveType(command.primitive_type)
indexCount:command.index_count
indexType:ToMTLIndexType(command.index_type)
indexBuffer:mtl_index_buffer
indexBufferOffset:command.index_buffer.range.offset
instanceCount:command.instance_count
baseVertex:command.base_vertex
baseInstance:0u];
} else {
[encoder drawIndexedPrimitives:ToMTLPrimitiveType(command.primitive_type)
indexCount:command.index_count
indexType:ToMTLIndexType(command.index_type)
indexBuffer:mtl_index_buffer
indexBufferOffset:command.index_buffer.range.offset];
}
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace impeller {

constexpr size_t DefaultUniformAlignment() {
#if FML_OS_IOS
#if FML_OS_IOS && !TARGET_OS_SIMULATOR
return 16u;
#elif FML_OS_MACOSX
return 256u;
Expand Down