Commit 8629c39b authored by Jonathan Backer's avatar Jonathan Backer Committed by Commit Bot

Relocate and mock texture copier

This is for reuse by RasterDecoder in a subsequent CL. The test added
for GLES2DecoderImpl is similar to what will be added for
RasterDecoderImpl.

Changes:
- made CopyTextureMethod an enum class for easy forward decl
- moved ValidateCopyTexFormatHelper and GetCopyTextureCHROMIUMMethod for
  future reuse
- added mock for texture copying
- added unittest to make sure that texture copying clears source and
  destination textures appropriately

Bug: 789238
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I44a1ca37ad48d065acfd9d94b737ac1d925d99e5
Reviewed-on: https://chromium-review.googlesource.com/993592
Commit-Queue: Jonathan Backer <backer@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548228}
parent b2fce295
...@@ -144,6 +144,8 @@ static_library("test_support") { ...@@ -144,6 +144,8 @@ static_library("test_support") {
"command_buffer/client/client_test_helper.h", "command_buffer/client/client_test_helper.h",
"command_buffer/client/gles2_interface_stub.cc", "command_buffer/client/gles2_interface_stub.cc",
"command_buffer/client/gles2_interface_stub.h", "command_buffer/client/gles2_interface_stub.h",
"command_buffer/service/copy_texture_chromium_mock.cc",
"command_buffer/service/copy_texture_chromium_mock.h",
"command_buffer/service/error_state_mock.cc", "command_buffer/service/error_state_mock.cc",
"command_buffer/service/error_state_mock.h", "command_buffer/service/error_state_mock.h",
"command_buffer/service/gles2_cmd_decoder_mock.cc", "command_buffer/service/gles2_cmd_decoder_mock.cc",
......
// Copyright 2018 The Chromium 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 "gpu/command_buffer/service/copy_texture_chromium_mock.h"
namespace gpu {
namespace gles2 {
MockCopyTextureResourceManager::MockCopyTextureResourceManager() = default;
MockCopyTextureResourceManager::~MockCopyTextureResourceManager() = default;
} // namespace gles2
} // namespace gpu
// Copyright 2018 The Chromium 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 GPU_COMMAND_BUFFER_SERVICE_COPY_TEXTURE_CHROMIUM_MOCK_H_
#define GPU_COMMAND_BUFFER_SERVICE_COPY_TEXTURE_CHROMIUM_MOCK_H_
#include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace gpu {
namespace gles2 {
class MockCopyTextureResourceManager
: public CopyTextureCHROMIUMResourceManager {
public:
MockCopyTextureResourceManager();
~MockCopyTextureResourceManager() final;
MOCK_METHOD2(Initialize,
void(const DecoderContext* decoder,
const gles2::FeatureInfo::FeatureFlags& feature_flags));
MOCK_METHOD0(Destroy, void());
// Cannot MOCK_METHOD more than 10 args.
void DoCopyTexture(
const DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_internal_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_internal_format,
GLsizei width,
GLsizei height,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
bool dither,
CopyTextureMethod method,
CopyTexImageResourceManager* luma_emulation_blitter) override {}
void DoCopySubTexture(
const DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_internal_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_internal_format,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLsizei dest_width,
GLsizei dest_height,
GLsizei source_width,
GLsizei source_height,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
bool dither,
CopyTextureMethod method,
CopyTexImageResourceManager* luma_emulation_blitter) override {}
void DoCopySubTextureWithTransform(
const DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_internal_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_internal_format,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLsizei dest_width,
GLsizei dest_height,
GLsizei source_width,
GLsizei source_height,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
bool dither,
const GLfloat transform_matrix[16],
CopyTexImageResourceManager* luma_emulation_blitter) override{};
void DoCopyTextureWithTransform(
const DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_format,
GLsizei width,
GLsizei height,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
bool dither,
const GLfloat transform_matrix[16],
CopyTexImageResourceManager* luma_emulation_blitter) override{};
private:
DISALLOW_COPY_AND_ASSIGN(MockCopyTextureResourceManager);
};
} // namespace gles2
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_SERVICE_COPY_TEXTURE_CHROMIUM_MOCK_H_
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
#include "gpu/command_buffer/common/capabilities.h" #include "gpu/command_buffer/common/capabilities.h"
#include "gpu/command_buffer/service/error_state.h" #include "gpu/command_buffer/service/error_state.h"
#include "gpu/command_buffer/service/feature_info.h" #include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
#include "gpu/command_buffer/service/logger.h" #include "gpu/command_buffer/service/logger.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gl/gl_version_info.h" #include "ui/gl/gl_version_info.h"
namespace gpu { namespace gpu {
...@@ -491,5 +493,154 @@ bool GetCompressedTexSizeInBytes(const char* function_name, ...@@ -491,5 +493,154 @@ bool GetCompressedTexSizeInBytes(const char* function_name,
return true; return true;
} }
bool ValidateCopyTexFormatHelper(const FeatureInfo* feature_info,
GLenum internal_format,
GLenum read_format,
GLenum read_type,
std::string* output_error_msg) {
DCHECK(output_error_msg);
if (read_format == 0) {
*output_error_msg = std::string("no valid color image");
return false;
}
// Check we have compatible formats.
uint32_t channels_exist = GLES2Util::GetChannelsForFormat(read_format);
uint32_t channels_needed = GLES2Util::GetChannelsForFormat(internal_format);
if (!channels_needed ||
(channels_needed & channels_exist) != channels_needed) {
*output_error_msg = std::string("incompatible format");
return false;
}
if (feature_info->IsWebGL2OrES3Context()) {
GLint color_encoding =
GLES2Util::GetColorEncodingFromInternalFormat(read_format);
bool float_mismatch = feature_info->ext_color_buffer_float_available()
? (GLES2Util::IsIntegerFormat(internal_format) !=
GLES2Util::IsIntegerFormat(read_format))
: GLES2Util::IsFloatFormat(internal_format);
if (color_encoding !=
GLES2Util::GetColorEncodingFromInternalFormat(internal_format) ||
float_mismatch ||
(GLES2Util::IsSignedIntegerFormat(internal_format) !=
GLES2Util::IsSignedIntegerFormat(read_format)) ||
(GLES2Util::IsUnsignedIntegerFormat(internal_format) !=
GLES2Util::IsUnsignedIntegerFormat(read_format))) {
*output_error_msg = std::string("incompatible format");
return false;
}
}
if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
*output_error_msg =
std::string("can not be used with depth or stencil textures");
return false;
}
if (feature_info->IsWebGL2OrES3Context() ||
(feature_info->feature_flags().chromium_color_buffer_float_rgb &&
internal_format == GL_RGB32F) ||
(feature_info->feature_flags().chromium_color_buffer_float_rgba &&
internal_format == GL_RGBA32F)) {
if (GLES2Util::IsSizedColorFormat(internal_format)) {
int sr, sg, sb, sa;
GLES2Util::GetColorFormatComponentSizes(read_format, read_type, &sr, &sg,
&sb, &sa);
DCHECK(sr > 0 || sg > 0 || sb > 0 || sa > 0);
int dr, dg, db, da;
GLES2Util::GetColorFormatComponentSizes(internal_format, 0, &dr, &dg, &db,
&da);
DCHECK(dr > 0 || dg > 0 || db > 0 || da > 0);
if ((dr > 0 && sr != dr) || (dg > 0 && sg != dg) ||
(db > 0 && sb != db) || (da > 0 && sa != da)) {
*output_error_msg = std::string("incompatible color component sizes");
return false;
}
}
}
return true;
}
CopyTextureMethod GetCopyTextureCHROMIUMMethod(const FeatureInfo* feature_info,
GLenum source_target,
GLint source_level,
GLenum source_internal_format,
GLenum source_type,
GLenum dest_target,
GLint dest_level,
GLenum dest_internal_format,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
bool dither) {
bool premultiply_alpha_change = premultiply_alpha ^ unpremultiply_alpha;
bool source_format_color_renderable =
Texture::ColorRenderable(feature_info, source_internal_format, false);
bool dest_format_color_renderable =
Texture::ColorRenderable(feature_info, dest_internal_format, false);
std::string output_error_msg;
switch (dest_internal_format) {
#if defined(OS_MACOSX)
// RGB5_A1 is not color-renderable on NVIDIA Mac, see
// https://crbug.com/676209.
case GL_RGB5_A1:
return CopyTextureMethod::DRAW_AND_READBACK;
#endif
// RGB9_E5 isn't accepted by glCopyTexImage2D if underlying context is ES.
case GL_RGB9_E5:
if (feature_info->gl_version_info().is_es)
return CopyTextureMethod::DRAW_AND_READBACK;
break;
// SRGB format has color-space conversion issue. WebGL spec doesn't define
// clearly if linear-to-srgb color space conversion is required or not when
// uploading DOM elements to SRGB textures. WebGL conformance test expects
// no linear-to-srgb conversion, while current GPU path for
// CopyTextureCHROMIUM does the conversion. Do a fallback path before the
// issue is resolved. see https://github.com/KhronosGroup/WebGL/issues/2165.
// TODO(qiankun.miao@intel.com): revisit this once the above issue is
// resolved.
case GL_SRGB_EXT:
case GL_SRGB_ALPHA_EXT:
case GL_SRGB8:
case GL_SRGB8_ALPHA8:
if (feature_info->IsWebGLContext())
return CopyTextureMethod::DRAW_AND_READBACK;
break;
default:
break;
}
// CopyTexImage* should not allow internalformat of GL_BGRA_EXT and
// GL_BGRA8_EXT. https://crbug.com/663086.
bool copy_tex_image_format_valid =
source_internal_format != GL_BGRA_EXT &&
dest_internal_format != GL_BGRA_EXT &&
source_internal_format != GL_BGRA8_EXT &&
dest_internal_format != GL_BGRA8_EXT &&
ValidateCopyTexFormatHelper(feature_info, dest_internal_format,
source_internal_format, source_type,
&output_error_msg);
// TODO(qiankun.miao@intel.com): for WebGL 2.0 or OpenGL ES 3.0, both
// DIRECT_DRAW path for dest_level > 0 and DIRECT_COPY path for source_level >
// 0 are not available due to a framebuffer completeness bug:
// https://crbug.com/678526. Once the bug is fixed, the limitation for WebGL
// 2.0 and OpenGL ES 3.0 can be lifted. For WebGL 1.0 or OpenGL ES 2.0,
// DIRECT_DRAW path isn't available for dest_level > 0 due to level > 0 isn't
// supported by glFramebufferTexture2D in ES2 context. DIRECT_DRAW path isn't
// available for cube map dest texture either due to it may be cube map
// incomplete. Go to DRAW_AND_COPY path in these cases.
if (source_target == GL_TEXTURE_2D &&
(dest_target == GL_TEXTURE_2D || dest_target == GL_TEXTURE_CUBE_MAP) &&
source_format_color_renderable && copy_tex_image_format_valid &&
source_level == 0 && !flip_y && !premultiply_alpha_change && !dither)
return CopyTextureMethod::DIRECT_COPY;
if (dest_format_color_renderable && dest_level == 0 &&
dest_target != GL_TEXTURE_CUBE_MAP)
return CopyTextureMethod::DIRECT_DRAW;
// Draw to a fbo attaching level 0 of an intermediate texture,
// then copy from the fbo to dest texture level with glCopyTexImage2D.
return CopyTextureMethod::DRAW_AND_COPY;
}
} // namespace gles2 } // namespace gles2
} // namespace gpu } // namespace gpu
...@@ -41,6 +41,7 @@ namespace gles2 { ...@@ -41,6 +41,7 @@ namespace gles2 {
class ErrorState; class ErrorState;
class FeatureInfo; class FeatureInfo;
class Logger; class Logger;
enum class CopyTextureMethod;
struct CALayerSharedState { struct CALayerSharedState {
float opacity; float opacity;
...@@ -104,6 +105,25 @@ bool GetCompressedTexSizeInBytes(const char* function_name, ...@@ -104,6 +105,25 @@ bool GetCompressedTexSizeInBytes(const char* function_name,
GLsizei* size_in_bytes, GLsizei* size_in_bytes,
ErrorState* error_state); ErrorState* error_state);
bool ValidateCopyTexFormatHelper(const FeatureInfo* feature_info,
GLenum internal_format,
GLenum read_format,
GLenum read_type,
std::string* output_error_msg);
CopyTextureMethod GetCopyTextureCHROMIUMMethod(const FeatureInfo* feature_info,
GLenum source_target,
GLint source_level,
GLenum source_internal_format,
GLenum source_type,
GLenum dest_target,
GLint dest_level,
GLenum dest_internal_format,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
bool dither);
} // namespace gles2 } // namespace gles2
} // namespace gpu } // namespace gpu
......
...@@ -244,7 +244,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager:: ...@@ -244,7 +244,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::
ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy); ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy);
// Source format for DoCopySubTexture is always GL_RGBA8. // Source format for DoCopySubTexture is always GL_RGBA8.
CopyTextureMethod method = DIRECT_COPY; CopyTextureMethod method = CopyTextureMethod::DIRECT_COPY;
bool copy_tex_image_format_valid = bool copy_tex_image_format_valid =
!GLES2Util::IsIntegerFormat(internal_format) && !GLES2Util::IsIntegerFormat(internal_format) &&
GLES2Util::GetColorEncodingFromInternalFormat(internal_format) != GLES2Util::GetColorEncodingFromInternalFormat(internal_format) !=
...@@ -260,7 +260,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager:: ...@@ -260,7 +260,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::
} }
} }
if (!copy_tex_image_format_valid) if (!copy_tex_image_format_valid)
method = DIRECT_DRAW; method = CopyTextureMethod::DIRECT_DRAW;
bool color_renderable = bool color_renderable =
Texture::ColorRenderable(decoder->GetFeatureInfo(), internal_format, Texture::ColorRenderable(decoder->GetFeatureInfo(), internal_format,
texture->texture()->IsImmutable()); texture->texture()->IsImmutable());
...@@ -270,10 +270,10 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager:: ...@@ -270,10 +270,10 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::
// TODO(dshwang): After Mesa fixes this issue, remove this hack. // TODO(dshwang): After Mesa fixes this issue, remove this hack.
// https://bugs.freedesktop.org/show_bug.cgi?id=98478, crbug.com/535198. // https://bugs.freedesktop.org/show_bug.cgi?id=98478, crbug.com/535198.
if (color_renderable) if (color_renderable)
method = DIRECT_DRAW; method = CopyTextureMethod::DIRECT_DRAW;
#endif #endif
if (method == DIRECT_DRAW && !color_renderable) if (method == CopyTextureMethod::DIRECT_DRAW && !color_renderable)
method = DRAW_AND_COPY; method = CopyTextureMethod::DRAW_AND_COPY;
// LUMINANCE, LUMINANCE_ALPHA and ALPHA textures aren't // LUMINANCE, LUMINANCE_ALPHA and ALPHA textures aren't
// renderable, so we don't need to pass in the luma emulation // renderable, so we don't need to pass in the luma emulation
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/containers/hash_tables.h" #include "base/containers/hash_tables.h"
#include "base/macros.h" #include "base/macros.h"
#include "gpu/command_buffer/service/feature_info.h" #include "gpu/command_buffer/service/feature_info.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/gpu_gles2_export.h" #include "gpu/gpu_gles2_export.h"
namespace gpu { namespace gpu {
...@@ -21,7 +20,7 @@ namespace gles2 { ...@@ -21,7 +20,7 @@ namespace gles2 {
class CopyTexImageResourceManager; class CopyTexImageResourceManager;
enum CopyTextureMethod { enum class CopyTextureMethod {
// Use CopyTex{Sub}Image2D to copy from the source to the destination. // Use CopyTex{Sub}Image2D to copy from the source to the destination.
DIRECT_COPY, DIRECT_COPY,
// Draw from the source to the destination texture. // Draw from the source to the destination texture.
...@@ -48,14 +47,18 @@ enum CopyTextureMethod { ...@@ -48,14 +47,18 @@ enum CopyTextureMethod {
// The target of |dest_id| texture must be GL_TEXTURE_2D. // The target of |dest_id| texture must be GL_TEXTURE_2D.
class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
public: public:
CopyTextureCHROMIUMResourceManager(); virtual ~CopyTextureCHROMIUMResourceManager();
~CopyTextureCHROMIUMResourceManager();
// Factory generating a real implementation.
static CopyTextureCHROMIUMResourceManager* Create();
void Initialize(const DecoderContext* decoder, virtual void Initialize(
const gles2::FeatureInfo::FeatureFlags& feature_flags); const DecoderContext* decoder,
void Destroy(); const gles2::FeatureInfo::FeatureFlags& feature_flags) = 0;
virtual void Destroy() = 0;
void DoCopyTexture(const DecoderContext* decoder, virtual void DoCopyTexture(
const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -71,9 +74,10 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { ...@@ -71,9 +74,10 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
bool unpremultiply_alpha, bool unpremultiply_alpha,
bool dither, bool dither,
CopyTextureMethod method, CopyTextureMethod method,
CopyTexImageResourceManager* luma_emulation_blitter); CopyTexImageResourceManager* luma_emulation_blitter) = 0;
void DoCopySubTexture(const DecoderContext* decoder, virtual void DoCopySubTexture(
const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
GLint source_level, GLint source_level,
...@@ -97,9 +101,9 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { ...@@ -97,9 +101,9 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
bool unpremultiply_alpha, bool unpremultiply_alpha,
bool dither, bool dither,
CopyTextureMethod method, CopyTextureMethod method,
CopyTexImageResourceManager* luma_emulation_blitter); CopyTexImageResourceManager* luma_emulation_blitter) = 0;
void DoCopySubTextureWithTransform( virtual void DoCopySubTextureWithTransform(
const DecoderContext* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
...@@ -124,13 +128,13 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { ...@@ -124,13 +128,13 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
bool unpremultiply_alpha, bool unpremultiply_alpha,
bool dither, bool dither,
const GLfloat transform_matrix[16], const GLfloat transform_matrix[16],
CopyTexImageResourceManager* luma_emulation_blitter); CopyTexImageResourceManager* luma_emulation_blitter) = 0;
// This will apply a transform on the texture coordinates before sampling // This will apply a transform on the texture coordinates before sampling
// the source texture and copying to the destination texture. The transform // the source texture and copying to the destination texture. The transform
// matrix should be given in column-major form, so it can be passed // matrix should be given in column-major form, so it can be passed
// directly to GL. // directly to GL.
void DoCopyTextureWithTransform( virtual void DoCopyTextureWithTransform(
const DecoderContext* decoder, const DecoderContext* decoder,
GLenum source_target, GLenum source_target,
GLuint source_id, GLuint source_id,
...@@ -147,77 +151,15 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager { ...@@ -147,77 +151,15 @@ class GPU_GLES2_EXPORT CopyTextureCHROMIUMResourceManager {
bool unpremultiply_alpha, bool unpremultiply_alpha,
bool dither, bool dither,
const GLfloat transform_matrix[16], const GLfloat transform_matrix[16],
CopyTexImageResourceManager* luma_emulation_blitter); CopyTexImageResourceManager* luma_emulation_blitter) = 0;
// The attributes used during invocation of the extension. // The attributes used during invocation of the extension.
static const GLuint kVertexPositionAttrib = 0; static const GLuint kVertexPositionAttrib = 0;
private: protected:
struct ProgramInfo { CopyTextureCHROMIUMResourceManager();
ProgramInfo()
: program(0u),
vertex_dest_mult_handle(0u),
vertex_dest_add_handle(0u),
vertex_source_mult_handle(0u),
vertex_source_add_handle(0u),
tex_coord_transform_handle(0u),
sampler_handle(0u) {}
GLuint program;
// Transformations that map from the original quad coordinates [-1, 1] into
// the destination texture's quad coordinates.
GLuint vertex_dest_mult_handle;
GLuint vertex_dest_add_handle;
// Transformations that map from the original quad coordinates [-1, 1] into
// the source texture's texture coordinates.
GLuint vertex_source_mult_handle;
GLuint vertex_source_add_handle;
GLuint tex_coord_transform_handle;
GLuint sampler_handle;
};
void DoCopyTextureInternal(
const DecoderContext* decoder,
GLenum source_target,
GLuint source_id,
GLint source_level,
GLenum source_format,
GLenum dest_target,
GLuint dest_id,
GLint dest_level,
GLenum dest_format,
GLint xoffset,
GLint yoffset,
GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLsizei dest_width,
GLsizei dest_height,
GLsizei source_width,
GLsizei source_height,
bool flip_y,
bool premultiply_alpha,
bool unpremultiply_alpha,
bool dither,
const GLfloat transform_matrix[16],
CopyTexImageResourceManager* luma_emulation_blitter);
bool initialized_;
bool nv_egl_stream_consumer_external_;
typedef std::vector<GLuint> ShaderVector;
ShaderVector vertex_shaders_;
ShaderVector fragment_shaders_;
typedef int ProgramMapKey;
typedef base::hash_map<ProgramMapKey, ProgramInfo> ProgramMap;
ProgramMap programs_;
GLuint vertex_array_object_id_;
GLuint buffer_id_;
GLuint framebuffer_;
private:
DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager); DISALLOW_COPY_AND_ASSIGN(CopyTextureCHROMIUMResourceManager);
}; };
......
...@@ -43,6 +43,7 @@ class ServiceTransferCache; ...@@ -43,6 +43,7 @@ class ServiceTransferCache;
namespace gles2 { namespace gles2 {
class ContextGroup; class ContextGroup;
class CopyTextureCHROMIUMResourceManager;
class FramebufferManager; class FramebufferManager;
class GLES2Util; class GLES2Util;
class ImageManager; class ImageManager;
...@@ -185,6 +186,9 @@ class GPU_GLES2_EXPORT GLES2Decoder : public CommonDecoder, ...@@ -185,6 +186,9 @@ class GPU_GLES2_EXPORT GLES2Decoder : public CommonDecoder,
virtual scoped_refptr<ShaderTranslatorInterface> GetTranslator( virtual scoped_refptr<ShaderTranslatorInterface> GetTranslator(
unsigned int type) = 0; unsigned int type) = 0;
virtual void SetCopyTextureResourceManagerForTest(
CopyTextureCHROMIUMResourceManager* copy_texture_resource_manager) = 0;
protected: protected:
GLES2Decoder(CommandBufferServiceBase* command_buffer_service, GLES2Decoder(CommandBufferServiceBase* command_buffer_service,
Outputter* outputter); Outputter* outputter);
......
...@@ -160,6 +160,9 @@ class MockGLES2Decoder : public GLES2Decoder { ...@@ -160,6 +160,9 @@ class MockGLES2Decoder : public GLES2Decoder {
uint32_t texture_target, uint32_t texture_target,
gl::GLImage* image, gl::GLImage* image,
bool can_bind_to_sampler)); bool can_bind_to_sampler));
MOCK_METHOD1(
SetCopyTextureResourceManagerForTest,
void(CopyTextureCHROMIUMResourceManager* copy_texture_resource_manager));
private: private:
base::WeakPtrFactory<MockGLES2Decoder> weak_ptr_factory_; base::WeakPtrFactory<MockGLES2Decoder> weak_ptr_factory_;
......
...@@ -1488,6 +1488,11 @@ void GLES2DecoderPassthroughImpl::OnDebugMessage(GLenum source, ...@@ -1488,6 +1488,11 @@ void GLES2DecoderPassthroughImpl::OnDebugMessage(GLenum source,
} }
} }
void GLES2DecoderPassthroughImpl::SetCopyTextureResourceManagerForTest(
CopyTextureCHROMIUMResourceManager* copy_texture_resource_manager) {
NOTIMPLEMENTED();
}
const char* GLES2DecoderPassthroughImpl::GetCommandName( const char* GLES2DecoderPassthroughImpl::GetCommandName(
unsigned int command_id) const { unsigned int command_id) const {
if (command_id >= kFirstGLES2Command && command_id < kNumCommands) { if (command_id >= kFirstGLES2Command && command_id < kNumCommands) {
......
...@@ -312,6 +312,10 @@ class GPU_GLES2_EXPORT GLES2DecoderPassthroughImpl : public GLES2Decoder { ...@@ -312,6 +312,10 @@ class GPU_GLES2_EXPORT GLES2DecoderPassthroughImpl : public GLES2Decoder {
GLsizei length, GLsizei length,
const GLchar* message); const GLchar* message);
void SetCopyTextureResourceManagerForTest(
CopyTextureCHROMIUMResourceManager* copy_texture_resource_manager)
override;
private: private:
// Allow unittests to inspect internal state tracking // Allow unittests to inspect internal state tracking
friend class GLES2DecoderPassthroughTestBase; friend class GLES2DecoderPassthroughTestBase;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "gpu/command_buffer/common/gles2_cmd_format.h" #include "gpu/command_buffer/common/gles2_cmd_format.h"
#include "gpu/command_buffer/common/gles2_cmd_utils.h" #include "gpu/command_buffer/common/gles2_cmd_utils.h"
#include "gpu/command_buffer/service/context_group.h" #include "gpu/command_buffer/service/context_group.h"
#include "gpu/command_buffer/service/copy_texture_chromium_mock.h"
#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/command_buffer/service/logger.h" #include "gpu/command_buffer/service/logger.h"
#include "gpu/command_buffer/service/mailbox_manager.h" #include "gpu/command_buffer/service/mailbox_manager.h"
...@@ -498,6 +499,10 @@ void GLES2DecoderTestBase::InitDecoderWithWorkarounds( ...@@ -498,6 +499,10 @@ void GLES2DecoderTestBase::InitDecoderWithWorkarounds(
&outputter_, group_.get())); &outputter_, group_.get()));
decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_); decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_);
decoder_->GetLogger()->set_log_synthesized_gl_errors(false); decoder_->GetLogger()->set_log_synthesized_gl_errors(false);
copy_texture_manager_ = new MockCopyTextureResourceManager();
decoder_->SetCopyTextureResourceManagerForTest(copy_texture_manager_);
ASSERT_EQ(decoder_->Initialize(surface_, context_, false, ASSERT_EQ(decoder_->Initialize(surface_, context_, false,
DisallowedFeatures(), attribs), DisallowedFeatures(), attribs),
gpu::ContextResult::kSuccess); gpu::ContextResult::kSuccess);
...@@ -583,6 +588,14 @@ void GLES2DecoderTestBase::ResetDecoder() { ...@@ -583,6 +588,14 @@ void GLES2DecoderTestBase::ResetDecoder() {
} }
decoder_->EndDecoding(); decoder_->EndDecoding();
if (!decoder_->WasContextLost()) {
EXPECT_CALL(*copy_texture_manager_, Destroy())
.Times(1)
.RetiresOnSaturation();
copy_texture_manager_ = nullptr;
}
decoder_->Destroy(!decoder_->WasContextLost()); decoder_->Destroy(!decoder_->WasContextLost());
decoder_.reset(); decoder_.reset();
group_->Destroy(mock_decoder_.get(), false); group_->Destroy(mock_decoder_.get(), false);
......
...@@ -47,6 +47,7 @@ namespace gpu { ...@@ -47,6 +47,7 @@ namespace gpu {
namespace gles2 { namespace gles2 {
class MemoryTracker; class MemoryTracker;
class MockCopyTextureResourceManager;
class GLES2DecoderTestBase : public ::testing::TestWithParam<bool>, class GLES2DecoderTestBase : public ::testing::TestWithParam<bool>,
public DecoderClient { public DecoderClient {
...@@ -797,6 +798,8 @@ class GLES2DecoderTestBase : public ::testing::TestWithParam<bool>, ...@@ -797,6 +798,8 @@ class GLES2DecoderTestBase : public ::testing::TestWithParam<bool>,
scoped_refptr<ContextGroup> group_; scoped_refptr<ContextGroup> group_;
MockGLStates gl_states_; MockGLStates gl_states_;
base::MessageLoop message_loop_; base::MessageLoop message_loop_;
MockCopyTextureResourceManager* copy_texture_manager_; // not owned
}; };
class GLES2DecoderWithShaderTestBase : public GLES2DecoderTestBase { class GLES2DecoderWithShaderTestBase : public GLES2DecoderTestBase {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment