Flutter Engine
embedder_external_texture_gl.cc
Go to the documentation of this file.
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 
12  int64_t texture_identifier,
13  const ExternalTextureCallback& callback)
14  : Texture(texture_identifier), external_texture_callback_(callback) {
15  FML_DCHECK(external_texture_callback_);
16 }
17 
19 
20 // |flutter::Texture|
21 void EmbedderExternalTextureGL::Paint(SkCanvas& canvas,
22  const SkRect& bounds,
23  bool freeze,
24  GrDirectContext* context,
25  SkFilterQuality filter_quality) {
26  if (auto image = external_texture_callback_(
27  Id(), //
28  context, //
29  SkISize::Make(bounds.width(), bounds.height()) //
30  )) {
31  last_image_ = image;
32  }
33 
34  if (last_image_) {
35  SkPaint paint;
36  paint.setFilterQuality(filter_quality);
37  if (bounds != SkRect::Make(last_image_->bounds())) {
38  canvas.drawImageRect(last_image_, bounds, &paint);
39  } else {
40  canvas.drawImage(last_image_, bounds.x(), bounds.y(), &paint);
41  }
42  }
43 }
44 
45 // |flutter::Texture|
46 void EmbedderExternalTextureGL::OnGrContextCreated() {}
47 
48 // |flutter::Texture|
49 void EmbedderExternalTextureGL::OnGrContextDestroyed() {}
50 
51 // |flutter::Texture|
52 void EmbedderExternalTextureGL::MarkNewFrameAvailable() {}
53 
54 // |flutter::Texture|
55 void EmbedderExternalTextureGL::OnTextureUnregistered() {}
56 
57 } // namespace flutter
int64_t Id()
Definition: texture.h:42
#define FML_DCHECK(condition)
Definition: logging.h:86
EmbedderExternalTextureGL(int64_t texture_identifier, const ExternalTextureCallback &callback)
std::function< sk_sp< SkImage >(int64_t texture_identifier, GrDirectContext *, const SkISize &)> ExternalTextureCallback