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

Side by Side Diff: ui/gl/gl_surface_format.h

Issue 2702403009: Make surface GetFormat pure virtual, add missing overrides. (Closed)
Patch Set: Fix class name for Windows Created 3 years, 9 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
« no previous file with comments | « ui/gl/gl_surface.cc ('k') | ui/gl/gl_surface_glx.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 UI_GL_GL_SURFACE_FORMAT_H_ 5 #ifndef UI_GL_GL_SURFACE_FORMAT_H_
6 #define UI_GL_GL_SURFACE_FORMAT_H_ 6 #define UI_GL_GL_SURFACE_FORMAT_H_
7 7
8 #include "ui/gl/gl_export.h" 8 #include "ui/gl/gl_export.h"
9 9
10 namespace gl { 10 namespace gl {
11 11
12 // Expresses surface format properties that may vary depending
13 // on the underlying gl_surface implementation or specific usage
14 // scenarios. Intended usage is to support copying formats and
15 // checking compatibility.
12 class GL_EXPORT GLSurfaceFormat { 16 class GL_EXPORT GLSurfaceFormat {
13 public: 17 public:
14 18
15 // For use with constructor. 19 // For use with constructor.
16 enum SurfacePixelLayout { 20 enum SurfacePixelLayout {
17 PIXEL_LAYOUT_DONT_CARE = -1, 21 PIXEL_LAYOUT_DONT_CARE = -1,
18 PIXEL_LAYOUT_BGRA, 22 PIXEL_LAYOUT_BGRA,
19 PIXEL_LAYOUT_RGBA, 23 PIXEL_LAYOUT_RGBA,
20 }; 24 };
21 25
26 // Default surface format for the underlying gl_surface subtype.
27 // Use the setters below to change attributes if needed.
22 GLSurfaceFormat(); 28 GLSurfaceFormat();
23 29
30 // Use a specified pixel layout, cf. gl_surface_osmesa.
31 GLSurfaceFormat(SurfacePixelLayout layout);
32
33 // Copy constructor from pre-existing format.
34 GLSurfaceFormat(const GLSurfaceFormat& other);
35
24 ~GLSurfaceFormat(); 36 ~GLSurfaceFormat();
25 37
26 GLSurfaceFormat(SurfacePixelLayout layout); 38 // Helper method to determine if the format is unchanged from the
27 39 // default at creation time. TODO(klausw): can this be removed?
28 GLSurfaceFormat(const GLSurfaceFormat& other);
29
30 bool IsDefault(); 40 bool IsDefault();
31 41
42 // Surfaceless appears as a format property for backwards
43 // compatibility with the previous enum-based implementation.
44 // TODO(klausw): consider removing it and/or merging it into the
45 // pre-existing IsSurfaceless() predicate for the various Surface
46 // subclasses?
32 void SetIsSurfaceless(); 47 void SetIsSurfaceless();
33 bool IsSurfaceless(); 48 bool IsSurfaceless();
34 49
50 // A given pair of surfaces is considered compatible if glSetSurface
51 // can be used to switch between them without generating BAD_MATCH
52 // errors, visual errors, or gross inefficiency, and incompatible
53 // otherwise. For example, a pixel layout mismatch would be
54 // considered incompatible. This comparison only makes sense within
55 // the context of a single gl_surface subtype.
35 bool IsCompatible(GLSurfaceFormat other_format); 56 bool IsCompatible(GLSurfaceFormat other_format);
36 57
37 // Default pixel format is RGBA8888. Use this method to select 58 // Default pixel format is RGBA8888. Use this method to select
38 // a preference of RGB565. TODO(klausw): use individual setter 59 // a preference of RGB565. TODO(klausw): use individual setter
39 // methods if there's a use case for them. 60 // methods if there's a use case for them.
40 void SetRGB565(); 61 void SetRGB565();
41 62
42 // Other properties for future use. 63 // Other properties for future use.
43 void SetDepthBits(int depth_bits); 64 void SetDepthBits(int depth_bits);
44 int GetDepthBits(); 65 int GetDepthBits();
45 66
46 void SetStencilBits(int stencil_bits); 67 void SetStencilBits(int stencil_bits);
47 int GetStencilBits(); 68 int GetStencilBits();
48 69
49 void SetSamples(int samples); 70 void SetSamples(int samples);
50 int GetSamples(); 71 int GetSamples();
51 72
52 void SetDefaultPixelLayout(SurfacePixelLayout layout); 73 void SetDefaultPixelLayout(SurfacePixelLayout layout);
53 74
54 SurfacePixelLayout GetPixelLayout(); 75 SurfacePixelLayout GetPixelLayout();
55 76
77 // Compute number of bits needed for storing one pixel, not
78 // including any padding. At this point mainly used to distinguish
79 // RGB565 (16) from RGBA8888 (32).
56 int GetBufferSize(); 80 int GetBufferSize();
57 81
58 private: 82 private:
59 bool is_default_ = true; 83 bool is_default_ = true;
60 SurfacePixelLayout pixel_layout_ = PIXEL_LAYOUT_DONT_CARE; 84 SurfacePixelLayout pixel_layout_ = PIXEL_LAYOUT_DONT_CARE;
61 bool is_surfaceless_ = false; 85 bool is_surfaceless_ = false;
62 int red_bits_ = -1; 86 int red_bits_ = -1;
63 int green_bits_ = -1; 87 int green_bits_ = -1;
64 int blue_bits_ = -1; 88 int blue_bits_ = -1;
65 int alpha_bits_ = -1; 89 int alpha_bits_ = -1;
66 int depth_bits_ = -1; 90 int depth_bits_ = -1;
67 int samples_ = -1; 91 int samples_ = -1;
68 int stencil_bits_ = -1; 92 int stencil_bits_ = -1;
69 }; 93 };
70 94
71 } // namespace gl 95 } // namespace gl
72 96
73 #endif // UI_GL_GL_SURFACE_FORMAT_H_ 97 #endif // UI_GL_GL_SURFACE_FORMAT_H_
OLDNEW
« no previous file with comments | « ui/gl/gl_surface.cc ('k') | ui/gl/gl_surface_glx.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698