#include "content/renderer/pepper/ppb_graphics_3d_impl.h"
+#include <algorithm>
+
#include "base/bind.h"
#include "base/command_line.h"
#include "base/feature_list.h"
namespace content {
+namespace {
+
+#if defined(OS_TIZEN_TV_PRODUCT)
+const int32_t kMaxTextureSamples = 4;
+#endif
+
+} // namespace
+
PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PP_Instance instance)
: PPB_Graphics3D_Shared(instance),
bound_to_instance_(false),
attrib_helper.should_use_native_gmb_for_backbuffer = use_image_chromium_;
attrib_helper.context_type = gpu::CONTEXT_TYPE_OPENGLES2;
+#if defined(OS_TIZEN_TV_PRODUCT)
+ if (attrib_helper.samples > 1 && attrib_helper.sample_buffers > 1) {
+ attrib_helper.samples = std::min(attrib_helper.samples, kMaxTextureSamples);
+ }
+#endif
gpu::CommandBufferProxyImpl* share_buffer = nullptr;
UMA_HISTOGRAM_BOOLEAN("Pepper.Graphics3DHasShareGroup", !!share_context);
if (share_context) {
'unit_test': False,
'extension': 'EXT_multisampled_render_to_texture',
'extension_flag': 'multisampled_render_to_texture',
+ 'pepper_interface': 'FramebufferMultisample',
+ 'pepper_name': 'FramebufferTexture2DMultisampleEXT',
'trace_level': 1,
},
'FramebufferTextureLayer': {
'extension': 'chromium_framebuffer_multisample',
'extension_flag': 'chromium_framebuffer_multisample',
'pepper_interface': 'FramebufferMultisample',
- 'pepper_name': 'RenderbufferStorageMultisampleEXT',
+ 'pepper_name': 'RenderbufferStorageMultisampleCHROMIUM',
'trace_level': 1,
},
'RenderbufferStorageMultisampleAdvancedAMD': {
'unit_test': False,
'extension': 'EXT_multisampled_render_to_texture',
'extension_flag': 'multisampled_render_to_texture',
+ 'pepper_interface': 'FramebufferMultisample',
+ 'pepper_name': 'RenderbufferStorageMultisampleEXT',
'trace_level': 1,
},
'ReadBuffer': {
gl::GLApi* api() const;
+#if defined(OS_TIZEN_TV_PRODUCT)
+ void SetTextureSamples(GLsizei samples) { texture_samples_ = samples; }
+#endif
+
private:
raw_ptr<GLES2DecoderImpl> decoder_;
+#if defined(OS_TIZEN_TV_PRODUCT)
+ GLsizei texture_samples_;
+#endif
GLuint id_;
};
GLenum offscreen_target_depth_format_;
GLenum offscreen_target_stencil_format_;
GLsizei offscreen_target_samples_;
+#if defined(OS_TIZEN_TV_PRODUCT)
+ GLsizei offscreen_texture_samples_;
+#endif
GLboolean offscreen_target_buffer_preserved_;
GLint max_offscreen_framebuffer_size_;
BackFramebuffer::BackFramebuffer(GLES2DecoderImpl* decoder)
: decoder_(decoder),
+#if defined(OS_TIZEN_TV_PRODUCT)
+ texture_samples_(0),
+#endif
id_(0) {
}
decoder_->error_state_.get());
ScopedFramebufferBinder binder(decoder_, id_);
GLuint attach_id = texture ? texture->id() : 0;
+#if defined(OS_TIZEN_TV_PRODUCT)
+ if (texture_samples_ > 1) {
+ glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, attach_id, 0,
+ texture_samples_);
+
+ return;
+ }
+#endif
api()->glFramebufferTexture2DEXTFn(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
texture->Target(), attach_id, 0);
}
offscreen_target_depth_format_(0),
offscreen_target_stencil_format_(0),
offscreen_target_samples_(0),
+#if defined(OS_TIZEN_TV_PRODUCT)
+ offscreen_texture_samples_(0),
+#endif
offscreen_target_buffer_preserved_(true),
max_offscreen_framebuffer_size_(0),
offscreen_single_buffer_(false),
// ANGLE only supports packed depth/stencil formats, so use it if it is
// available.
const bool depth24_stencil8_supported =
+#if defined(OS_TIZEN_TV_PRODUCT)
+ offscreen_texture_samples_ <= 1 &&
+#endif
feature_info_->feature_flags().packed_depth24_stencil8;
VLOG(1) << "GL_OES_packed_depth_stencil "
<< (depth24_stencil8_supported ? "" : "not ") << "supported.";
// Create the target frame buffer. This is the one that the client renders
// directly to.
offscreen_target_frame_buffer_ = std::make_unique<BackFramebuffer>(this);
+#if defined(OS_TIZEN_TV_PRODUCT)
+ offscreen_target_frame_buffer_->SetTextureSamples(
+ offscreen_texture_samples_);
+#endif
offscreen_target_frame_buffer_->Create();
// Due to GLES2 format limitations, either the color texture (for
// non-multisampling) or the color render buffer (for multisampling) will be
// Create the saved offscreen texture. The target frame buffer is copied
// here when SwapBuffers is called.
offscreen_saved_frame_buffer_ = std::make_unique<BackFramebuffer>(this);
+#if defined(OS_TIZEN_TV_PRODUCT)
+ offscreen_saved_frame_buffer_->SetTextureSamples(
+ offscreen_texture_samples_);
+#endif
offscreen_saved_frame_buffer_->Create();
offscreen_saved_color_texture_ = std::make_unique<BackTexture>(this);
offscreen_saved_color_texture_->Create();
return false;
}
}
+ int32_t target_samples = offscreen_target_samples_;
+#if defined(OS_TIZEN_TV_PRODUCT)
+ if (target_samples == 1 && offscreen_texture_samples_ > 1)
+ target_samples = offscreen_texture_samples_;
+#endif
if (offscreen_target_depth_format_ &&
!offscreen_target_depth_render_buffer_->AllocateStorage(
- offscreen_size_, offscreen_target_depth_format_,
- offscreen_target_samples_)) {
+ offscreen_size_, offscreen_target_depth_format_, target_samples)) {
LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed "
<< "to allocate storage for offscreen target depth buffer.";
return false;
}
if (offscreen_target_stencil_format_ &&
!offscreen_target_stencil_render_buffer_->AllocateStorage(
- offscreen_size_, offscreen_target_stencil_format_,
- offscreen_target_samples_)) {
+ offscreen_size_, offscreen_target_stencil_format_, target_samples)) {
LOG(ERROR) << "GLES2DecoderImpl::ResizeOffscreenFramebuffer failed "
<< "to allocate storage for offscreen target stencil buffer.";
return false;
[macro="PPB_OPENGLES2_FRAMEBUFFERMULTISAMPLE_INTERFACE", force_struct_namespace]
interface PPB_OpenGLES2FramebufferMultisample {
+ void RenderbufferStorageMultisampleCHROMIUM([in] PP_Resource context,
+ [in] GLenum target,
+ [in] GLsizei samples,
+ [in] GLenum internalformat,
+ [in] GLsizei width,
+ [in] GLsizei height);
void RenderbufferStorageMultisampleEXT([in] PP_Resource context,
[in] GLenum target,
[in] GLsizei samples,
[in] GLenum internalformat,
[in] GLsizei width,
[in] GLsizei height);
+ void FramebufferTexture2DMultisampleEXT([in] PP_Resource context,
+ [in] GLenum target,
+ [in] GLenum attachment,
+ [in] GLenum textarget,
+ [in] GLuint texture,
+ [in] GLint level,
+ [in] GLsizei samples);
};
};
struct PPB_OpenGLES2FramebufferMultisample_1_0 {
+ void (*RenderbufferStorageMultisampleCHROMIUM)(PP_Resource context,
+ GLenum target,
+ GLsizei samples,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height);
void (*RenderbufferStorageMultisampleEXT)(PP_Resource context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height);
+ void (*FramebufferTexture2DMultisampleEXT)(PP_Resource context,
+ GLenum target,
+ GLenum attachment,
+ GLenum textarget,
+ GLuint texture,
+ GLint level,
+ GLsizei samples);
};
struct PPB_OpenGLES2FramebufferMultisample {
+ void (*RenderbufferStorageMultisampleCHROMIUM)(PP_Resource context,
+ GLenum target,
+ GLsizei samples,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height);
void (*RenderbufferStorageMultisampleEXT)(PP_Resource context,
GLenum target,
GLsizei samples,
GLenum internalformat,
GLsizei width,
GLsizei height);
+ void (*FramebufferTexture2DMultisampleEXT)(PP_Resource context,
+ GLenum target,
+ GLenum attachment,
+ GLenum textarget,
+ GLuint texture,
+ GLint level,
+ GLsizei samples);
};
struct PPB_OpenGLES2ChromiumEnableFeature_1_0 {
srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
}
+void GL_APIENTRY glRenderbufferStorageMultisampleCHROMIUM(GLenum target,
+ GLsizei samples,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height) {
+ const struct PPB_OpenGLES2FramebufferMultisample* ext =
+ glGetFramebufferMultisampleInterfacePPAPI();
+ if (ext)
+ ext->RenderbufferStorageMultisampleCHROMIUM(glGetCurrentContextPPAPI(),
+ target, samples, internalformat,
+ width, height);
+}
+
void GL_APIENTRY glRenderbufferStorageMultisampleEXT(GLenum target,
GLsizei samples,
GLenum internalformat,
height);
}
+void GL_APIENTRY glFramebufferTexture2DMultisampleEXT(GLenum target,
+ GLenum attachment,
+ GLenum textarget,
+ GLuint texture,
+ GLint level,
+ GLsizei samples) {
+ const struct PPB_OpenGLES2FramebufferMultisample* ext =
+ glGetFramebufferMultisampleInterfacePPAPI();
+ if (ext)
+ ext->FramebufferTexture2DMultisampleEXT(glGetCurrentContextPPAPI(), target,
+ attachment, textarget, texture,
+ level, samples);
+}
+
void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* queries) {
const struct PPB_OpenGLES2Query* ext = glGetQueryInterfacePPAPI();
if (ext)
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
#endif
-#if 0 // Defined in GL_EXT_multisampled_render_to_texture
#ifdef GL_GLEXT_PROTOTYPES
-#define glRenderbufferStorageMultisampleEXT GLES2_GET_FUN(RenderbufferStorageMultisampleEXT)
+#define glRenderbufferStorageMultisampleCHROMIUM \
+ GLES2_GET_FUN(RenderbufferStorageMultisampleCHROMIUM)
#if !defined(GLES2_USE_CPP_BINDINGS)
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY
+glRenderbufferStorageMultisampleCHROMIUM(GLenum target,
+ GLsizei samples,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height);
#endif
#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif
+typedef void(GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECHROMIUMPROC)(
+ GLenum target,
+ GLsizei samples,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height);
#endif
#ifndef GL_EXT_framebuffer_blit
}
}
+void RenderbufferStorageMultisampleCHROMIUM(PP_Resource context_id,
+ GLenum target,
+ GLsizei samples,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height) {
+ Enter3D enter(context_id, true);
+ if (enter.succeeded()) {
+ ToGles2Impl(&enter)->RenderbufferStorageMultisampleCHROMIUM(
+ target, samples, internalformat, width, height);
+ }
+}
+
void RenderbufferStorageMultisampleEXT(PP_Resource context_id,
GLenum target,
GLsizei samples,
GLsizei height) {
Enter3D enter(context_id, true);
if (enter.succeeded()) {
- ToGles2Impl(&enter)->RenderbufferStorageMultisampleCHROMIUM(
+ ToGles2Impl(&enter)->RenderbufferStorageMultisampleEXT(
target, samples, internalformat, width, height);
}
}
+void FramebufferTexture2DMultisampleEXT(PP_Resource context_id,
+ GLenum target,
+ GLenum attachment,
+ GLenum textarget,
+ GLuint texture,
+ GLint level,
+ GLsizei samples) {
+ Enter3D enter(context_id, true);
+ if (enter.succeeded()) {
+ ToGles2Impl(&enter)->FramebufferTexture2DMultisampleEXT(
+ target, attachment, textarget, texture, level, samples);
+ }
+}
+
void GenQueriesEXT(PP_Resource context_id, GLsizei n, GLuint* queries) {
Enter3D enter(context_id, true);
if (enter.succeeded()) {
const PPB_OpenGLES2FramebufferMultisample*
PPB_OpenGLES2_Shared::GetFramebufferMultisampleInterface() {
static const struct PPB_OpenGLES2FramebufferMultisample ppb_opengles2 = {
- &RenderbufferStorageMultisampleEXT};
+ &RenderbufferStorageMultisampleCHROMIUM,
+ &RenderbufferStorageMultisampleEXT, &FramebufferTexture2DMultisampleEXT};
return &ppb_opengles2;
}
const PPB_OpenGLES2ChromiumEnableFeature*