OLD | NEW |
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_BROWSER_COMPOSITOR_GL_HELPER_READBACK_SUPPORT_H_ |
6 #define CONTENT_COMMON_GPU_CLIENT_GL_HELPER_READBACK_SUPPORT_H_ | 6 #define CONTENT_BROWSER_COMPOSITOR_GL_HELPER_READBACK_SUPPORT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "content/common/gpu/client/gl_helper.h" | 12 #include "content/browser/compositor/gl_helper.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 class CONTENT_EXPORT GLHelperReadbackSupport { | 16 class CONTENT_EXPORT GLHelperReadbackSupport { |
17 public: | 17 public: |
18 enum FormatSupport { SUPPORTED, SWIZZLE, NOT_SUPPORTED }; | 18 enum FormatSupport { SUPPORTED, SWIZZLE, NOT_SUPPORTED }; |
19 | 19 |
20 GLHelperReadbackSupport(gpu::gles2::GLES2Interface* gl); | 20 GLHelperReadbackSupport(gpu::gles2::GLES2Interface* gl); |
21 | 21 |
22 ~GLHelperReadbackSupport(); | 22 ~GLHelperReadbackSupport(); |
23 | 23 |
24 // For a given color type retrieve whether readback is supported and if so | 24 // For a given color type retrieve whether readback is supported and if so |
25 // how it should be performed. The |format|, |type| and |bytes_per_pixel| are | 25 // how it should be performed. The |format|, |type| and |bytes_per_pixel| are |
26 // the values that should be used with glReadPixels to facilitate the | 26 // the values that should be used with glReadPixels to facilitate the |
27 // readback. If |can_swizzle| is true then this method will return SWIZZLE if | 27 // readback. If |can_swizzle| is true then this method will return SWIZZLE if |
28 // the data needs to be swizzled before using the returned |format| otherwise | 28 // the data needs to be swizzled before using the returned |format| otherwise |
29 // the method will return SUPPORTED to indicate that readback is permitted of | 29 // the method will return SUPPORTED to indicate that readback is permitted of |
30 // this color othewise NOT_SUPPORTED will be returned. This method always | 30 // this color othewise NOT_SUPPORTED will be returned. This method always |
31 // overwrites the out values irrespective of the return value. | 31 // overwrites the out values irrespective of the return value. |
32 FormatSupport GetReadbackConfig(SkColorType color_type, | 32 FormatSupport GetReadbackConfig(SkColorType color_type, |
33 bool can_swizzle, | 33 bool can_swizzle, |
34 GLenum* format, | 34 GLenum* format, |
35 GLenum* type, | 35 GLenum* type, |
36 size_t* bytes_per_pixel); | 36 size_t* bytes_per_pixel); |
37 // Provides the additional readback format/type pairing for a render target | 37 // Provides the additional readback format/type pairing for a render target |
38 // of a given format/type pairing | 38 // of a given format/type pairing |
39 void GetAdditionalFormat(GLenum format, GLenum type, GLenum *format_out, | 39 void GetAdditionalFormat(GLenum format, |
40 GLenum *type_out); | 40 GLenum type, |
| 41 GLenum* format_out, |
| 42 GLenum* type_out); |
| 43 |
41 private: | 44 private: |
42 struct FormatCacheEntry { | 45 struct FormatCacheEntry { |
43 GLenum format; | 46 GLenum format; |
44 GLenum type; | 47 GLenum type; |
45 GLenum read_format; | 48 GLenum read_format; |
46 GLenum read_type; | 49 GLenum read_type; |
47 }; | 50 }; |
48 | 51 |
49 // This populates the format_support_table with the list of supported | 52 // This populates the format_support_table with the list of supported |
50 // formats. | 53 // formats. |
(...skipping 11 matching lines...) Expand all Loading... |
62 bool SupportsFormat(GLenum format, GLenum type); | 65 bool SupportsFormat(GLenum format, GLenum type); |
63 | 66 |
64 FormatSupport format_support_table_[kLastEnum_SkColorType + 1]; | 67 FormatSupport format_support_table_[kLastEnum_SkColorType + 1]; |
65 | 68 |
66 gpu::gles2::GLES2Interface* gl_; | 69 gpu::gles2::GLES2Interface* gl_; |
67 std::vector<struct FormatCacheEntry> format_cache_; | 70 std::vector<struct FormatCacheEntry> format_cache_; |
68 }; | 71 }; |
69 | 72 |
70 } // namespace content | 73 } // namespace content |
71 | 74 |
72 #endif // CONTENT_COMMON_GPU_CLIENT_GL_HELPER_READBACK_SUPPORT_H_ | 75 #endif // CONTENT_BROWSER_COMPOSITOR_GL_HELPER_READBACK_SUPPORT_H_ |
OLD | NEW |