1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "flutter/shell/platform/embedder/embedder_external_texture_gl.h"
6
7 #include "flutter/fml/logging.h"
8
9 namespace flutter {
10
EmbedderExternalTextureGL(int64_t texture_identifier,ExternalTextureCallback callback)11 EmbedderExternalTextureGL::EmbedderExternalTextureGL(
12 int64_t texture_identifier,
13 ExternalTextureCallback callback)
14 : Texture(texture_identifier), external_texture_callback_(callback) {
15 FML_DCHECK(external_texture_callback_);
16 }
17
18 EmbedderExternalTextureGL::~EmbedderExternalTextureGL() = default;
19
20 // |flutter::Texture|
Paint(SkCanvas & canvas,const SkRect & bounds,bool freeze,GrContext * context)21 void EmbedderExternalTextureGL::Paint(SkCanvas& canvas,
22 const SkRect& bounds,
23 bool freeze,
24 GrContext* context) {
25 if (auto image = external_texture_callback_(
26 Id(), //
27 canvas.getGrContext(), //
28 SkISize::Make(bounds.width(), bounds.height()) //
29 )) {
30 last_image_ = image;
31 }
32
33 if (last_image_) {
34 canvas.drawImage(last_image_, bounds.x(), bounds.y());
35 }
36 }
37
38 // |flutter::Texture|
OnGrContextCreated()39 void EmbedderExternalTextureGL::OnGrContextCreated() {}
40
41 // |flutter::Texture|
OnGrContextDestroyed()42 void EmbedderExternalTextureGL::OnGrContextDestroyed() {}
43
44 // |flutter::Texture|
MarkNewFrameAvailable()45 void EmbedderExternalTextureGL::MarkNewFrameAvailable() {}
46
47 } // namespace flutter
48