Windows: Cleanup: Eliminate ExternalTexturePixelBufferState (flutter/engine#36074)

This commit is contained in:
Niklas Schulze
2022-09-10 23:08:22 +02:00
committed by GitHub
parent a854f5840a
commit 9501668cf3
4 changed files with 12 additions and 32 deletions

View File

@@ -4,9 +4,6 @@
#include "flutter/shell/platform/windows/external_texture_d3d.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "flutter/fml/logging.h"
#include "flutter/shell/platform/embedder/embedder_struct_macros.h"

View File

@@ -5,11 +5,6 @@
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_EXTERNAL_TEXTURE_D3D_H_
#define FLUTTER_SHELL_PLATFORM_WINDOWS_EXTERNAL_TEXTURE_D3D_H_
#include <stdint.h>
#include <memory>
#include "flutter/shell/platform/common/public/flutter_texture_registrar.h"
#include "flutter/shell/platform/windows/angle_surface_manager.h"
#include "flutter/shell/platform/windows/external_texture.h"

View File

@@ -6,22 +6,17 @@
namespace flutter {
struct ExternalTexturePixelBufferState {
GLuint gl_texture = 0;
};
ExternalTexturePixelBuffer::ExternalTexturePixelBuffer(
FlutterDesktopPixelBufferTextureCallback texture_callback,
const FlutterDesktopPixelBufferTextureCallback texture_callback,
void* user_data,
const GlProcs& gl_procs)
: state_(std::make_unique<ExternalTexturePixelBufferState>()),
texture_callback_(texture_callback),
: texture_callback_(texture_callback),
user_data_(user_data),
gl_(gl_procs) {}
ExternalTexturePixelBuffer::~ExternalTexturePixelBuffer() {
if (state_->gl_texture != 0) {
gl_.glDeleteTextures(1, &state_->gl_texture);
if (gl_texture_ != 0) {
gl_.glDeleteTextures(1, &gl_texture_);
}
}
@@ -35,7 +30,7 @@ bool ExternalTexturePixelBuffer::PopulateTexture(
// Populate the texture object used by the engine.
opengl_texture->target = GL_TEXTURE_2D;
opengl_texture->name = state_->gl_texture;
opengl_texture->name = gl_texture_;
opengl_texture->format = GL_RGBA8_OES;
opengl_texture->destruction_callback = nullptr;
opengl_texture->user_data = nullptr;
@@ -55,17 +50,17 @@ bool ExternalTexturePixelBuffer::CopyPixelBuffer(size_t& width,
width = pixel_buffer->width;
height = pixel_buffer->height;
if (state_->gl_texture == 0) {
gl_.glGenTextures(1, &state_->gl_texture);
if (gl_texture_ == 0) {
gl_.glGenTextures(1, &gl_texture_);
gl_.glBindTexture(GL_TEXTURE_2D, state_->gl_texture);
gl_.glBindTexture(GL_TEXTURE_2D, gl_texture_);
gl_.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl_.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gl_.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl_.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
gl_.glBindTexture(GL_TEXTURE_2D, state_->gl_texture);
gl_.glBindTexture(GL_TEXTURE_2D, gl_texture_);
}
gl_.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixel_buffer->width,
pixel_buffer->height, 0, GL_RGBA, GL_UNSIGNED_BYTE,

View File

@@ -5,23 +5,16 @@
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_EXTERNAL_TEXTURE_PIXELBUFFER_H_
#define FLUTTER_SHELL_PLATFORM_WINDOWS_EXTERNAL_TEXTURE_PIXELBUFFER_H_
#include <stdint.h>
#include <memory>
#include "flutter/shell/platform/common/public/flutter_texture_registrar.h"
#include "flutter/shell/platform/windows/external_texture.h"
namespace flutter {
typedef struct ExternalTexturePixelBufferState ExternalTexturePixelBufferState;
// An abstraction of an pixel-buffer based texture.
class ExternalTexturePixelBuffer : public ExternalTexture {
public:
ExternalTexturePixelBuffer(
FlutterDesktopPixelBufferTextureCallback texture_callback,
const FlutterDesktopPixelBufferTextureCallback texture_callback,
void* user_data,
const GlProcs& gl_procs);
@@ -41,10 +34,10 @@ class ExternalTexturePixelBuffer : public ExternalTexture {
// by |texture_callback_| was invalid.
bool CopyPixelBuffer(size_t& width, size_t& height);
std::unique_ptr<ExternalTexturePixelBufferState> state_;
FlutterDesktopPixelBufferTextureCallback texture_callback_ = nullptr;
const FlutterDesktopPixelBufferTextureCallback texture_callback_ = nullptr;
void* const user_data_ = nullptr;
const GlProcs& gl_;
GLuint gl_texture_ = 0;
};
} // namespace flutter