mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Render on Simulator (flutter/engine#35692)
This commit is contained in:
parent
9167b654b4
commit
cce2ee3fb8
@ -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"
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -493,18 +493,31 @@ bool RenderPassMTL::EncodeCommands(const std::shared_ptr<Allocator>& allocator,
|
||||
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) {
|
||||
#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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user