Use common GrGLDefines instead of guessing platform specific headers. (flutter/engine#5381)
This commit is contained in:
@@ -4,18 +4,6 @@
|
||||
|
||||
#include "gpu_surface_gl.h"
|
||||
|
||||
#if OS_IOS
|
||||
#include <OpenGLES/ES2/gl.h>
|
||||
#include <OpenGLES/ES2/glext.h>
|
||||
#elif OS_MACOSX
|
||||
#include <OpenGL/gl3.h>
|
||||
#elif OS_LINUX
|
||||
#include <GL/gl.h>
|
||||
#else
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#endif
|
||||
|
||||
#include "flutter/glue/trace_event.h"
|
||||
#include "lib/fxl/arraysize.h"
|
||||
#include "lib/fxl/logging.h"
|
||||
@@ -24,6 +12,7 @@
|
||||
#include "third_party/skia/include/gpu/GrBackendSurface.h"
|
||||
#include "third_party/skia/include/gpu/GrContextOptions.h"
|
||||
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
|
||||
#include "third_party/skia/src/gpu/gl/GrGLDefines.h"
|
||||
|
||||
namespace shell {
|
||||
|
||||
@@ -87,27 +76,23 @@ bool GPUSurfaceGL::IsValid() {
|
||||
return valid_;
|
||||
}
|
||||
|
||||
static SkColorType FirstSupportedColorType(GrContext* context, GLenum* format) {
|
||||
static SkColorType FirstSupportedColorType(GrContext* context,
|
||||
GrGLenum* format) {
|
||||
#define RETURN_IF_RENDERABLE(x, y) \
|
||||
if (context->colorTypeSupportedAsSurface((x))) { \
|
||||
*format = (y); \
|
||||
return (x); \
|
||||
}
|
||||
#if (OS_MACOSX && !OS_IOS) || OS_LINUX
|
||||
RETURN_IF_RENDERABLE(kRGBA_8888_SkColorType, GL_RGBA8);
|
||||
#else
|
||||
RETURN_IF_RENDERABLE(kRGBA_8888_SkColorType, GL_RGBA8_OES);
|
||||
#endif
|
||||
RETURN_IF_RENDERABLE(kARGB_4444_SkColorType, GL_RGBA4);
|
||||
RETURN_IF_RENDERABLE(kRGB_565_SkColorType, GL_RGB565);
|
||||
RETURN_IF_RENDERABLE(kRGBA_8888_SkColorType, GR_GL_RGBA8);
|
||||
RETURN_IF_RENDERABLE(kARGB_4444_SkColorType, GR_GL_RGBA4);
|
||||
RETURN_IF_RENDERABLE(kRGB_565_SkColorType, GR_GL_RGB565);
|
||||
return kUnknown_SkColorType;
|
||||
}
|
||||
|
||||
static sk_sp<SkSurface> WrapOnscreenSurface(GrContext* context,
|
||||
const SkISize& size,
|
||||
intptr_t fbo) {
|
||||
|
||||
GLenum format;
|
||||
GrGLenum format;
|
||||
const SkColorType color_type = FirstSupportedColorType(context, &format);
|
||||
|
||||
const GrGLFramebufferInfo framebuffer_info = {
|
||||
@@ -115,7 +100,6 @@ static sk_sp<SkSurface> WrapOnscreenSurface(GrContext* context,
|
||||
.fFormat = format,
|
||||
};
|
||||
|
||||
|
||||
GrBackendRenderTarget render_target(size.fWidth, // width
|
||||
size.fHeight, // height
|
||||
0, // sample count
|
||||
@@ -214,11 +198,11 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceGL::AcquireFrame(const SkISize& size) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SurfaceFrame::SubmitCallback submit_callback = [weak = weak_factory_
|
||||
.GetWeakPtr()](
|
||||
const SurfaceFrame& surface_frame, SkCanvas* canvas) {
|
||||
return weak ? weak->PresentSurface(canvas) : false;
|
||||
};
|
||||
SurfaceFrame::SubmitCallback submit_callback =
|
||||
[weak = weak_factory_.GetWeakPtr()](const SurfaceFrame& surface_frame,
|
||||
SkCanvas* canvas) {
|
||||
return weak ? weak->PresentSurface(canvas) : false;
|
||||
};
|
||||
|
||||
return std::make_unique<SurfaceFrame>(surface, submit_callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user