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

Side by Side Diff: components/display_compositor/gl_helper_readback_support.h

Issue 2873243002: Move components/display_compositor to components/viz/display_compositor (Closed)
Patch Set: Rebase Created 3 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_DISPLAY_COMPOSITOR_GL_HELPER_READBACK_SUPPORT_H_
6 #define COMPONENTS_DISPLAY_COMPOSITOR_GL_HELPER_READBACK_SUPPORT_H_
7
8 #include <stddef.h>
9
10 #include <vector>
11
12 #include "components/display_compositor/display_compositor_export.h"
13 #include "components/display_compositor/gl_helper.h"
14
15 namespace display_compositor {
16
17 class DISPLAY_COMPOSITOR_EXPORT GLHelperReadbackSupport {
18 public:
19 enum FormatSupport { SUPPORTED, SWIZZLE, NOT_SUPPORTED };
20
21 GLHelperReadbackSupport(gpu::gles2::GLES2Interface* gl);
22
23 ~GLHelperReadbackSupport();
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 SWIZZLE if
29 // the data needs to be swizzled before using the returned |format| otherwise
30 // the method will return SUPPORTED to indicate that readback is permitted of
31 // this color othewise NOT_SUPPORTED will be returned. This method always
32 // overwrites the out values irrespective of the return value.
33 FormatSupport GetReadbackConfig(SkColorType color_type,
34 bool can_swizzle,
35 GLenum* format,
36 GLenum* type,
37 size_t* bytes_per_pixel);
38 // Provides the additional readback format/type pairing for a render target
39 // of a given format/type pairing
40 void GetAdditionalFormat(GLenum format,
41 GLenum type,
42 GLenum* format_out,
43 GLenum* type_out);
44
45 private:
46 struct FormatCacheEntry {
47 GLenum format;
48 GLenum type;
49 GLenum read_format;
50 GLenum read_type;
51 };
52
53 // This populates the format_support_table with the list of supported
54 // formats.
55 void InitializeReadbackSupport();
56
57 // This api is called once per format and it is done in the
58 // InitializeReadbackSupport. We should not use this any where
59 // except the InitializeReadbackSupport.Calling this at other places
60 // can distrub the state of normal gl operations.
61 void CheckForReadbackSupport(SkColorType texture_format);
62
63 // Helper functions for checking the supported texture formats.
64 // Avoid using this API in between texture operations, as this does some
65 // teture opertions (bind, attach) internally.
66 bool SupportsFormat(GLenum format, GLenum type);
67
68 FormatSupport format_support_table_[kLastEnum_SkColorType + 1];
69
70 gpu::gles2::GLES2Interface* gl_;
71 std::vector<struct FormatCacheEntry> format_cache_;
72 };
73
74 } // namespace display_compositor
75
76 #endif // COMPONENTS_DISPLAY_COMPOSITOR_GL_HELPER_READBACK_SUPPORT_H_
OLDNEW
« no previous file with comments | « components/display_compositor/gl_helper_benchmark.cc ('k') | components/display_compositor/gl_helper_readback_support.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698