-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wire up support for external OpenGL textures for the embedder.
- Loading branch information
1 parent
b972f75
commit a812604
Showing
7 changed files
with
283 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2018 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 shell { | ||
|
||
EmbedderExternalTextureGL::EmbedderExternalTextureGL( | ||
int64_t texture_identifier, | ||
ExternalTextureCallback callback) | ||
: Texture(texture_identifier), external_texture_callback_(callback) { | ||
FML_DCHECK(external_texture_callback_); | ||
} | ||
|
||
EmbedderExternalTextureGL::~EmbedderExternalTextureGL() = default; | ||
|
||
// |flow::Texture| | ||
void EmbedderExternalTextureGL::Paint(SkCanvas& canvas, | ||
const SkRect& bounds, | ||
bool freeze) { | ||
if (auto image = external_texture_callback_( | ||
Id(), // | ||
canvas.getGrContext(), // | ||
SkISize::Make(bounds.width(), bounds.height()) // | ||
)) { | ||
last_image_ = image; | ||
} | ||
|
||
if (last_image_) { | ||
canvas.drawImage(last_image_, bounds.x(), bounds.y()); | ||
} | ||
} | ||
|
||
// |flow::Texture| | ||
void EmbedderExternalTextureGL::OnGrContextCreated() {} | ||
|
||
// |flow::Texture| | ||
void EmbedderExternalTextureGL::OnGrContextDestroyed() {} | ||
|
||
// |flow::Texture| | ||
void EmbedderExternalTextureGL::MarkNewFrameAvailable() {} | ||
|
||
} // namespace shell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2018 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. | ||
|
||
#ifndef FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_EXTERNAL_TEXTURE_GL_H_ | ||
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_EXTERNAL_TEXTURE_GL_H_ | ||
|
||
#include "flutter/flow/texture.h" | ||
#include "flutter/fml/macros.h" | ||
#include "third_party/skia/include/core/SkImage.h" | ||
#include "third_party/skia/include/core/SkSize.h" | ||
|
||
namespace shell { | ||
|
||
class EmbedderExternalTextureGL : public flow::Texture { | ||
public: | ||
using ExternalTextureCallback = std::function< | ||
sk_sp<SkImage>(int64_t texture_identifier, GrContext*, const SkISize&)>; | ||
|
||
EmbedderExternalTextureGL(int64_t texture_identifier, | ||
ExternalTextureCallback callback); | ||
|
||
~EmbedderExternalTextureGL(); | ||
|
||
private: | ||
ExternalTextureCallback external_texture_callback_; | ||
sk_sp<SkImage> last_image_; | ||
|
||
// |flow::Texture| | ||
void Paint(SkCanvas& canvas, const SkRect& bounds, bool freeze) override; | ||
|
||
// |flow::Texture| | ||
void OnGrContextCreated() override; | ||
|
||
// |flow::Texture| | ||
void OnGrContextDestroyed() override; | ||
|
||
// |flow::Texture| | ||
void MarkNewFrameAvailable() override; | ||
|
||
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderExternalTextureGL); | ||
}; | ||
|
||
} // namespace shell | ||
|
||
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_EXTERNAL_TEXTURE_GL_H_ |