mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This is part of a larger effort to expose the difference between GrDirectContext, which runs on the GPU thread and can directly perform operations like uploading textures, and GrRecordingContext, which can only queue up work to be delivered to the GrDirectContext later.
58 lines
1.8 KiB
C++
58 lines
1.8 KiB
C++
// 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/embedder_external_texture_gl.h"
|
|
|
|
#include "flutter/fml/logging.h"
|
|
|
|
namespace flutter {
|
|
|
|
EmbedderExternalTextureGL::EmbedderExternalTextureGL(
|
|
int64_t texture_identifier,
|
|
const ExternalTextureCallback& callback)
|
|
: Texture(texture_identifier), external_texture_callback_(callback) {
|
|
FML_DCHECK(external_texture_callback_);
|
|
}
|
|
|
|
EmbedderExternalTextureGL::~EmbedderExternalTextureGL() = default;
|
|
|
|
// |flutter::Texture|
|
|
void EmbedderExternalTextureGL::Paint(SkCanvas& canvas,
|
|
const SkRect& bounds,
|
|
bool freeze,
|
|
GrDirectContext* context,
|
|
SkFilterQuality filter_quality) {
|
|
if (auto image = external_texture_callback_(
|
|
Id(), //
|
|
context, //
|
|
SkISize::Make(bounds.width(), bounds.height()) //
|
|
)) {
|
|
last_image_ = image;
|
|
}
|
|
|
|
if (last_image_) {
|
|
SkPaint paint;
|
|
paint.setFilterQuality(filter_quality);
|
|
if (bounds != SkRect::Make(last_image_->bounds())) {
|
|
canvas.drawImageRect(last_image_, bounds, &paint);
|
|
} else {
|
|
canvas.drawImage(last_image_, bounds.x(), bounds.y(), &paint);
|
|
}
|
|
}
|
|
}
|
|
|
|
// |flutter::Texture|
|
|
void EmbedderExternalTextureGL::OnGrContextCreated() {}
|
|
|
|
// |flutter::Texture|
|
|
void EmbedderExternalTextureGL::OnGrContextDestroyed() {}
|
|
|
|
// |flutter::Texture|
|
|
void EmbedderExternalTextureGL::MarkNewFrameAvailable() {}
|
|
|
|
// |flutter::Texture|
|
|
void EmbedderExternalTextureGL::OnTextureUnregistered() {}
|
|
|
|
} // namespace flutter
|