mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
With the update to HEAD of the Fuchsia buildtools repo, the new clang toolchain picked up caused link-time breakage in android x86_64 libFlutter.so builds. Sample log: https://build.chromium.org/p/client.flutter/builders/Linux%20Engine/builds/1974/steps/build%20android_debug_x64/logs/stdio Sample failure: FAILED: libflutter.so libflutter.so.TOC lib.stripped/libflutter.so ../../third_party/android_tools/ndk/toolchains/x86_64-4.9/prebuilt/linux-x86_64/lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld.gold: error: obj/flutter/shell/platform/android/libflutter/android_context_gl.o: unsupported reloc 42 against global symbol std::__ndk1::num_put<char, std::__ndk1::ostreambuf_iterator<char, std::__ndk1::char_traits<char> > >::id This reverts commit fecc7aa281821e01037089846744b5331e3cbd22.
76 lines
2.1 KiB
C++
76 lines
2.1 KiB
C++
// Copyright 2017 The Chromium 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/gpu/gpu_surface_software.h"
|
|
|
|
#include <memory>
|
|
#include "lib/fxl/logging.h"
|
|
|
|
namespace shell {
|
|
|
|
GPUSurfaceSoftware::GPUSurfaceSoftware(GPUSurfaceSoftwareDelegate* delegate)
|
|
: delegate_(delegate), weak_factory_(this) {}
|
|
|
|
GPUSurfaceSoftware::~GPUSurfaceSoftware() = default;
|
|
|
|
bool GPUSurfaceSoftware::IsValid() {
|
|
return delegate_ != nullptr;
|
|
}
|
|
|
|
bool GPUSurfaceSoftware::SupportsScaling() const {
|
|
return true;
|
|
}
|
|
|
|
std::unique_ptr<SurfaceFrame> GPUSurfaceSoftware::AcquireFrame(
|
|
const SkISize& logical_size) {
|
|
if (!IsValid()) {
|
|
return nullptr;
|
|
}
|
|
|
|
// Check if we need to support surface scaling.
|
|
const auto scale = SupportsScaling() ? GetScale() : 1.0;
|
|
const auto size = SkISize::Make(logical_size.width() * scale,
|
|
logical_size.height() * scale);
|
|
|
|
sk_sp<SkSurface> backing_store = delegate_->AcquireBackingStore(size);
|
|
|
|
if (backing_store == nullptr) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (size != SkISize::Make(backing_store->width(), backing_store->height())) {
|
|
return nullptr;
|
|
}
|
|
|
|
// If the surface has been scaled, we need to apply the inverse scaling to the
|
|
// underlying canvas so that coordinates are mapped to the same spot
|
|
// irrespective of surface scaling.
|
|
SkCanvas* canvas = backing_store->getCanvas();
|
|
canvas->resetMatrix();
|
|
canvas->scale(scale, scale);
|
|
|
|
SurfaceFrame::SubmitCallback
|
|
on_submit = [self = weak_factory_.GetWeakPtr()](
|
|
const SurfaceFrame& surface_frame, SkCanvas* canvas)
|
|
->bool {
|
|
// If the surface itself went away, there is nothing more to do.
|
|
if (!self || !self->IsValid() || canvas == nullptr) {
|
|
return false;
|
|
}
|
|
|
|
canvas->flush();
|
|
|
|
return self->delegate_->PresentBackingStore(surface_frame.SkiaSurface());
|
|
};
|
|
|
|
return std::make_unique<SurfaceFrame>(backing_store, on_submit);
|
|
}
|
|
|
|
GrContext* GPUSurfaceSoftware::GetContext() {
|
|
// The is no GrContext associated with a software surface.
|
|
return nullptr;
|
|
}
|
|
|
|
} // namespace shell
|