flutter_flutter/shell/platform/embedder/embedder_external_texture_gl.cc
Adlai Holler c57aff1800
Use the GrDirectContext factories instead of deprecated GrContext ones (#19962)
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.
2020-07-28 13:32:09 -07:00

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