Split out EmbedderTest{Context,Compositor} to handle software and GL separately (flutter/engine#20962)
This commit is contained in:
@@ -141,10 +141,20 @@ if (current_toolchain == host_toolchain) {
|
||||
"tests/embedder_config_builder.h",
|
||||
"tests/embedder_test.cc",
|
||||
"tests/embedder_test.h",
|
||||
"tests/embedder_test_backingstore_producer.cc",
|
||||
"tests/embedder_test_backingstore_producer.h",
|
||||
"tests/embedder_test_compositor.cc",
|
||||
"tests/embedder_test_compositor.h",
|
||||
"tests/embedder_test_compositor_gl.cc",
|
||||
"tests/embedder_test_compositor_gl.h",
|
||||
"tests/embedder_test_compositor_software.cc",
|
||||
"tests/embedder_test_compositor_software.h",
|
||||
"tests/embedder_test_context.cc",
|
||||
"tests/embedder_test_context.h",
|
||||
"tests/embedder_test_context_gl.cc",
|
||||
"tests/embedder_test_context_gl.h",
|
||||
"tests/embedder_test_context_software.cc",
|
||||
"tests/embedder_test_context_software.h",
|
||||
"tests/embedder_unittests.cc",
|
||||
]
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ using Embedder11yTest = testing::EmbedderTest;
|
||||
|
||||
// TODO(52372): De-flake and re-enable.
|
||||
TEST_F(Embedder11yTest, DISABLED_A11yTreeIsConsistent) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
|
||||
|
||||
@@ -27,28 +27,28 @@ EmbedderConfigBuilder::EmbedderConfigBuilder(
|
||||
|
||||
opengl_renderer_config_.struct_size = sizeof(FlutterOpenGLRendererConfig);
|
||||
opengl_renderer_config_.make_current = [](void* context) -> bool {
|
||||
return reinterpret_cast<EmbedderTestContext*>(context)->GLMakeCurrent();
|
||||
return reinterpret_cast<EmbedderTestContextGL*>(context)->GLMakeCurrent();
|
||||
};
|
||||
opengl_renderer_config_.clear_current = [](void* context) -> bool {
|
||||
return reinterpret_cast<EmbedderTestContext*>(context)->GLClearCurrent();
|
||||
return reinterpret_cast<EmbedderTestContextGL*>(context)->GLClearCurrent();
|
||||
};
|
||||
opengl_renderer_config_.present_with_info =
|
||||
[](void* context, const FlutterPresentInfo* present_info) -> bool {
|
||||
return reinterpret_cast<EmbedderTestContext*>(context)->GLPresent(
|
||||
return reinterpret_cast<EmbedderTestContextGL*>(context)->GLPresent(
|
||||
present_info->fbo_id);
|
||||
};
|
||||
opengl_renderer_config_.fbo_with_frame_info_callback =
|
||||
[](void* context, const FlutterFrameInfo* frame_info) -> uint32_t {
|
||||
return reinterpret_cast<EmbedderTestContext*>(context)->GLGetFramebuffer(
|
||||
return reinterpret_cast<EmbedderTestContextGL*>(context)->GLGetFramebuffer(
|
||||
*frame_info);
|
||||
};
|
||||
opengl_renderer_config_.make_resource_current = [](void* context) -> bool {
|
||||
return reinterpret_cast<EmbedderTestContext*>(context)
|
||||
return reinterpret_cast<EmbedderTestContextGL*>(context)
|
||||
->GLMakeResourceCurrent();
|
||||
};
|
||||
opengl_renderer_config_.gl_proc_resolver = [](void* context,
|
||||
const char* name) -> void* {
|
||||
return reinterpret_cast<EmbedderTestContext*>(context)->GLGetProcAddress(
|
||||
return reinterpret_cast<EmbedderTestContextGL*>(context)->GLGetProcAddress(
|
||||
name);
|
||||
};
|
||||
opengl_renderer_config_.fbo_reset_after_present = true;
|
||||
@@ -72,7 +72,7 @@ EmbedderConfigBuilder::EmbedderConfigBuilder(
|
||||
return false;
|
||||
}
|
||||
bitmap.setImmutable();
|
||||
return reinterpret_cast<EmbedderTestContext*>(context)->SofwarePresent(
|
||||
return reinterpret_cast<EmbedderTestContextSoftware*>(context)->Present(
|
||||
SkImage::MakeFromBitmap(bitmap));
|
||||
};
|
||||
|
||||
@@ -124,7 +124,7 @@ void EmbedderConfigBuilder::SetOpenGLFBOCallBack() {
|
||||
frame_info.struct_size = sizeof(FlutterFrameInfo);
|
||||
frame_info.size.width = 0;
|
||||
frame_info.size.height = 0;
|
||||
return reinterpret_cast<EmbedderTestContext*>(context)->GLGetFramebuffer(
|
||||
return reinterpret_cast<EmbedderTestContextGL*>(context)->GLGetFramebuffer(
|
||||
frame_info);
|
||||
};
|
||||
}
|
||||
@@ -134,7 +134,7 @@ void EmbedderConfigBuilder::SetOpenGLPresentCallBack() {
|
||||
FML_CHECK(renderer_config_.type == FlutterRendererType::kOpenGL);
|
||||
renderer_config_.open_gl.present = [](void* context) -> bool {
|
||||
// passing a placeholder fbo_id.
|
||||
return reinterpret_cast<EmbedderTestContext*>(context)->GLPresent(0);
|
||||
return reinterpret_cast<EmbedderTestContextGL*>(context)->GLPresent(0);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -269,6 +269,16 @@ FlutterCompositor& EmbedderConfigBuilder::GetCompositor() {
|
||||
return compositor_;
|
||||
}
|
||||
|
||||
void EmbedderConfigBuilder::SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType type) {
|
||||
auto& compositor = context_.GetCompositor();
|
||||
// TODO(wrightgeorge): figure out a better way of plumbing through the
|
||||
// GrDirectContext
|
||||
compositor.SetBackingStoreProducer(
|
||||
std::make_unique<EmbedderTestBackingStoreProducer>(
|
||||
compositor.GetGrContext(), type));
|
||||
}
|
||||
|
||||
UniqueEngine EmbedderConfigBuilder::LaunchEngine() const {
|
||||
return SetupEngine(true);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#include "flutter/fml/unique_object.h"
|
||||
#include "flutter/shell/platform/embedder/embedder.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_compositor.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_context.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_compositor_gl.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_context_gl.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_context_software.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
@@ -88,6 +89,9 @@ class EmbedderConfigBuilder {
|
||||
|
||||
FlutterCompositor& GetCompositor();
|
||||
|
||||
void SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType type);
|
||||
|
||||
UniqueEngine LaunchEngine() const;
|
||||
|
||||
UniqueEngine InitializeEngine() const;
|
||||
|
||||
@@ -13,14 +13,27 @@ std::string EmbedderTest::GetFixturesDirectory() const {
|
||||
return GetFixturesPath();
|
||||
}
|
||||
|
||||
EmbedderTestContext& EmbedderTest::GetEmbedderContext() {
|
||||
EmbedderTestContext& EmbedderTest::GetEmbedderContext(ContextType type) {
|
||||
// Setup the embedder context lazily instead of in the constructor because we
|
||||
// don't to do all the work if the test won't end up using context.
|
||||
if (!embedder_context_) {
|
||||
embedder_context_ =
|
||||
std::make_unique<EmbedderTestContext>(GetFixturesDirectory());
|
||||
if (!embedder_contexts_[type]) {
|
||||
switch (type) {
|
||||
case ContextType::kSoftwareContext:
|
||||
embedder_contexts_[type] =
|
||||
std::make_unique<EmbedderTestContextSoftware>(
|
||||
GetFixturesDirectory());
|
||||
break;
|
||||
case ContextType::kOpenGLContext:
|
||||
embedder_contexts_[type] =
|
||||
std::make_unique<EmbedderTestContextGL>(GetFixturesDirectory());
|
||||
break;
|
||||
default:
|
||||
FML_DCHECK(false) << "Invalid context type specified.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return *embedder_context_;
|
||||
|
||||
return *embedder_contexts_[type];
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_context.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_context_gl.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_context_software.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "flutter/testing/thread_test.h"
|
||||
|
||||
@@ -17,14 +19,20 @@ namespace testing {
|
||||
|
||||
class EmbedderTest : public ThreadTest {
|
||||
public:
|
||||
enum class ContextType {
|
||||
kSoftwareContext,
|
||||
kOpenGLContext,
|
||||
};
|
||||
|
||||
EmbedderTest();
|
||||
|
||||
std::string GetFixturesDirectory() const;
|
||||
|
||||
EmbedderTestContext& GetEmbedderContext();
|
||||
EmbedderTestContext& GetEmbedderContext(ContextType type);
|
||||
|
||||
private:
|
||||
std::unique_ptr<EmbedderTestContext> embedder_context_;
|
||||
std::map<ContextType, std::unique_ptr<EmbedderTestContext>>
|
||||
embedder_contexts_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTest);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
// 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 "flutter/shell/platform/embedder/tests/embedder_test_backingstore_producer.h"
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
EmbedderTestBackingStoreProducer::EmbedderTestBackingStoreProducer(
|
||||
sk_sp<GrDirectContext> context,
|
||||
RenderTargetType type)
|
||||
: context_(context), type_(type) {}
|
||||
|
||||
EmbedderTestBackingStoreProducer::~EmbedderTestBackingStoreProducer() = default;
|
||||
|
||||
bool EmbedderTestBackingStoreProducer::Create(
|
||||
const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* renderer_out) {
|
||||
switch (type_) {
|
||||
case RenderTargetType::kSoftwareBuffer:
|
||||
return CreateSoftware(config, renderer_out);
|
||||
case RenderTargetType::kOpenGLTexture:
|
||||
return CreateTexture(config, renderer_out);
|
||||
case RenderTargetType::kOpenGLFramebuffer:
|
||||
return CreateFramebuffer(config, renderer_out);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool EmbedderTestBackingStoreProducer::CreateFramebuffer(
|
||||
const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* backing_store_out) {
|
||||
const auto image_info =
|
||||
SkImageInfo::MakeN32Premul(config->size.width, config->size.height);
|
||||
|
||||
auto surface = SkSurface::MakeRenderTarget(
|
||||
context_.get(), // context
|
||||
SkBudgeted::kNo, // budgeted
|
||||
image_info, // image info
|
||||
1, // sample count
|
||||
kBottomLeft_GrSurfaceOrigin, // surface origin
|
||||
nullptr, // surface properties
|
||||
false // mipmaps
|
||||
);
|
||||
|
||||
if (!surface) {
|
||||
FML_LOG(ERROR) << "Could not create render target for compositor layer.";
|
||||
return false;
|
||||
}
|
||||
|
||||
GrBackendRenderTarget render_target = surface->getBackendRenderTarget(
|
||||
SkSurface::BackendHandleAccess::kDiscardWrite_BackendHandleAccess);
|
||||
|
||||
if (!render_target.isValid()) {
|
||||
FML_LOG(ERROR) << "Backend render target was invalid.";
|
||||
return false;
|
||||
}
|
||||
|
||||
GrGLFramebufferInfo framebuffer_info = {};
|
||||
if (!render_target.getGLFramebufferInfo(&framebuffer_info)) {
|
||||
FML_LOG(ERROR) << "Could not access backend framebuffer info.";
|
||||
return false;
|
||||
}
|
||||
|
||||
backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
|
||||
backing_store_out->user_data = surface.get();
|
||||
backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeFramebuffer;
|
||||
backing_store_out->open_gl.framebuffer.target = framebuffer_info.fFormat;
|
||||
backing_store_out->open_gl.framebuffer.name = framebuffer_info.fFBOID;
|
||||
// The balancing unref is in the destruction callback.
|
||||
surface->ref();
|
||||
backing_store_out->open_gl.framebuffer.user_data = surface.get();
|
||||
backing_store_out->open_gl.framebuffer.destruction_callback =
|
||||
[](void* user_data) { reinterpret_cast<SkSurface*>(user_data)->unref(); };
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmbedderTestBackingStoreProducer::CreateTexture(
|
||||
const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* backing_store_out) {
|
||||
const auto image_info =
|
||||
SkImageInfo::MakeN32Premul(config->size.width, config->size.height);
|
||||
|
||||
auto surface = SkSurface::MakeRenderTarget(
|
||||
context_.get(), // context
|
||||
SkBudgeted::kNo, // budgeted
|
||||
image_info, // image info
|
||||
1, // sample count
|
||||
kBottomLeft_GrSurfaceOrigin, // surface origin
|
||||
nullptr, // surface properties
|
||||
false // mipmaps
|
||||
);
|
||||
|
||||
if (!surface) {
|
||||
FML_LOG(ERROR) << "Could not create render target for compositor layer.";
|
||||
return false;
|
||||
}
|
||||
|
||||
GrBackendTexture render_texture = surface->getBackendTexture(
|
||||
SkSurface::BackendHandleAccess::kDiscardWrite_BackendHandleAccess);
|
||||
|
||||
if (!render_texture.isValid()) {
|
||||
FML_LOG(ERROR) << "Backend render texture was invalid.";
|
||||
return false;
|
||||
}
|
||||
|
||||
GrGLTextureInfo texture_info = {};
|
||||
if (!render_texture.getGLTextureInfo(&texture_info)) {
|
||||
FML_LOG(ERROR) << "Could not access backend texture info.";
|
||||
return false;
|
||||
}
|
||||
|
||||
backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
|
||||
backing_store_out->user_data = surface.get();
|
||||
backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeTexture;
|
||||
backing_store_out->open_gl.texture.target = texture_info.fTarget;
|
||||
backing_store_out->open_gl.texture.name = texture_info.fID;
|
||||
backing_store_out->open_gl.texture.format = texture_info.fFormat;
|
||||
// The balancing unref is in the destruction callback.
|
||||
surface->ref();
|
||||
backing_store_out->open_gl.texture.user_data = surface.get();
|
||||
backing_store_out->open_gl.texture.destruction_callback =
|
||||
[](void* user_data) { reinterpret_cast<SkSurface*>(user_data)->unref(); };
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmbedderTestBackingStoreProducer::CreateSoftware(
|
||||
const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* backing_store_out) {
|
||||
auto surface = SkSurface::MakeRaster(
|
||||
SkImageInfo::MakeN32Premul(config->size.width, config->size.height));
|
||||
|
||||
if (!surface) {
|
||||
FML_LOG(ERROR)
|
||||
<< "Could not create the render target for compositor layer.";
|
||||
return false;
|
||||
}
|
||||
|
||||
SkPixmap pixmap;
|
||||
if (!surface->peekPixels(&pixmap)) {
|
||||
FML_LOG(ERROR) << "Could not peek pixels of pixmap.";
|
||||
return false;
|
||||
}
|
||||
|
||||
backing_store_out->type = kFlutterBackingStoreTypeSoftware;
|
||||
backing_store_out->user_data = surface.get();
|
||||
backing_store_out->software.allocation = pixmap.addr();
|
||||
backing_store_out->software.row_bytes = pixmap.rowBytes();
|
||||
backing_store_out->software.height = pixmap.height();
|
||||
// The balancing unref is in the destruction callback.
|
||||
surface->ref();
|
||||
backing_store_out->software.user_data = surface.get();
|
||||
backing_store_out->software.destruction_callback = [](void* user_data) {
|
||||
reinterpret_cast<SkSurface*>(user_data)->unref();
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -0,0 +1,50 @@
|
||||
// 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_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_BACKINGSTORE_PRODUCER_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_BACKINGSTORE_PRODUCER_H_
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/shell/platform/embedder/embedder.h"
|
||||
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class EmbedderTestBackingStoreProducer {
|
||||
public:
|
||||
enum class RenderTargetType {
|
||||
kSoftwareBuffer,
|
||||
kOpenGLFramebuffer,
|
||||
kOpenGLTexture,
|
||||
};
|
||||
|
||||
EmbedderTestBackingStoreProducer(sk_sp<GrDirectContext> context,
|
||||
RenderTargetType type);
|
||||
~EmbedderTestBackingStoreProducer();
|
||||
|
||||
bool Create(const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* renderer_out);
|
||||
|
||||
private:
|
||||
bool CreateFramebuffer(const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* renderer_out);
|
||||
|
||||
bool CreateTexture(const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* renderer_out);
|
||||
|
||||
bool CreateSoftware(const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* backing_store_out);
|
||||
|
||||
sk_sp<GrDirectContext> context_;
|
||||
RenderTargetType type_;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestBackingStoreProducer);
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_BACKINGSTORE_PRODUCER_H_
|
||||
@@ -20,10 +20,6 @@ EmbedderTestCompositor::EmbedderTestCompositor(SkISize surface_size,
|
||||
|
||||
EmbedderTestCompositor::~EmbedderTestCompositor() = default;
|
||||
|
||||
void EmbedderTestCompositor::SetRenderTargetType(RenderTargetType type) {
|
||||
type_ = type;
|
||||
}
|
||||
|
||||
static void InvokeAllCallbacks(const std::vector<fml::closure>& callbacks) {
|
||||
for (const auto& callback : callbacks) {
|
||||
if (callback) {
|
||||
@@ -35,21 +31,7 @@ static void InvokeAllCallbacks(const std::vector<fml::closure>& callbacks) {
|
||||
bool EmbedderTestCompositor::CreateBackingStore(
|
||||
const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* backing_store_out) {
|
||||
bool success = false;
|
||||
switch (type_) {
|
||||
case RenderTargetType::kOpenGLFramebuffer:
|
||||
success = CreateFramebufferRenderSurface(config, backing_store_out);
|
||||
break;
|
||||
case RenderTargetType::kOpenGLTexture:
|
||||
success = CreateTextureRenderSurface(config, backing_store_out);
|
||||
break;
|
||||
case RenderTargetType::kSoftwareBuffer:
|
||||
success = CreateSoftwareRenderSurface(config, backing_store_out);
|
||||
break;
|
||||
default:
|
||||
FML_CHECK(false);
|
||||
return false;
|
||||
}
|
||||
bool success = backingstore_producer_->Create(config, backing_store_out);
|
||||
if (success) {
|
||||
backing_stores_created_++;
|
||||
InvokeAllCallbacks(on_create_render_target_callbacks_);
|
||||
@@ -68,94 +50,9 @@ bool EmbedderTestCompositor::CollectBackingStore(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmbedderTestCompositor::UpdateOffscrenComposition(
|
||||
const FlutterLayer** layers,
|
||||
size_t layers_count) {
|
||||
last_composition_ = nullptr;
|
||||
|
||||
const auto image_info = SkImageInfo::MakeN32Premul(surface_size_);
|
||||
|
||||
auto surface = type_ == RenderTargetType::kSoftwareBuffer
|
||||
? SkSurface::MakeRaster(image_info)
|
||||
: SkSurface::MakeRenderTarget(
|
||||
context_.get(), // context
|
||||
SkBudgeted::kNo, // budgeted
|
||||
image_info, // image info
|
||||
1, // sample count
|
||||
kTopLeft_GrSurfaceOrigin, // surface origin
|
||||
nullptr, // surface properties
|
||||
false // create mipmaps
|
||||
);
|
||||
|
||||
if (!surface) {
|
||||
FML_LOG(ERROR) << "Could not update the off-screen composition.";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
// This has to be transparent because we are going to be compositing this
|
||||
// sub-hierarchy onto the on-screen surface.
|
||||
canvas->clear(SK_ColorTRANSPARENT);
|
||||
|
||||
for (size_t i = 0; i < layers_count; ++i) {
|
||||
const auto* layer = layers[i];
|
||||
|
||||
sk_sp<SkImage> platform_renderered_contents;
|
||||
|
||||
sk_sp<SkImage> layer_image;
|
||||
SkIPoint canvas_offset = SkIPoint::Make(0, 0);
|
||||
|
||||
switch (layer->type) {
|
||||
case kFlutterLayerContentTypeBackingStore:
|
||||
layer_image =
|
||||
reinterpret_cast<SkSurface*>(layer->backing_store->user_data)
|
||||
->makeImageSnapshot();
|
||||
|
||||
break;
|
||||
case kFlutterLayerContentTypePlatformView:
|
||||
layer_image =
|
||||
platform_view_renderer_callback_
|
||||
? platform_view_renderer_callback_(*layer, context_.get())
|
||||
: nullptr;
|
||||
canvas_offset = SkIPoint::Make(layer->offset.x, layer->offset.y);
|
||||
break;
|
||||
};
|
||||
|
||||
// If the layer is not a platform view but the engine did not specify an
|
||||
// image for the backing store, it is an error.
|
||||
if (!layer_image && layer->type != kFlutterLayerContentTypePlatformView) {
|
||||
FML_LOG(ERROR) << "Could not snapshot layer in test compositor: "
|
||||
<< *layer;
|
||||
return false;
|
||||
}
|
||||
|
||||
// The test could have just specified no contents to be rendered in place of
|
||||
// a platform view. This is not an error.
|
||||
if (layer_image) {
|
||||
// The image rendered by Flutter already has the correct offset and
|
||||
// transformation applied. The layers offset is meant for the platform.
|
||||
canvas->drawImage(layer_image.get(), canvas_offset.x(),
|
||||
canvas_offset.y());
|
||||
}
|
||||
}
|
||||
|
||||
last_composition_ = surface->makeImageSnapshot();
|
||||
|
||||
if (!last_composition_) {
|
||||
FML_LOG(ERROR) << "Could not update the contents of the sub-composition.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (next_scene_callback_) {
|
||||
auto last_composition_snapshot = last_composition_->makeRasterImage();
|
||||
FML_CHECK(last_composition_snapshot);
|
||||
auto callback = next_scene_callback_;
|
||||
next_scene_callback_ = nullptr;
|
||||
callback(std::move(last_composition_snapshot));
|
||||
}
|
||||
|
||||
return true;
|
||||
void EmbedderTestCompositor::SetBackingStoreProducer(
|
||||
std::unique_ptr<EmbedderTestBackingStoreProducer> backingstore_producer) {
|
||||
backingstore_producer_ = std::move(backingstore_producer);
|
||||
}
|
||||
|
||||
sk_sp<SkImage> EmbedderTestCompositor::GetLastComposition() {
|
||||
@@ -184,139 +81,6 @@ bool EmbedderTestCompositor::Present(const FlutterLayer** layers,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmbedderTestCompositor::CreateFramebufferRenderSurface(
|
||||
const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* backing_store_out) {
|
||||
const auto image_info =
|
||||
SkImageInfo::MakeN32Premul(config->size.width, config->size.height);
|
||||
|
||||
auto surface = SkSurface::MakeRenderTarget(
|
||||
context_.get(), // context
|
||||
SkBudgeted::kNo, // budgeted
|
||||
image_info, // image info
|
||||
1, // sample count
|
||||
kBottomLeft_GrSurfaceOrigin, // surface origin
|
||||
nullptr, // surface properties
|
||||
false // mipmaps
|
||||
);
|
||||
|
||||
if (!surface) {
|
||||
FML_LOG(ERROR) << "Could not create render target for compositor layer.";
|
||||
return false;
|
||||
}
|
||||
|
||||
GrBackendRenderTarget render_target = surface->getBackendRenderTarget(
|
||||
SkSurface::BackendHandleAccess::kDiscardWrite_BackendHandleAccess);
|
||||
|
||||
if (!render_target.isValid()) {
|
||||
FML_LOG(ERROR) << "Backend render target was invalid.";
|
||||
return false;
|
||||
}
|
||||
|
||||
GrGLFramebufferInfo framebuffer_info = {};
|
||||
if (!render_target.getGLFramebufferInfo(&framebuffer_info)) {
|
||||
FML_LOG(ERROR) << "Could not access backend framebuffer info.";
|
||||
return false;
|
||||
}
|
||||
|
||||
backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
|
||||
backing_store_out->user_data = surface.get();
|
||||
backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeFramebuffer;
|
||||
backing_store_out->open_gl.framebuffer.target = framebuffer_info.fFormat;
|
||||
backing_store_out->open_gl.framebuffer.name = framebuffer_info.fFBOID;
|
||||
// The balancing unref is in the destruction callback.
|
||||
surface->ref();
|
||||
backing_store_out->open_gl.framebuffer.user_data = surface.get();
|
||||
backing_store_out->open_gl.framebuffer.destruction_callback =
|
||||
[](void* user_data) { reinterpret_cast<SkSurface*>(user_data)->unref(); };
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmbedderTestCompositor::CreateTextureRenderSurface(
|
||||
const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* backing_store_out) {
|
||||
const auto image_info =
|
||||
SkImageInfo::MakeN32Premul(config->size.width, config->size.height);
|
||||
|
||||
auto surface = SkSurface::MakeRenderTarget(
|
||||
context_.get(), // context
|
||||
SkBudgeted::kNo, // budgeted
|
||||
image_info, // image info
|
||||
1, // sample count
|
||||
kBottomLeft_GrSurfaceOrigin, // surface origin
|
||||
nullptr, // surface properties
|
||||
false // mipmaps
|
||||
|
||||
);
|
||||
|
||||
if (!surface) {
|
||||
FML_LOG(ERROR) << "Could not create render target for compositor layer.";
|
||||
return false;
|
||||
}
|
||||
|
||||
GrBackendTexture render_texture = surface->getBackendTexture(
|
||||
SkSurface::BackendHandleAccess::kDiscardWrite_BackendHandleAccess);
|
||||
|
||||
if (!render_texture.isValid()) {
|
||||
FML_LOG(ERROR) << "Backend render texture was invalid.";
|
||||
return false;
|
||||
}
|
||||
|
||||
GrGLTextureInfo texture_info = {};
|
||||
if (!render_texture.getGLTextureInfo(&texture_info)) {
|
||||
FML_LOG(ERROR) << "Could not access backend texture info.";
|
||||
return false;
|
||||
}
|
||||
|
||||
backing_store_out->type = kFlutterBackingStoreTypeOpenGL;
|
||||
backing_store_out->user_data = surface.get();
|
||||
backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeTexture;
|
||||
backing_store_out->open_gl.texture.target = texture_info.fTarget;
|
||||
backing_store_out->open_gl.texture.name = texture_info.fID;
|
||||
backing_store_out->open_gl.texture.format = texture_info.fFormat;
|
||||
// The balancing unref is in the destruction callback.
|
||||
surface->ref();
|
||||
backing_store_out->open_gl.texture.user_data = surface.get();
|
||||
backing_store_out->open_gl.texture.destruction_callback =
|
||||
[](void* user_data) { reinterpret_cast<SkSurface*>(user_data)->unref(); };
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmbedderTestCompositor::CreateSoftwareRenderSurface(
|
||||
const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* backing_store_out) {
|
||||
auto surface = SkSurface::MakeRaster(
|
||||
SkImageInfo::MakeN32Premul(config->size.width, config->size.height));
|
||||
|
||||
if (!surface) {
|
||||
FML_LOG(ERROR)
|
||||
<< "Could not create the render target for compositor layer.";
|
||||
return false;
|
||||
}
|
||||
|
||||
SkPixmap pixmap;
|
||||
if (!surface->peekPixels(&pixmap)) {
|
||||
FML_LOG(ERROR) << "Could not peek pixels of pixmap.";
|
||||
return false;
|
||||
}
|
||||
|
||||
backing_store_out->type = kFlutterBackingStoreTypeSoftware;
|
||||
backing_store_out->user_data = surface.get();
|
||||
backing_store_out->software.allocation = pixmap.addr();
|
||||
backing_store_out->software.row_bytes = pixmap.rowBytes();
|
||||
backing_store_out->software.height = pixmap.height();
|
||||
// The balancing unref is in the destruction callback.
|
||||
surface->ref();
|
||||
backing_store_out->software.user_data = surface.get();
|
||||
backing_store_out->software.destruction_callback = [](void* user_data) {
|
||||
reinterpret_cast<SkSurface*>(user_data)->unref();
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EmbedderTestCompositor::SetNextPresentCallback(
|
||||
const PresentCallback& next_present_callback) {
|
||||
SetPresentCallback(next_present_callback, true);
|
||||
@@ -368,5 +132,9 @@ void EmbedderTestCompositor::AddOnPresentCallback(fml::closure callback) {
|
||||
on_present_callbacks_.push_back(callback);
|
||||
}
|
||||
|
||||
sk_sp<GrDirectContext> EmbedderTestCompositor::GetGrContext() {
|
||||
return context_;
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "flutter/fml/closure.h"
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/shell/platform/embedder/embedder.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_backingstore_producer.h"
|
||||
#include "third_party/skia/include/gpu/GrDirectContext.h"
|
||||
|
||||
namespace flutter {
|
||||
@@ -17,17 +18,18 @@ namespace testing {
|
||||
|
||||
class EmbedderTestCompositor {
|
||||
public:
|
||||
enum class RenderTargetType {
|
||||
kOpenGLFramebuffer,
|
||||
kOpenGLTexture,
|
||||
kSoftwareBuffer,
|
||||
};
|
||||
using PlatformViewRendererCallback =
|
||||
std::function<sk_sp<SkImage>(const FlutterLayer& layer,
|
||||
GrDirectContext* context)>;
|
||||
using PresentCallback =
|
||||
std::function<void(const FlutterLayer** layers, size_t layers_count)>;
|
||||
|
||||
EmbedderTestCompositor(SkISize surface_size, sk_sp<GrDirectContext> context);
|
||||
|
||||
~EmbedderTestCompositor();
|
||||
virtual ~EmbedderTestCompositor();
|
||||
|
||||
void SetRenderTargetType(RenderTargetType type);
|
||||
void SetBackingStoreProducer(
|
||||
std::unique_ptr<EmbedderTestBackingStoreProducer> backingstore_producer);
|
||||
|
||||
bool CreateBackingStore(const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* backing_store_out);
|
||||
@@ -36,14 +38,9 @@ class EmbedderTestCompositor {
|
||||
|
||||
bool Present(const FlutterLayer** layers, size_t layers_count);
|
||||
|
||||
using PlatformViewRendererCallback =
|
||||
std::function<sk_sp<SkImage>(const FlutterLayer& layer,
|
||||
GrDirectContext* context)>;
|
||||
void SetPlatformViewRendererCallback(
|
||||
const PlatformViewRendererCallback& callback);
|
||||
|
||||
using PresentCallback =
|
||||
std::function<void(const FlutterLayer** layers, size_t layers_count)>;
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Allows tests to install a callback to notify them when the
|
||||
/// entire render tree has been finalized so they can run their
|
||||
@@ -73,10 +70,17 @@ class EmbedderTestCompositor {
|
||||
|
||||
void AddOnPresentCallback(fml::closure callback);
|
||||
|
||||
private:
|
||||
sk_sp<GrDirectContext> GetGrContext();
|
||||
|
||||
protected:
|
||||
virtual bool UpdateOffscrenComposition(const FlutterLayer** layers,
|
||||
size_t layers_count) = 0;
|
||||
|
||||
// TODO(gw280): encapsulate these properly for subclasses to use
|
||||
std::unique_ptr<EmbedderTestBackingStoreProducer> backingstore_producer_;
|
||||
const SkISize surface_size_;
|
||||
sk_sp<GrDirectContext> context_;
|
||||
RenderTargetType type_ = RenderTargetType::kOpenGLFramebuffer;
|
||||
|
||||
PlatformViewRendererCallback platform_view_renderer_callback_;
|
||||
bool present_callback_is_one_shot_ = false;
|
||||
PresentCallback present_callback_;
|
||||
@@ -88,22 +92,10 @@ class EmbedderTestCompositor {
|
||||
std::vector<fml::closure> on_collect_render_target_callbacks_;
|
||||
std::vector<fml::closure> on_present_callbacks_;
|
||||
|
||||
bool UpdateOffscrenComposition(const FlutterLayer** layers,
|
||||
size_t layers_count);
|
||||
|
||||
bool CreateFramebufferRenderSurface(const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* renderer_out);
|
||||
|
||||
bool CreateTextureRenderSurface(const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* renderer_out);
|
||||
|
||||
bool CreateSoftwareRenderSurface(const FlutterBackingStoreConfig* config,
|
||||
FlutterBackingStore* renderer_out);
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestCompositor);
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_H_
|
||||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_GL_H_
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
// 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 "flutter/shell/platform/embedder/tests/embedder_test_compositor_gl.h"
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_assertions.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
EmbedderTestCompositorGL::EmbedderTestCompositorGL(
|
||||
SkISize surface_size,
|
||||
sk_sp<GrDirectContext> context)
|
||||
: EmbedderTestCompositor(surface_size, context) {}
|
||||
|
||||
EmbedderTestCompositorGL::~EmbedderTestCompositorGL() = default;
|
||||
|
||||
bool EmbedderTestCompositorGL::UpdateOffscrenComposition(
|
||||
const FlutterLayer** layers,
|
||||
size_t layers_count) {
|
||||
last_composition_ = nullptr;
|
||||
|
||||
const auto image_info = SkImageInfo::MakeN32Premul(surface_size_);
|
||||
|
||||
auto surface =
|
||||
SkSurface::MakeRenderTarget(context_.get(), // context
|
||||
SkBudgeted::kNo, // budgeted
|
||||
image_info, // image info
|
||||
1, // sample count
|
||||
kTopLeft_GrSurfaceOrigin, // surface origin
|
||||
nullptr, // surface properties
|
||||
false // create mipmaps
|
||||
);
|
||||
|
||||
if (!surface) {
|
||||
FML_LOG(ERROR) << "Could not update the off-screen composition.";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
// This has to be transparent because we are going to be compositing this
|
||||
// sub-hierarchy onto the on-screen surface.
|
||||
canvas->clear(SK_ColorTRANSPARENT);
|
||||
|
||||
for (size_t i = 0; i < layers_count; ++i) {
|
||||
const auto* layer = layers[i];
|
||||
|
||||
sk_sp<SkImage> platform_renderered_contents;
|
||||
|
||||
sk_sp<SkImage> layer_image;
|
||||
SkIPoint canvas_offset = SkIPoint::Make(0, 0);
|
||||
|
||||
switch (layer->type) {
|
||||
case kFlutterLayerContentTypeBackingStore:
|
||||
layer_image =
|
||||
reinterpret_cast<SkSurface*>(layer->backing_store->user_data)
|
||||
->makeImageSnapshot();
|
||||
|
||||
break;
|
||||
case kFlutterLayerContentTypePlatformView:
|
||||
layer_image =
|
||||
platform_view_renderer_callback_
|
||||
? platform_view_renderer_callback_(*layer, context_.get())
|
||||
: nullptr;
|
||||
canvas_offset = SkIPoint::Make(layer->offset.x, layer->offset.y);
|
||||
break;
|
||||
};
|
||||
|
||||
// If the layer is not a platform view but the engine did not specify an
|
||||
// image for the backing store, it is an error.
|
||||
if (!layer_image && layer->type != kFlutterLayerContentTypePlatformView) {
|
||||
FML_LOG(ERROR) << "Could not snapshot layer in test compositor: "
|
||||
<< *layer;
|
||||
return false;
|
||||
}
|
||||
|
||||
// The test could have just specified no contents to be rendered in place of
|
||||
// a platform view. This is not an error.
|
||||
if (layer_image) {
|
||||
// The image rendered by Flutter already has the correct offset and
|
||||
// transformation applied. The layers offset is meant for the platform.
|
||||
canvas->drawImage(layer_image.get(), canvas_offset.x(),
|
||||
canvas_offset.y());
|
||||
}
|
||||
}
|
||||
|
||||
last_composition_ = surface->makeImageSnapshot();
|
||||
|
||||
if (!last_composition_) {
|
||||
FML_LOG(ERROR) << "Could not update the contents of the sub-composition.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (next_scene_callback_) {
|
||||
auto last_composition_snapshot = last_composition_->makeRasterImage();
|
||||
FML_CHECK(last_composition_snapshot);
|
||||
auto callback = next_scene_callback_;
|
||||
next_scene_callback_ = nullptr;
|
||||
callback(std::move(last_composition_snapshot));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_GL_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_GL_H_
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/shell/platform/embedder/embedder.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_compositor.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class EmbedderTestCompositorGL : public EmbedderTestCompositor {
|
||||
public:
|
||||
EmbedderTestCompositorGL(SkISize surface_size,
|
||||
sk_sp<GrDirectContext> context);
|
||||
|
||||
~EmbedderTestCompositorGL() override;
|
||||
|
||||
private:
|
||||
bool UpdateOffscrenComposition(const FlutterLayer** layers,
|
||||
size_t layers_count) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestCompositorGL);
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_GL_H_
|
||||
@@ -0,0 +1,102 @@
|
||||
// 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 "flutter/shell/platform/embedder/tests/embedder_test_compositor_software.h"
|
||||
|
||||
#include "flutter/fml/logging.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_assertions.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
EmbedderTestCompositorSoftware::EmbedderTestCompositorSoftware(
|
||||
SkISize surface_size,
|
||||
sk_sp<GrDirectContext> context)
|
||||
: EmbedderTestCompositor(surface_size, context) {}
|
||||
|
||||
EmbedderTestCompositorSoftware::~EmbedderTestCompositorSoftware() = default;
|
||||
|
||||
bool EmbedderTestCompositorSoftware::UpdateOffscrenComposition(
|
||||
const FlutterLayer** layers,
|
||||
size_t layers_count) {
|
||||
last_composition_ = nullptr;
|
||||
|
||||
const auto image_info = SkImageInfo::MakeN32Premul(surface_size_);
|
||||
|
||||
auto surface = SkSurface::MakeRaster(image_info);
|
||||
|
||||
if (!surface) {
|
||||
FML_LOG(ERROR) << "Could not update the off-screen composition.";
|
||||
return false;
|
||||
}
|
||||
|
||||
auto canvas = surface->getCanvas();
|
||||
|
||||
// This has to be transparent because we are going to be compositing this
|
||||
// sub-hierarchy onto the on-screen surface.
|
||||
canvas->clear(SK_ColorTRANSPARENT);
|
||||
|
||||
for (size_t i = 0; i < layers_count; ++i) {
|
||||
const auto* layer = layers[i];
|
||||
|
||||
sk_sp<SkImage> platform_renderered_contents;
|
||||
|
||||
sk_sp<SkImage> layer_image;
|
||||
SkIPoint canvas_offset = SkIPoint::Make(0, 0);
|
||||
|
||||
switch (layer->type) {
|
||||
case kFlutterLayerContentTypeBackingStore:
|
||||
layer_image =
|
||||
reinterpret_cast<SkSurface*>(layer->backing_store->user_data)
|
||||
->makeImageSnapshot();
|
||||
|
||||
break;
|
||||
case kFlutterLayerContentTypePlatformView:
|
||||
layer_image =
|
||||
platform_view_renderer_callback_
|
||||
? platform_view_renderer_callback_(*layer, context_.get())
|
||||
: nullptr;
|
||||
canvas_offset = SkIPoint::Make(layer->offset.x, layer->offset.y);
|
||||
break;
|
||||
};
|
||||
|
||||
// If the layer is not a platform view but the engine did not specify an
|
||||
// image for the backing store, it is an error.
|
||||
if (!layer_image && layer->type != kFlutterLayerContentTypePlatformView) {
|
||||
FML_LOG(ERROR) << "Could not snapshot layer in test compositor: "
|
||||
<< *layer;
|
||||
return false;
|
||||
}
|
||||
|
||||
// The test could have just specified no contents to be rendered in place of
|
||||
// a platform view. This is not an error.
|
||||
if (layer_image) {
|
||||
// The image rendered by Flutter already has the correct offset and
|
||||
// transformation applied. The layers offset is meant for the platform.
|
||||
canvas->drawImage(layer_image.get(), canvas_offset.x(),
|
||||
canvas_offset.y());
|
||||
}
|
||||
}
|
||||
|
||||
last_composition_ = surface->makeImageSnapshot();
|
||||
|
||||
if (!last_composition_) {
|
||||
FML_LOG(ERROR) << "Could not update the contents of the sub-composition.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (next_scene_callback_) {
|
||||
auto last_composition_snapshot = last_composition_->makeRasterImage();
|
||||
FML_CHECK(last_composition_snapshot);
|
||||
auto callback = next_scene_callback_;
|
||||
next_scene_callback_ = nullptr;
|
||||
callback(std::move(last_composition_snapshot));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_SOFTWARE_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_SOFTWARE_H_
|
||||
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_compositor.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class EmbedderTestCompositorSoftware : public EmbedderTestCompositor {
|
||||
public:
|
||||
EmbedderTestCompositorSoftware(SkISize surface_size,
|
||||
sk_sp<GrDirectContext> context);
|
||||
|
||||
~EmbedderTestCompositorSoftware() override;
|
||||
|
||||
private:
|
||||
bool UpdateOffscrenComposition(const FlutterLayer** layers,
|
||||
size_t layers_count);
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestCompositorSoftware);
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_TEST_COMPOSITOR_SOFTWARE_H_
|
||||
@@ -30,9 +30,7 @@ EmbedderTestContext::EmbedderTestContext(std::string assets_path)
|
||||
});
|
||||
}
|
||||
|
||||
EmbedderTestContext::~EmbedderTestContext() {
|
||||
SetGLGetFBOCallback(nullptr);
|
||||
}
|
||||
EmbedderTestContext::~EmbedderTestContext() = default;
|
||||
|
||||
void EmbedderTestContext::SetupAOTMappingsIfNecessary() {
|
||||
if (!DartVM::IsRunningPrecompiledCode()) {
|
||||
@@ -170,94 +168,10 @@ EmbedderTestContext::GetComputePlatformResolvedLocaleCallbackHook() {
|
||||
};
|
||||
}
|
||||
|
||||
void EmbedderTestContext::SetupOpenGLSurface(SkISize surface_size) {
|
||||
FML_CHECK(!gl_surface_);
|
||||
gl_surface_ = std::make_unique<TestGLSurface>(surface_size);
|
||||
}
|
||||
|
||||
bool EmbedderTestContext::GLMakeCurrent() {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
return gl_surface_->MakeCurrent();
|
||||
}
|
||||
|
||||
bool EmbedderTestContext::GLClearCurrent() {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
return gl_surface_->ClearCurrent();
|
||||
}
|
||||
|
||||
bool EmbedderTestContext::GLPresent(uint32_t fbo_id) {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
gl_surface_present_count_++;
|
||||
|
||||
GLPresentCallback callback;
|
||||
{
|
||||
std::scoped_lock lock(gl_callback_mutex_);
|
||||
callback = gl_present_callback_;
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback(fbo_id);
|
||||
}
|
||||
|
||||
FireRootSurfacePresentCallbackIfPresent(
|
||||
[&]() { return gl_surface_->GetRasterSurfaceSnapshot(); });
|
||||
|
||||
if (!gl_surface_->Present()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EmbedderTestContext::SetGLGetFBOCallback(GLGetFBOCallback callback) {
|
||||
std::scoped_lock lock(gl_callback_mutex_);
|
||||
gl_get_fbo_callback_ = callback;
|
||||
}
|
||||
|
||||
void EmbedderTestContext::SetGLPresentCallback(GLPresentCallback callback) {
|
||||
std::scoped_lock lock(gl_callback_mutex_);
|
||||
gl_present_callback_ = callback;
|
||||
}
|
||||
|
||||
uint32_t EmbedderTestContext::GLGetFramebuffer(FlutterFrameInfo frame_info) {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
|
||||
GLGetFBOCallback callback;
|
||||
{
|
||||
std::scoped_lock lock(gl_callback_mutex_);
|
||||
callback = gl_get_fbo_callback_;
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback(frame_info);
|
||||
}
|
||||
|
||||
const auto size = frame_info.size;
|
||||
return gl_surface_->GetFramebuffer(size.width, size.height);
|
||||
}
|
||||
|
||||
bool EmbedderTestContext::GLMakeResourceCurrent() {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
return gl_surface_->MakeResourceCurrent();
|
||||
}
|
||||
|
||||
void* EmbedderTestContext::GLGetProcAddress(const char* name) {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
return gl_surface_->GetProcAddress(name);
|
||||
}
|
||||
|
||||
FlutterTransformation EmbedderTestContext::GetRootSurfaceTransformation() {
|
||||
return FlutterTransformationMake(root_surface_transformation_);
|
||||
}
|
||||
|
||||
void EmbedderTestContext::SetupCompositor() {
|
||||
FML_CHECK(!compositor_) << "Already ssetup a compositor in this context.";
|
||||
FML_CHECK(gl_surface_)
|
||||
<< "Setup the GL surface before setting up a compositor.";
|
||||
compositor_ = std::make_unique<EmbedderTestCompositor>(
|
||||
gl_surface_->GetSurfaceSize(), gl_surface_->GetGrContext());
|
||||
}
|
||||
|
||||
EmbedderTestCompositor& EmbedderTestContext::GetCompositor() {
|
||||
FML_CHECK(compositor_)
|
||||
<< "Accessed the compositor on a context where one was not setup. Use "
|
||||
@@ -284,22 +198,6 @@ std::future<sk_sp<SkImage>> EmbedderTestContext::GetNextSceneImage() {
|
||||
return future;
|
||||
}
|
||||
|
||||
bool EmbedderTestContext::SofwarePresent(sk_sp<SkImage> image) {
|
||||
software_surface_present_count_++;
|
||||
|
||||
FireRootSurfacePresentCallbackIfPresent([image] { return image; });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t EmbedderTestContext::GetGLSurfacePresentCount() const {
|
||||
return gl_surface_present_count_;
|
||||
}
|
||||
|
||||
size_t EmbedderTestContext::GetSoftwareSurfacePresentCount() const {
|
||||
return software_surface_present_count_;
|
||||
}
|
||||
|
||||
/// @note Procedure doesn't copy all closures.
|
||||
void EmbedderTestContext::FireRootSurfacePresentCallbackIfPresent(
|
||||
const std::function<sk_sp<SkImage>(void)>& image_callback) {
|
||||
@@ -311,10 +209,5 @@ void EmbedderTestContext::FireRootSurfacePresentCallbackIfPresent(
|
||||
callback(image_callback());
|
||||
}
|
||||
|
||||
uint32_t EmbedderTestContext::GetWindowFBOId() const {
|
||||
FML_CHECK(gl_surface_);
|
||||
return gl_surface_->GetWindowFBOId();
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
@@ -43,7 +43,7 @@ class EmbedderTestContext {
|
||||
public:
|
||||
EmbedderTestContext(std::string assets_path = "");
|
||||
|
||||
~EmbedderTestContext();
|
||||
virtual ~EmbedderTestContext();
|
||||
|
||||
const std::string& GetAssetsPath() const;
|
||||
|
||||
@@ -72,47 +72,14 @@ class EmbedderTestContext {
|
||||
void SetPlatformMessageCallback(
|
||||
const std::function<void(const FlutterPlatformMessage*)>& callback);
|
||||
|
||||
EmbedderTestCompositor& GetCompositor();
|
||||
|
||||
std::future<sk_sp<SkImage>> GetNextSceneImage();
|
||||
|
||||
size_t GetGLSurfacePresentCount() const;
|
||||
EmbedderTestCompositor& GetCompositor();
|
||||
|
||||
size_t GetSoftwareSurfacePresentCount() const;
|
||||
virtual size_t GetSurfacePresentCount() const = 0;
|
||||
|
||||
using GLGetFBOCallback = std::function<void(FlutterFrameInfo frame_info)>;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Sets a callback that will be invoked (on the raster task
|
||||
/// runner) when the engine asks the embedder for a new FBO ID at
|
||||
/// the updated size.
|
||||
///
|
||||
/// @attention The callback will be invoked on the raster task runner. The
|
||||
/// callback can be set on the tests host thread.
|
||||
///
|
||||
/// @param[in] callback The callback to set. The previous callback will be
|
||||
/// un-registered.
|
||||
///
|
||||
void SetGLGetFBOCallback(GLGetFBOCallback callback);
|
||||
|
||||
uint32_t GetWindowFBOId() const;
|
||||
|
||||
using GLPresentCallback = std::function<void(uint32_t fbo_id)>;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Sets a callback that will be invoked (on the raster task
|
||||
/// runner) when the engine presents an fbo that was given by the
|
||||
/// embedder.
|
||||
///
|
||||
/// @attention The callback will be invoked on the raster task runner. The
|
||||
/// callback can be set on the tests host thread.
|
||||
///
|
||||
/// @param[in] callback The callback to set. The previous callback will be
|
||||
/// un-registered.
|
||||
///
|
||||
void SetGLPresentCallback(GLPresentCallback callback);
|
||||
|
||||
private:
|
||||
// TODO(gw280): encapsulate these properly for subclasses to use
|
||||
protected:
|
||||
// This allows the builder to access the hooks.
|
||||
friend class EmbedderConfigBuilder;
|
||||
|
||||
@@ -130,15 +97,9 @@ class EmbedderTestContext {
|
||||
SemanticsNodeCallback update_semantics_node_callback_;
|
||||
SemanticsActionCallback update_semantics_custom_action_callback_;
|
||||
std::function<void(const FlutterPlatformMessage*)> platform_message_callback_;
|
||||
std::unique_ptr<TestGLSurface> gl_surface_;
|
||||
std::unique_ptr<EmbedderTestCompositor> compositor_;
|
||||
NextSceneCallback next_scene_callback_;
|
||||
SkMatrix root_surface_transformation_;
|
||||
size_t gl_surface_present_count_ = 0;
|
||||
size_t software_surface_present_count_ = 0;
|
||||
std::mutex gl_callback_mutex_;
|
||||
GLGetFBOCallback gl_get_fbo_callback_;
|
||||
GLPresentCallback gl_present_callback_;
|
||||
|
||||
static VoidCallback GetIsolateCreateCallbackHook();
|
||||
|
||||
@@ -155,37 +116,23 @@ class EmbedderTestContext {
|
||||
|
||||
void SetupAOTDataIfNecessary();
|
||||
|
||||
void SetupCompositor();
|
||||
virtual void SetupCompositor() = 0;
|
||||
|
||||
void FireIsolateCreateCallbacks();
|
||||
|
||||
void SetNativeResolver();
|
||||
|
||||
void SetupOpenGLSurface(SkISize surface_size);
|
||||
|
||||
bool GLMakeCurrent();
|
||||
|
||||
bool GLClearCurrent();
|
||||
|
||||
bool GLPresent(uint32_t fbo_id);
|
||||
|
||||
uint32_t GLGetFramebuffer(FlutterFrameInfo frame_info);
|
||||
|
||||
bool GLMakeResourceCurrent();
|
||||
|
||||
void* GLGetProcAddress(const char* name);
|
||||
|
||||
FlutterTransformation GetRootSurfaceTransformation();
|
||||
|
||||
void PlatformMessageCallback(const FlutterPlatformMessage* message);
|
||||
|
||||
bool SofwarePresent(sk_sp<SkImage> image);
|
||||
|
||||
void FireRootSurfacePresentCallbackIfPresent(
|
||||
const std::function<sk_sp<SkImage>(void)>& image_callback);
|
||||
|
||||
void SetNextSceneCallback(const NextSceneCallback& next_scene_callback);
|
||||
|
||||
virtual void SetupOpenGLSurface(SkISize surface_size) = 0;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestContext);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
// 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 "flutter/shell/platform/embedder/tests/embedder_test_context_gl.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_compositor_gl.h"
|
||||
|
||||
#include "flutter/fml/make_copyable.h"
|
||||
#include "flutter/fml/paths.h"
|
||||
#include "flutter/runtime/dart_vm.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_assertions.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "third_party/dart/runtime/bin/elf_loader.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
EmbedderTestContextGL::EmbedderTestContextGL(std::string assets_path)
|
||||
: EmbedderTestContext(assets_path) {}
|
||||
|
||||
EmbedderTestContextGL::~EmbedderTestContextGL() {
|
||||
SetGLGetFBOCallback(nullptr);
|
||||
}
|
||||
|
||||
void EmbedderTestContextGL::SetupOpenGLSurface(SkISize surface_size) {
|
||||
FML_CHECK(!gl_surface_);
|
||||
gl_surface_ = std::make_unique<TestGLSurface>(surface_size);
|
||||
}
|
||||
|
||||
bool EmbedderTestContextGL::GLMakeCurrent() {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
return gl_surface_->MakeCurrent();
|
||||
}
|
||||
|
||||
bool EmbedderTestContextGL::GLClearCurrent() {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
return gl_surface_->ClearCurrent();
|
||||
}
|
||||
|
||||
bool EmbedderTestContextGL::GLPresent(uint32_t fbo_id) {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
gl_surface_present_count_++;
|
||||
|
||||
GLPresentCallback callback;
|
||||
{
|
||||
std::scoped_lock lock(gl_callback_mutex_);
|
||||
callback = gl_present_callback_;
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback(fbo_id);
|
||||
}
|
||||
|
||||
FireRootSurfacePresentCallbackIfPresent(
|
||||
[&]() { return gl_surface_->GetRasterSurfaceSnapshot(); });
|
||||
|
||||
if (!gl_surface_->Present()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EmbedderTestContextGL::SetGLGetFBOCallback(GLGetFBOCallback callback) {
|
||||
std::scoped_lock lock(gl_callback_mutex_);
|
||||
gl_get_fbo_callback_ = callback;
|
||||
}
|
||||
|
||||
void EmbedderTestContextGL::SetGLPresentCallback(GLPresentCallback callback) {
|
||||
std::scoped_lock lock(gl_callback_mutex_);
|
||||
gl_present_callback_ = callback;
|
||||
}
|
||||
|
||||
uint32_t EmbedderTestContextGL::GLGetFramebuffer(FlutterFrameInfo frame_info) {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
|
||||
GLGetFBOCallback callback;
|
||||
{
|
||||
std::scoped_lock lock(gl_callback_mutex_);
|
||||
callback = gl_get_fbo_callback_;
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback(frame_info);
|
||||
}
|
||||
|
||||
const auto size = frame_info.size;
|
||||
return gl_surface_->GetFramebuffer(size.width, size.height);
|
||||
}
|
||||
|
||||
bool EmbedderTestContextGL::GLMakeResourceCurrent() {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
return gl_surface_->MakeResourceCurrent();
|
||||
}
|
||||
|
||||
void* EmbedderTestContextGL::GLGetProcAddress(const char* name) {
|
||||
FML_CHECK(gl_surface_) << "GL surface must be initialized.";
|
||||
return gl_surface_->GetProcAddress(name);
|
||||
}
|
||||
|
||||
size_t EmbedderTestContextGL::GetSurfacePresentCount() const {
|
||||
return gl_surface_present_count_;
|
||||
}
|
||||
|
||||
uint32_t EmbedderTestContextGL::GetWindowFBOId() const {
|
||||
FML_CHECK(gl_surface_);
|
||||
return gl_surface_->GetWindowFBOId();
|
||||
}
|
||||
|
||||
void EmbedderTestContextGL::SetupCompositor() {
|
||||
FML_CHECK(!compositor_) << "Already ssetup a compositor in this context.";
|
||||
FML_CHECK(gl_surface_)
|
||||
<< "Setup the GL surface before setting up a compositor.";
|
||||
compositor_ = std::make_unique<EmbedderTestCompositorGL>(
|
||||
gl_surface_->GetSurfaceSize(), gl_surface_->GetGrContext());
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -0,0 +1,85 @@
|
||||
// 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_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_GL_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_GL_H_
|
||||
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_context.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class EmbedderTestContextGL : public EmbedderTestContext {
|
||||
public:
|
||||
using GLGetFBOCallback = std::function<void(FlutterFrameInfo frame_info)>;
|
||||
using GLPresentCallback = std::function<void(uint32_t fbo_id)>;
|
||||
|
||||
EmbedderTestContextGL(std::string assets_path = "");
|
||||
|
||||
~EmbedderTestContextGL() override;
|
||||
|
||||
size_t GetSurfacePresentCount() const override;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Sets a callback that will be invoked (on the raster task
|
||||
/// runner) when the engine asks the embedder for a new FBO ID at
|
||||
/// the updated size.
|
||||
///
|
||||
/// @attention The callback will be invoked on the raster task runner. The
|
||||
/// callback can be set on the tests host thread.
|
||||
///
|
||||
/// @param[in] callback The callback to set. The previous callback will be
|
||||
/// un-registered.
|
||||
///
|
||||
void SetGLGetFBOCallback(GLGetFBOCallback callback);
|
||||
|
||||
uint32_t GetWindowFBOId() const;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Sets a callback that will be invoked (on the raster task
|
||||
/// runner) when the engine presents an fbo that was given by the
|
||||
/// embedder.
|
||||
///
|
||||
/// @attention The callback will be invoked on the raster task runner. The
|
||||
/// callback can be set on the tests host thread.
|
||||
///
|
||||
/// @param[in] callback The callback to set. The previous callback will be
|
||||
/// un-registered.
|
||||
///
|
||||
void SetGLPresentCallback(GLPresentCallback callback);
|
||||
|
||||
protected:
|
||||
virtual void SetupCompositor() override;
|
||||
|
||||
private:
|
||||
// This allows the builder to access the hooks.
|
||||
friend class EmbedderConfigBuilder;
|
||||
|
||||
std::unique_ptr<TestGLSurface> gl_surface_;
|
||||
size_t gl_surface_present_count_ = 0;
|
||||
std::mutex gl_callback_mutex_;
|
||||
GLGetFBOCallback gl_get_fbo_callback_;
|
||||
GLPresentCallback gl_present_callback_;
|
||||
|
||||
void SetupOpenGLSurface(SkISize surface_size) override;
|
||||
|
||||
bool GLMakeCurrent();
|
||||
|
||||
bool GLClearCurrent();
|
||||
|
||||
bool GLPresent(uint32_t fbo_id);
|
||||
|
||||
uint32_t GLGetFramebuffer(FlutterFrameInfo frame_info);
|
||||
|
||||
bool GLMakeResourceCurrent();
|
||||
|
||||
void* GLGetProcAddress(const char* name);
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestContextGL);
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_GL_H_
|
||||
@@ -0,0 +1,51 @@
|
||||
// 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 "flutter/shell/platform/embedder/tests/embedder_test_context_software.h"
|
||||
|
||||
#include "flutter/fml/make_copyable.h"
|
||||
#include "flutter/fml/paths.h"
|
||||
#include "flutter/runtime/dart_vm.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_assertions.h"
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_compositor_software.h"
|
||||
#include "flutter/testing/testing.h"
|
||||
#include "third_party/dart/runtime/bin/elf_loader.h"
|
||||
#include "third_party/skia/include/core/SkSurface.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
EmbedderTestContextSoftware::EmbedderTestContextSoftware(
|
||||
std::string assets_path)
|
||||
: EmbedderTestContext(assets_path) {}
|
||||
|
||||
EmbedderTestContextSoftware::~EmbedderTestContextSoftware() = default;
|
||||
|
||||
bool EmbedderTestContextSoftware::Present(sk_sp<SkImage> image) {
|
||||
software_surface_present_count_++;
|
||||
|
||||
FireRootSurfacePresentCallbackIfPresent([image] { return image; });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t EmbedderTestContextSoftware::GetSurfacePresentCount() const {
|
||||
return software_surface_present_count_;
|
||||
}
|
||||
|
||||
void EmbedderTestContextSoftware::SetupOpenGLSurface(SkISize surface_size) {
|
||||
FML_CHECK(!gl_surface_);
|
||||
gl_surface_ = std::make_unique<TestGLSurface>(surface_size);
|
||||
}
|
||||
|
||||
void EmbedderTestContextSoftware::SetupCompositor() {
|
||||
FML_CHECK(!compositor_) << "Already ssetup a compositor in this context.";
|
||||
FML_CHECK(gl_surface_)
|
||||
<< "Setup the GL surface before setting up a compositor.";
|
||||
compositor_ = std::make_unique<EmbedderTestCompositorSoftware>(
|
||||
gl_surface_->GetSurfaceSize(), gl_surface_->GetGrContext());
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
@@ -0,0 +1,37 @@
|
||||
// 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_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_SOFTWARE_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_SOFTWARE_H_
|
||||
|
||||
#include "flutter/shell/platform/embedder/tests/embedder_test_context.h"
|
||||
|
||||
namespace flutter {
|
||||
namespace testing {
|
||||
|
||||
class EmbedderTestContextSoftware : public EmbedderTestContext {
|
||||
public:
|
||||
EmbedderTestContextSoftware(std::string assets_path = "");
|
||||
|
||||
~EmbedderTestContextSoftware() override;
|
||||
|
||||
size_t GetSurfacePresentCount() const override;
|
||||
|
||||
bool Present(sk_sp<SkImage> image);
|
||||
|
||||
protected:
|
||||
virtual void SetupCompositor() override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<TestGLSurface> gl_surface_;
|
||||
size_t software_surface_present_count_ = 0;
|
||||
void SetupOpenGLSurface(SkISize surface_size) override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderTestContextSoftware);
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace flutter
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_TESTS_EMBEDDER_CONTEXT_SOFTWARE_H_
|
||||
@@ -34,7 +34,7 @@ namespace testing {
|
||||
using EmbedderTest = testing::EmbedderTest;
|
||||
|
||||
TEST(EmbedderTestNoFixture, MustNotRunWithInvalidArgs) {
|
||||
EmbedderTestContext context;
|
||||
EmbedderTestContextSoftware context;
|
||||
EmbedderConfigBuilder builder(
|
||||
context, EmbedderConfigBuilder::InitializationPreference::kNoInitialize);
|
||||
auto engine = builder.LaunchEngine();
|
||||
@@ -42,7 +42,7 @@ TEST(EmbedderTestNoFixture, MustNotRunWithInvalidArgs) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanLaunchAndShutdownWithValidProjectArgs) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
context.AddIsolateCreateCallback([&latch]() { latch.Signal(); });
|
||||
EmbedderConfigBuilder builder(context);
|
||||
@@ -56,7 +56,8 @@ TEST_F(EmbedderTest, CanLaunchAndShutdownWithValidProjectArgs) {
|
||||
|
||||
// TODO(41999): Disabled because flaky.
|
||||
TEST_F(EmbedderTest, DISABLED_CanLaunchAndShutdownMultipleTimes) {
|
||||
EmbedderConfigBuilder builder(GetEmbedderContext());
|
||||
EmbedderConfigBuilder builder(
|
||||
GetEmbedderContext(ContextType::kSoftwareContext));
|
||||
builder.SetSoftwareRendererConfig();
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
auto engine = builder.LaunchEngine();
|
||||
@@ -66,7 +67,7 @@ TEST_F(EmbedderTest, DISABLED_CanLaunchAndShutdownMultipleTimes) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanInvokeCustomEntrypoint) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
static fml::AutoResetWaitableEvent latch;
|
||||
Dart_NativeFunction entrypoint = [](Dart_NativeArguments args) {
|
||||
latch.Signal();
|
||||
@@ -81,7 +82,7 @@ TEST_F(EmbedderTest, CanInvokeCustomEntrypoint) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanInvokeCustomEntrypointMacro) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
|
||||
fml::AutoResetWaitableEvent latch1;
|
||||
fml::AutoResetWaitableEvent latch2;
|
||||
@@ -176,7 +177,7 @@ class EmbedderTestTaskRunner {
|
||||
std::atomic_size_t EmbedderTestTaskRunner::sEmbedderTaskRunnerIdentifiers = {};
|
||||
|
||||
TEST_F(EmbedderTest, CanSpecifyCustomPlatformTaskRunner) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
|
||||
// Run the test on its own thread with a message loop so that it can safely
|
||||
@@ -248,7 +249,7 @@ TEST(EmbedderTestNoFixture, CanGetCurrentTimeInNanoseconds) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanReloadSystemFonts) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
auto engine = builder.LaunchEngine();
|
||||
@@ -259,14 +260,15 @@ TEST_F(EmbedderTest, CanReloadSystemFonts) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanCreateOpenGLRenderingEngine) {
|
||||
EmbedderConfigBuilder builder(GetEmbedderContext());
|
||||
EmbedderConfigBuilder builder(
|
||||
GetEmbedderContext(ContextType::kOpenGLContext));
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(1, 1));
|
||||
auto engine = builder.LaunchEngine();
|
||||
ASSERT_TRUE(engine.is_valid());
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, IsolateServiceIdSent) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
|
||||
fml::Thread thread;
|
||||
@@ -309,7 +311,7 @@ TEST_F(EmbedderTest, IsolateServiceIdSent) {
|
||||
/// immediately collects the same.
|
||||
///
|
||||
TEST_F(EmbedderTest, CanCreateAndCollectCallbacks) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
builder.SetDartEntrypoint("platform_messages_response");
|
||||
@@ -347,7 +349,7 @@ TEST_F(EmbedderTest, PlatformMessagesCanReceiveResponse) {
|
||||
|
||||
CreateNewThread()->PostTask([&]() {
|
||||
captures.thread_id = std::this_thread::get_id();
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
builder.SetDartEntrypoint("platform_messages_response");
|
||||
@@ -403,7 +405,7 @@ TEST_F(EmbedderTest, PlatformMessagesCanReceiveResponse) {
|
||||
/// callback with the response is invoked to assert integrity.
|
||||
///
|
||||
TEST_F(EmbedderTest, PlatformMessagesCanBeSentWithoutResponseHandles) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
builder.SetDartEntrypoint("platform_messages_no_response");
|
||||
@@ -448,7 +450,7 @@ TEST_F(EmbedderTest, PlatformMessagesCanBeSentWithoutResponseHandles) {
|
||||
/// Tests that a null platform message can be sent.
|
||||
///
|
||||
TEST_F(EmbedderTest, NullPlatformMessagesCanBeSent) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
builder.SetDartEntrypoint("null_platform_messages");
|
||||
@@ -490,7 +492,7 @@ TEST_F(EmbedderTest, NullPlatformMessagesCanBeSent) {
|
||||
/// isn't equals to 0.
|
||||
///
|
||||
TEST_F(EmbedderTest, InvalidPlatformMessages) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
auto engine = builder.LaunchEngine();
|
||||
@@ -514,7 +516,7 @@ TEST_F(EmbedderTest, InvalidPlatformMessages) {
|
||||
/// set to true by default in these unit-tests).
|
||||
///
|
||||
TEST_F(EmbedderTest, VMShutsDownWhenNoEnginesInProcess) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
const auto launch_count = DartVM::GetVMLaunchCount();
|
||||
@@ -540,7 +542,7 @@ TEST_F(EmbedderTest, VMAndIsolateSnapshotSizesAreRedundantInAOTMode) {
|
||||
GTEST_SKIP();
|
||||
return;
|
||||
}
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
|
||||
@@ -561,7 +563,7 @@ TEST_F(EmbedderTest, VMAndIsolateSnapshotSizesAreRedundantInAOTMode) {
|
||||
///
|
||||
TEST_F(EmbedderTest,
|
||||
MustPreventEngineLaunchWhenRequiredCompositorArgsAreAbsent) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(1, 1));
|
||||
builder.SetCompositor();
|
||||
@@ -577,15 +579,15 @@ TEST_F(EmbedderTest,
|
||||
/// complete OpenGL textures.
|
||||
///
|
||||
TEST_F(EmbedderTest, CompositorMustBeAbleToRenderToOpenGLFramebuffer) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_composite_platform_views");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLFramebuffer);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
fml::CountDownLatch latch(3);
|
||||
context.GetCompositor().SetNextPresentCallback(
|
||||
@@ -668,15 +670,15 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderToOpenGLFramebuffer) {
|
||||
/// Layers in a hierarchy containing a platform view should not be cached. The
|
||||
/// other layers in the hierarchy should be, however.
|
||||
TEST_F(EmbedderTest, RasterCacheDisabledWithPlatformViews) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_composite_platform_views_with_opacity");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLFramebuffer);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
fml::CountDownLatch setup(3);
|
||||
fml::CountDownLatch verify(1);
|
||||
@@ -772,15 +774,15 @@ TEST_F(EmbedderTest, RasterCacheDisabledWithPlatformViews) {
|
||||
/// The RasterCache should normally be enabled.
|
||||
///
|
||||
TEST_F(EmbedderTest, RasterCacheEnabled) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_composite_with_opacity");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLFramebuffer);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
fml::CountDownLatch setup(3);
|
||||
fml::CountDownLatch verify(1);
|
||||
@@ -843,15 +845,15 @@ TEST_F(EmbedderTest, RasterCacheEnabled) {
|
||||
/// the individual layers are OpenGL textures.
|
||||
///
|
||||
TEST_F(EmbedderTest, CompositorMustBeAbleToRenderToOpenGLTexture) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_composite_platform_views");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(3);
|
||||
context.GetCompositor().SetNextPresentCallback(
|
||||
@@ -935,15 +937,15 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderToOpenGLTexture) {
|
||||
/// individual layers are software buffers.
|
||||
///
|
||||
TEST_F(EmbedderTest, CompositorMustBeAbleToRenderToSoftwareBuffer) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_composite_platform_views");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kSoftwareBuffer);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
|
||||
|
||||
fml::CountDownLatch latch(3);
|
||||
context.GetCompositor().SetNextPresentCallback(
|
||||
@@ -1155,15 +1157,15 @@ static bool ImageMatchesFixture(const std::string& fixture_file_name,
|
||||
/// Test the layer structure and pixels rendered when using a custom compositor.
|
||||
///
|
||||
TEST_F(EmbedderTest, CompositorMustBeAbleToRenderKnownScene) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_composite_platform_views_with_known_scene");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(5);
|
||||
|
||||
@@ -1318,8 +1320,7 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderKnownScene) {
|
||||
ASSERT_TRUE(ImageMatchesFixture("compositor.png", scene_image));
|
||||
|
||||
// There should no present calls on the root surface.
|
||||
ASSERT_EQ(context.GetSoftwareSurfacePresentCount(), 0u);
|
||||
ASSERT_EQ(context.GetGLSurfacePresentCount(), 0u);
|
||||
ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1328,15 +1329,15 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderKnownScene) {
|
||||
///
|
||||
TEST_F(EmbedderTest,
|
||||
CompositorMustBeAbleToRenderKnownSceneWithSoftwareCompositor) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_composite_platform_views_with_known_scene");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kSoftwareBuffer);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
|
||||
|
||||
fml::CountDownLatch latch(5);
|
||||
|
||||
@@ -1492,8 +1493,7 @@ TEST_F(EmbedderTest,
|
||||
ASSERT_TRUE(ImageMatchesFixture("compositor_software.png", scene_image));
|
||||
|
||||
// There should no present calls on the root surface.
|
||||
ASSERT_EQ(context.GetSoftwareSurfacePresentCount(), 0u);
|
||||
ASSERT_EQ(context.GetGLSurfacePresentCount(), 0u);
|
||||
ASSERT_EQ(context.GetSurfacePresentCount(), 0u);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1501,7 +1501,7 @@ TEST_F(EmbedderTest,
|
||||
/// thread merging mechanism must not interfere with the custom compositor.
|
||||
///
|
||||
TEST_F(EmbedderTest, CustomCompositorMustWorkWithCustomTaskRunner) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
|
||||
@@ -1523,8 +1523,8 @@ TEST_F(EmbedderTest, CustomCompositorMustWorkWithCustomTaskRunner) {
|
||||
ASSERT_EQ(FlutterEngineRunTask(engine.get(), &task), kSuccess);
|
||||
});
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(3);
|
||||
context.GetCompositor().SetNextPresentCallback(
|
||||
@@ -1626,7 +1626,7 @@ TEST_F(EmbedderTest, CustomCompositorMustWorkWithCustomTaskRunner) {
|
||||
/// and a single layer.
|
||||
///
|
||||
TEST_F(EmbedderTest, CompositorMustBeAbleToRenderWithRootLayerOnly) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
@@ -1634,8 +1634,8 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderWithRootLayerOnly) {
|
||||
builder.SetDartEntrypoint(
|
||||
"can_composite_platform_views_with_root_layer_only");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(3);
|
||||
|
||||
@@ -1693,7 +1693,7 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderWithRootLayerOnly) {
|
||||
/// and ensure that a redundant layer is not added.
|
||||
///
|
||||
TEST_F(EmbedderTest, CompositorMustBeAbleToRenderWithPlatformLayerOnBottom) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
@@ -1701,8 +1701,8 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderWithPlatformLayerOnBottom) {
|
||||
builder.SetDartEntrypoint(
|
||||
"can_composite_platform_views_with_platform_layer_on_bottom");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(3);
|
||||
|
||||
@@ -1806,15 +1806,15 @@ TEST_F(EmbedderTest, CompositorMustBeAbleToRenderWithPlatformLayerOnBottom) {
|
||||
///
|
||||
TEST_F(EmbedderTest,
|
||||
CompositorMustBeAbleToRenderKnownSceneWithRootSurfaceTransformation) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 800));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_composite_platform_views_with_known_scene");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
// This must match the transformation provided in the
|
||||
// |CanRenderGradientWithoutCompositorWithXform| test to ensure that
|
||||
@@ -1980,7 +1980,7 @@ TEST_F(EmbedderTest,
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanRenderSceneWithoutCustomCompositor) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
|
||||
@@ -2006,7 +2006,7 @@ TEST_F(EmbedderTest, CanRenderSceneWithoutCustomCompositor) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanRenderSceneWithoutCustomCompositorWithTransformation) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
const auto root_surface_transformation =
|
||||
SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
|
||||
@@ -2039,7 +2039,7 @@ TEST_F(EmbedderTest, CanRenderSceneWithoutCustomCompositorWithTransformation) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanRenderGradientWithoutCompositor) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
|
||||
@@ -2064,7 +2064,7 @@ TEST_F(EmbedderTest, CanRenderGradientWithoutCompositor) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanRenderGradientWithoutCompositorWithXform) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
const auto root_surface_transformation =
|
||||
SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
|
||||
@@ -2097,13 +2097,15 @@ TEST_F(EmbedderTest, CanRenderGradientWithoutCompositorWithXform) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanRenderGradientWithCompositor) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
|
||||
builder.SetDartEntrypoint("render_gradient");
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
auto renderered_scene = context.GetNextSceneImage();
|
||||
|
||||
@@ -2123,7 +2125,7 @@ TEST_F(EmbedderTest, CanRenderGradientWithCompositor) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanRenderGradientWithCompositorWithXform) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
// This must match the transformation provided in the
|
||||
// |CanRenderGradientWithoutCompositorWithXform| test to ensure that
|
||||
@@ -2138,6 +2140,8 @@ TEST_F(EmbedderTest, CanRenderGradientWithCompositorWithXform) {
|
||||
builder.SetDartEntrypoint("render_gradient");
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 800));
|
||||
builder.SetCompositor();
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
auto renderered_scene = context.GetNextSceneImage();
|
||||
|
||||
@@ -2158,13 +2162,15 @@ TEST_F(EmbedderTest, CanRenderGradientWithCompositorWithXform) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanRenderGradientWithCompositorOnNonRootLayer) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
|
||||
builder.SetDartEntrypoint("render_gradient_on_non_root_backing_store");
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
context.GetCompositor().SetNextPresentCallback(
|
||||
[&](const FlutterLayer** layers, size_t layers_count) {
|
||||
@@ -2261,7 +2267,7 @@ TEST_F(EmbedderTest, CanRenderGradientWithCompositorOnNonRootLayer) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanRenderGradientWithCompositorOnNonRootLayerWithXform) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
// This must match the transformation provided in the
|
||||
// |CanRenderGradientWithoutCompositorWithXform| test to ensure that
|
||||
@@ -2276,6 +2282,8 @@ TEST_F(EmbedderTest, CanRenderGradientWithCompositorOnNonRootLayerWithXform) {
|
||||
builder.SetDartEntrypoint("render_gradient_on_non_root_backing_store");
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 800));
|
||||
builder.SetCompositor();
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
context.GetCompositor().SetNextPresentCallback(
|
||||
[&](const FlutterLayer** layers, size_t layers_count) {
|
||||
@@ -2373,7 +2381,7 @@ TEST_F(EmbedderTest, CanRenderGradientWithCompositorOnNonRootLayerWithXform) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, VerifyB141980393) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
|
||||
@@ -2397,6 +2405,8 @@ TEST_F(EmbedderTest, VerifyB141980393) {
|
||||
|
||||
// Use a compositor instead of rendering directly to the surface.
|
||||
builder.SetCompositor();
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
builder.SetDartEntrypoint("verify_b141980393");
|
||||
|
||||
@@ -2478,7 +2488,8 @@ TEST_F(EmbedderTest, VerifyB141980393) {
|
||||
/// Test that an engine can be initialized but not run.
|
||||
///
|
||||
TEST_F(EmbedderTest, CanCreateInitializedEngine) {
|
||||
EmbedderConfigBuilder builder(GetEmbedderContext());
|
||||
EmbedderConfigBuilder builder(
|
||||
GetEmbedderContext(ContextType::kSoftwareContext));
|
||||
builder.SetSoftwareRendererConfig();
|
||||
auto engine = builder.InitializeEngine();
|
||||
ASSERT_TRUE(engine.is_valid());
|
||||
@@ -2489,7 +2500,8 @@ TEST_F(EmbedderTest, CanCreateInitializedEngine) {
|
||||
/// Test that an initialized engine can be run exactly once.
|
||||
///
|
||||
TEST_F(EmbedderTest, CanRunInitializedEngine) {
|
||||
EmbedderConfigBuilder builder(GetEmbedderContext());
|
||||
EmbedderConfigBuilder builder(
|
||||
GetEmbedderContext(ContextType::kSoftwareContext));
|
||||
builder.SetSoftwareRendererConfig();
|
||||
auto engine = builder.InitializeEngine();
|
||||
ASSERT_TRUE(engine.is_valid());
|
||||
@@ -2503,7 +2515,8 @@ TEST_F(EmbedderTest, CanRunInitializedEngine) {
|
||||
/// Test that an engine can be deinitialized.
|
||||
///
|
||||
TEST_F(EmbedderTest, CaDeinitializeAnEngine) {
|
||||
EmbedderConfigBuilder builder(GetEmbedderContext());
|
||||
EmbedderConfigBuilder builder(
|
||||
GetEmbedderContext(ContextType::kSoftwareContext));
|
||||
builder.SetSoftwareRendererConfig();
|
||||
auto engine = builder.InitializeEngine();
|
||||
ASSERT_TRUE(engine.is_valid());
|
||||
@@ -2542,7 +2555,8 @@ TEST_F(EmbedderTest, CanCreateEmbedderWithCustomRenderTaskRunner) {
|
||||
task_latch.Signal();
|
||||
}
|
||||
});
|
||||
EmbedderConfigBuilder builder(GetEmbedderContext());
|
||||
EmbedderConfigBuilder builder(
|
||||
GetEmbedderContext(ContextType::kOpenGLContext));
|
||||
builder.SetDartEntrypoint("can_render_scene_without_custom_compositor");
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetRenderTaskRunner(
|
||||
@@ -2600,7 +2614,8 @@ TEST_F(EmbedderTest,
|
||||
});
|
||||
|
||||
platform_task_runner->PostTask([&]() {
|
||||
EmbedderConfigBuilder builder(GetEmbedderContext());
|
||||
EmbedderConfigBuilder builder(
|
||||
GetEmbedderContext(ContextType::kOpenGLContext));
|
||||
builder.SetDartEntrypoint("can_render_scene_without_custom_compositor");
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetRenderTaskRunner(
|
||||
@@ -2654,15 +2669,15 @@ TEST_F(EmbedderTest,
|
||||
|
||||
TEST_F(EmbedderTest,
|
||||
CompositorMustBeAbleToRenderKnownScenePixelRatioOnSurface) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_display_platform_view_with_pixel_ratio");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(1);
|
||||
|
||||
@@ -2745,15 +2760,15 @@ TEST_F(EmbedderTest,
|
||||
TEST_F(
|
||||
EmbedderTest,
|
||||
CompositorMustBeAbleToRenderKnownScenePixelRatioOnSurfaceWithRootSurfaceXformation) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 800));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("can_display_platform_view_with_pixel_ratio");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
const auto root_surface_transformation =
|
||||
SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
|
||||
@@ -2838,7 +2853,7 @@ TEST_F(
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanUpdateLocales) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
builder.SetDartEntrypoint("can_receive_locale_updates");
|
||||
@@ -2897,7 +2912,7 @@ TEST_F(EmbedderTest, CanUpdateLocales) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, LocalizationCallbacksCalled) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
context.AddIsolateCreateCallback([&latch]() { latch.Signal(); });
|
||||
EmbedderConfigBuilder builder(context);
|
||||
@@ -2929,15 +2944,15 @@ TEST_F(EmbedderTest, CanQueryDartAOTMode) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, VerifyB143464703WithSoftwareBackend) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig(SkISize::Make(1024, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("verify_b143464703");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kSoftwareBuffer);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kSoftwareBuffer);
|
||||
|
||||
fml::CountDownLatch latch(1);
|
||||
context.GetCompositor().SetNextPresentCallback(
|
||||
@@ -3049,15 +3064,15 @@ TEST_F(EmbedderTest, VerifyB143464703WithSoftwareBackend) {
|
||||
|
||||
TEST_F(EmbedderTest,
|
||||
PushingMutlipleFramesSetsUpNewRecordingCanvasWithCustomCompositor) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("push_frames_over_and_over");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
const auto root_surface_transformation =
|
||||
SkMatrix().preTranslate(0, 1024).preRotate(-90, 0, 0);
|
||||
@@ -3091,7 +3106,7 @@ TEST_F(EmbedderTest,
|
||||
|
||||
TEST_F(EmbedderTest,
|
||||
PushingMutlipleFramesSetsUpNewRecordingCanvasWithoutCustomCompositor) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
|
||||
@@ -3128,15 +3143,15 @@ TEST_F(EmbedderTest,
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, PlatformViewMutatorsAreValid) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("platform_view_mutators");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(1);
|
||||
context.GetCompositor().SetNextPresentCallback(
|
||||
@@ -3224,15 +3239,15 @@ TEST_F(EmbedderTest, PlatformViewMutatorsAreValid) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, PlatformViewMutatorsAreValidWithPixelRatio) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("platform_view_mutators_with_pixel_ratio");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(1);
|
||||
context.GetCompositor().SetNextPresentCallback(
|
||||
@@ -3321,15 +3336,15 @@ TEST_F(EmbedderTest, PlatformViewMutatorsAreValidWithPixelRatio) {
|
||||
|
||||
TEST_F(EmbedderTest,
|
||||
PlatformViewMutatorsAreValidWithPixelRatioAndRootSurfaceTransformation) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("platform_view_mutators_with_pixel_ratio");
|
||||
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
static const auto root_surface_transformation =
|
||||
SkMatrix().preTranslate(0, 800).preRotate(-90, 0, 0);
|
||||
@@ -3423,7 +3438,7 @@ TEST_F(EmbedderTest,
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, EmptySceneIsAcceptable) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
@@ -3449,11 +3464,13 @@ TEST_F(EmbedderTest, EmptySceneIsAcceptable) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, SceneWithNoRootContainerIsAcceptable) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
builder.SetDartEntrypoint("scene_with_no_container");
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
context.AddNativeCallback(
|
||||
@@ -3477,12 +3494,14 @@ TEST_F(EmbedderTest, SceneWithNoRootContainerIsAcceptable) {
|
||||
// Verifies that https://skia-review.googlesource.com/c/skia/+/259174 is pulled
|
||||
// into the engine.
|
||||
TEST_F(EmbedderTest, ArcEndCapsAreDrawnCorrectly) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 1024));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("arc_end_caps_correct");
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
const auto root_surface_transformation = SkMatrix()
|
||||
.preScale(1.0, -1.0)
|
||||
@@ -3556,12 +3575,14 @@ static SkMatrix GetTotalMutationTransformationMatrix(
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, ClipsAreCorrectlyCalculated) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(400, 300));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("scene_builder_with_clips");
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
const auto root_surface_transformation =
|
||||
SkMatrix().preTranslate(0, 400).preRotate(-90, 0, 0);
|
||||
@@ -3633,12 +3654,14 @@ TEST_F(EmbedderTest, ClipsAreCorrectlyCalculated) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, ComplexClipsAreCorrectlyCalculated) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(1024, 600));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("scene_builder_with_complex_clips");
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLFramebuffer);
|
||||
|
||||
const auto root_surface_transformation =
|
||||
SkMatrix().preTranslate(0, 1024).preRotate(-90, 0, 0);
|
||||
@@ -3715,7 +3738,7 @@ TEST_F(EmbedderTest, ComplexClipsAreCorrectlyCalculated) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, ObjectsCanBePostedViaPorts) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(800, 1024));
|
||||
builder.SetDartEntrypoint("objects_can_be_posted");
|
||||
@@ -3914,7 +3937,7 @@ TEST_F(EmbedderTest, ObjectsCanBePostedViaPorts) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CanSendLowMemoryNotification) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
@@ -3943,7 +3966,7 @@ TEST_F(EmbedderTest, CanPostTaskToAllNativeThreads) {
|
||||
auto platform_task_runner = CreateNewThread("platform_thread");
|
||||
|
||||
platform_task_runner->PostTask([&]() {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetSoftwareRendererConfig();
|
||||
@@ -4034,14 +4057,14 @@ TEST_F(EmbedderTest, CanPostTaskToAllNativeThreads) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CompositorCanPostZeroLayersForPresentation) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(300, 200));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("empty_scene_posts_zero_layers_to_compositor");
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
|
||||
@@ -4067,14 +4090,14 @@ TEST_F(EmbedderTest, CompositorCanPostZeroLayersForPresentation) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CompositorCanPostOnlyPlatformViews) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(300, 200));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("compositor_can_post_only_platform_views");
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
|
||||
@@ -4130,14 +4153,14 @@ TEST_F(EmbedderTest, CompositorCanPostOnlyPlatformViews) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CompositorRenderTargetsAreRecycled) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(300, 200));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("render_targets_are_recycled");
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(2);
|
||||
|
||||
@@ -4175,14 +4198,14 @@ TEST_F(EmbedderTest, CompositorRenderTargetsAreRecycled) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, CompositorRenderTargetsAreInStableOrder) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(300, 200));
|
||||
builder.SetCompositor();
|
||||
builder.SetDartEntrypoint("render_targets_are_recycled");
|
||||
context.GetCompositor().SetRenderTargetType(
|
||||
EmbedderTestCompositor::RenderTargetType::kOpenGLTexture);
|
||||
builder.SetRenderTargetType(
|
||||
EmbedderTestBackingStoreProducer::RenderTargetType::kOpenGLTexture);
|
||||
|
||||
fml::CountDownLatch latch(2);
|
||||
|
||||
@@ -4291,7 +4314,7 @@ TEST_F(EmbedderTest, MustNotRunWithMultipleAOTSources) {
|
||||
GTEST_SKIP();
|
||||
return;
|
||||
}
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
|
||||
EmbedderConfigBuilder builder(
|
||||
context,
|
||||
@@ -4333,7 +4356,7 @@ TEST_F(EmbedderTest, CanLaunchAndShutdownWithAValidElfSource) {
|
||||
GTEST_SKIP();
|
||||
return;
|
||||
}
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kSoftwareContext);
|
||||
|
||||
fml::AutoResetWaitableEvent latch;
|
||||
context.AddIsolateCreateCallback([&latch]() { latch.Signal(); });
|
||||
@@ -4353,7 +4376,7 @@ TEST_F(EmbedderTest, CanLaunchAndShutdownWithAValidElfSource) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, FrameInfoContainsValidWidthAndHeight) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
|
||||
@@ -4383,7 +4406,7 @@ TEST_F(EmbedderTest, FrameInfoContainsValidWidthAndHeight) {
|
||||
/* Nothing to do. */
|
||||
}));
|
||||
|
||||
context.SetGLGetFBOCallback(
|
||||
static_cast<EmbedderTestContextGL&>(context).SetGLGetFBOCallback(
|
||||
[&event, &frame_latch](FlutterFrameInfo frame_info) {
|
||||
// width and height are rotated by 90 deg
|
||||
ASSERT_EQ(frame_info.size.width, event.height);
|
||||
@@ -4396,7 +4419,7 @@ TEST_F(EmbedderTest, FrameInfoContainsValidWidthAndHeight) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, MustNotRunWithBothFBOCallbacksSet) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
|
||||
@@ -4407,7 +4430,7 @@ TEST_F(EmbedderTest, MustNotRunWithBothFBOCallbacksSet) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, MustNotRunWithBothPresentCallbacksSet) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
|
||||
@@ -4418,7 +4441,7 @@ TEST_F(EmbedderTest, MustNotRunWithBothPresentCallbacksSet) {
|
||||
}
|
||||
|
||||
TEST_F(EmbedderTest, PresentInfoContainsValidFBOId) {
|
||||
auto& context = GetEmbedderContext();
|
||||
auto& context = GetEmbedderContext(ContextType::kOpenGLContext);
|
||||
|
||||
EmbedderConfigBuilder builder(context);
|
||||
builder.SetOpenGLRendererConfig(SkISize::Make(600, 1024));
|
||||
@@ -4448,8 +4471,9 @@ TEST_F(EmbedderTest, PresentInfoContainsValidFBOId) {
|
||||
/* Nothing to do. */
|
||||
}));
|
||||
|
||||
const uint32_t window_fbo_id = context.GetWindowFBOId();
|
||||
context.SetGLPresentCallback(
|
||||
const uint32_t window_fbo_id =
|
||||
static_cast<EmbedderTestContextGL&>(context).GetWindowFBOId();
|
||||
static_cast<EmbedderTestContextGL&>(context).SetGLPresentCallback(
|
||||
[window_fbo_id = window_fbo_id, &frame_latch](uint32_t fbo_id) {
|
||||
ASSERT_EQ(fbo_id, window_fbo_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user