Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: gpu/command_buffer/service/gles2_cmd_srgb_converter.h

Issue 2286593002: [Command Buffer] emulate SRGB color format for BlitFramebuffer in OpenGL (Closed)
Patch Set: addressed piman@'s feedbacks, and rebased code Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_srgb_converter.h
diff --git a/gpu/command_buffer/service/gles2_cmd_srgb_converter.h b/gpu/command_buffer/service/gles2_cmd_srgb_converter.h
new file mode 100644
index 0000000000000000000000000000000000000000..739d7481347e335c9eabb46794bd840d1e6b5745
--- /dev/null
+++ b/gpu/command_buffer/service/gles2_cmd_srgb_converter.h
@@ -0,0 +1,91 @@
+// Copyright (c) 2016 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_GLES2_CMD_SRGB_CONVERTER_H_
+#define GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_SRGB_CONVERTER_H_
+
+#include <array>
+
+#include "base/containers/hash_tables.h"
+#include "base/macros.h"
+#include "gpu/command_buffer/service/feature_info.h"
+#include "gpu/command_buffer/service/gl_utils.h"
+#include "gpu/gpu_export.h"
+
+namespace gpu {
+namespace gles2 {
+
+class GLES2Decoder;
+
+// This class encapsulates the resources required to implement the
+// glBlitFramebuffer command, which somtimes requires to convert sRGB
+// to linear (RGBA) color format, or vice versa.
+class GPU_EXPORT SRGBConverter {
+ public:
+ explicit SRGBConverter(const gles2::FeatureInfo* feature_info);
+ ~SRGBConverter();
+
+ void InitializeSRGBDecoder(const gles2::GLES2Decoder* decoder);
+ void InitializeSRGBEncoder(const gles2::GLES2Decoder* decoder);
+ void Destroy();
+
+ void SRGBToLinear(
+ const gles2::GLES2Decoder* decoder,
+ GLint srcX0,
+ GLint srcY0,
+ GLint srcX1,
+ GLint srcY1,
+ GLint dstX0,
+ GLint dstY0,
+ GLint dstX1,
+ GLint dstY1,
+ GLbitfield mask,
+ GLenum filter,
+ const gfx::Size& framebuffer_size,
+ GLuint src_framebuffer,
+ GLenum src_framebuffer_internal_format,
+ GLuint dst_framebuffer);
+
+ void LinearToSRGB(
+ const gles2::GLES2Decoder* decoder,
+ GLint srcX0,
+ GLint srcY0,
+ GLint srcX1,
+ GLint srcY1,
+ GLint dstX0,
+ GLint dstY0,
+ GLint dstX1,
+ GLint dstY1,
+ GLbitfield mask,
+ GLenum filter,
+ GLuint src_framebuffer,
+ GLenum src_framebuffer_internal_format,
+ GLenum src_framebuffer_format,
+ GLenum src_framebuffer_type,
+ GLuint dst_framebuffer);
+
+ private:
+ scoped_refptr<const gles2::FeatureInfo> feature_info_;
+
+ bool srgb_decoder_initialized_ = false;
+ bool srgb_encoder_initialized_ = false;
+
+ GLuint srgb_decoder_program_ = 0;
+ GLuint srgb_encoder_program_ = 0;
+
+ std::array<GLuint, 2> srgb_decoder_textures_ = {{0, 0}};
+ std::array<GLuint, 1> srgb_encoder_textures_ = {{0}};
+ GLuint srgb_decoder_fbo_ = 0;
+ GLuint srgb_encoder_fbo_ = 0;
+
+ GLuint srgb_decoder_vao_ = 0;
+ GLuint srgb_encoder_vao_ = 0;
+
+ DISALLOW_COPY_AND_ASSIGN(SRGBConverter);
+};
+
+} // namespace gles2.
+} // namespace gpu.
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_GLES2_CMD_SRGB_CONVERTER_H_

Powered by Google App Engine
This is Rietveld 408576698