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

Side by Side Diff: content/common/gpu/client/gl_helper_readback_support.h

Issue 412453002: GLHelper: Address inconsistent mapping of SkColorType to GL format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_GPU_CLIENT_GL_HELPER_READBACK_SUPPORT_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GL_HELPER_READBACK_SUPPORT_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GL_HELPER_READBACK_SUPPORT_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_GL_HELPER_READBACK_SUPPORT_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "content/common/gpu/client/gl_helper.h" 10 #include "content/common/gpu/client/gl_helper.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 enum FormatSupport { kReadbackSupported,
piman 2014/07/22 19:57:55 nit: leave the enum in GLHelperReadbackSupport for
robert.bradford 2014/07/23 16:58:45 Enum moved in, and moved to MACRO_STYLE.
15 kReadbackSwizzle,
16 kReadbackNotSupported};
17
14 class CONTENT_EXPORT GLHelperReadbackSupport { 18 class CONTENT_EXPORT GLHelperReadbackSupport {
15 public: 19 public:
16 GLHelperReadbackSupport(gpu::gles2::GLES2Interface* gl); 20 GLHelperReadbackSupport(gpu::gles2::GLES2Interface* gl);
17 21
18 ~GLHelperReadbackSupport(); 22 ~GLHelperReadbackSupport();
19 23
20 // Checks whether the readback (Color read format and type) is supported
21 // for the requested texture format by the hardware or not.
22 // For ex: some hardwares have rgb565 readback
23 // support when binded with the frame buffer for others it may fail.
24 // Here we pass the internal textureformat as skia config.
25 bool IsReadbackConfigSupported(SkColorType texture_format);
26 24
25 // For a given color type retrieve whether readback is supported and if so
26 // how it should be performed. The |format|, |type| and |bytes_per_pixel| are
27 // the values that should be used with glReadPixels to facilitate the
28 // readback. If |can_swizzle| is true then this method will return
29 // kReadbackSwizzle if the data needs to be swizzled before using the
30 // returned |format| otherwise the method will return kReadbackSupported to
31 // indicate that readback is permitted of this color othewise
32 // kReadbackNotSupported will be returned. This method always overwrites the
33 // out values irrespective of the return value
piman 2014/07/22 19:57:55 nit: end comment with a period.
robert.bradford 2014/07/23 16:58:45 Done.
34 FormatSupport ReadbackConfig(SkColorType color_type,
35 const bool& can_swizzle,
piman 2014/07/22 19:57:55 nit: bool instead of const bool &.
robert.bradford 2014/07/23 16:58:45 Done.
36 GLint& format,
piman 2014/07/22 19:57:56 non-const references are forbidden by style guide.
robert.bradford 2014/07/23 16:58:45 Done.
37 GLint& type,
piman 2014/07/22 19:57:56 GLenum
robert.bradford 2014/07/23 16:58:45 Done.
38 int32& bytes_per_pixel);
piman 2014/07/22 19:57:55 size_t
robert.bradford 2014/07/23 16:58:45 Done.
27 // Provides the additional readback format/type pairing for a render target 39 // Provides the additional readback format/type pairing for a render target
28 // of a given format/type pairing 40 // of a given format/type pairing
29 void GetAdditionalFormat(GLint format, GLint type, GLint *format_out, 41 void GetAdditionalFormat(GLint format, GLint type, GLint *format_out,
30 GLint *type_out); 42 GLint *type_out);
31 private: 43 private:
32 enum FormatSupport { FORMAT_NOT_SUPPORTED = 0, FORMAT_SUPPORTED, };
33
34 struct FormatCacheEntry { 44 struct FormatCacheEntry {
35 GLint format; 45 GLint format;
36 GLint type; 46 GLint type;
37 GLint read_format; 47 GLint read_format;
38 GLint read_type; 48 GLint read_type;
39 }; 49 };
40 50
41 // This populates the format_support_table with the list of supported 51 // This populates the format_support_table with the list of supported
42 // formats. 52 // formats.
43 void InitializeReadbackSupport(); 53 void InitializeReadbackSupport();
(...skipping 11 matching lines...) Expand all
55 65
56 FormatSupport format_support_table_[kLastEnum_SkColorType + 1]; 66 FormatSupport format_support_table_[kLastEnum_SkColorType + 1];
57 67
58 gpu::gles2::GLES2Interface* gl_; 68 gpu::gles2::GLES2Interface* gl_;
59 std::vector<struct FormatCacheEntry> format_cache_; 69 std::vector<struct FormatCacheEntry> format_cache_;
60 }; 70 };
61 71
62 } // namespace content 72 } // namespace content
63 73
64 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_READBACK_SUPPORT_H_ 74 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_READBACK_SUPPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698