OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011, Google Inc. | 2 * Copyright 2011, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 namespace o3d { | 42 namespace o3d { |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
46 Texture::RGBASwizzleIndices g_gl_abgr32f_swizzle_indices = {0, 1, 2, 3}; | 46 Texture::RGBASwizzleIndices g_gl_abgr32f_swizzle_indices = {0, 1, 2, 3}; |
47 | 47 |
48 } // anonymous namespace. | 48 } // anonymous namespace. |
49 | 49 |
50 namespace o2d { | 50 namespace o2d { |
51 | 51 |
| 52 // This is equivalent to the CAIRO_FORMAT_INVALID enum value, but we can't refer |
| 53 // to that because it was only recently added to the Cairo headers and thus it |
| 54 // is not present on the Linux buildbots (where we use the OS version of Cairo |
| 55 // rather than the one in third_party). |
| 56 static const cairo_format_t kCairoFormatInvalid = |
| 57 static_cast<cairo_format_t>(-1); |
| 58 |
52 static cairo_format_t CairoFormatFromO3DFormat( | 59 static cairo_format_t CairoFormatFromO3DFormat( |
53 Texture::Format format) { | 60 Texture::Format format) { |
54 switch (format) { | 61 switch (format) { |
55 case Texture::ARGB8: | 62 case Texture::ARGB8: |
56 return CAIRO_FORMAT_ARGB32; | 63 return CAIRO_FORMAT_ARGB32; |
57 case Texture::XRGB8: | 64 case Texture::XRGB8: |
58 return CAIRO_FORMAT_RGB24; | 65 return CAIRO_FORMAT_RGB24; |
59 default: | 66 default: |
60 return CAIRO_FORMAT_INVALID; | 67 return kCairoFormatInvalid; |
61 } | 68 } |
62 // Cairo also supports two other pure-alpha formats, but we don't expose those | 69 // Cairo also supports two other pure-alpha formats, but we don't expose those |
63 // capabilities. | 70 // capabilities. |
64 } | 71 } |
65 | 72 |
66 TextureCairo::TextureCairo(ServiceLocator* service_locator, | 73 TextureCairo::TextureCairo(ServiceLocator* service_locator, |
67 cairo_surface_t* image_surface, | 74 cairo_surface_t* image_surface, |
68 Texture::Format format, | 75 Texture::Format format, |
69 int levels, | 76 int levels, |
70 int width, | 77 int width, |
(...skipping 13 matching lines...) Expand all Loading... |
84 // Creates a new texture object from scratch. | 91 // Creates a new texture object from scratch. |
85 TextureCairo* TextureCairo::Create(ServiceLocator* service_locator, | 92 TextureCairo* TextureCairo::Create(ServiceLocator* service_locator, |
86 Texture::Format format, | 93 Texture::Format format, |
87 int levels, | 94 int levels, |
88 int width, | 95 int width, |
89 int height, | 96 int height, |
90 bool enable_render_surfaces) { | 97 bool enable_render_surfaces) { |
91 cairo_format_t cairo_format = CairoFormatFromO3DFormat(format); | 98 cairo_format_t cairo_format = CairoFormatFromO3DFormat(format); |
92 cairo_surface_t* image_surface; | 99 cairo_surface_t* image_surface; |
93 cairo_status_t status; | 100 cairo_status_t status; |
94 if (CAIRO_FORMAT_INVALID == cairo_format) { | 101 if (kCairoFormatInvalid == cairo_format) { |
95 DLOG(ERROR) << "Texture format " << format << " not supported by Cairo"; | 102 DLOG(ERROR) << "Texture format " << format << " not supported by Cairo"; |
96 goto fail0; | 103 goto fail0; |
97 } | 104 } |
98 image_surface = cairo_image_surface_create( | 105 image_surface = cairo_image_surface_create( |
99 cairo_format, | 106 cairo_format, |
100 width, | 107 width, |
101 height); | 108 height); |
102 status = cairo_surface_status(image_surface); | 109 status = cairo_surface_status(image_surface); |
103 if (CAIRO_STATUS_SUCCESS != status) { | 110 if (CAIRO_STATUS_SUCCESS != status) { |
104 DLOG(ERROR) << "Error creating Cairo image surface: " << status; | 111 DLOG(ERROR) << "Error creating Cairo image surface: " << status; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 225 |
219 // Returns the implementation-specific texture handle for this texture. | 226 // Returns the implementation-specific texture handle for this texture. |
220 void* TextureCairo::GetTextureHandle() const { | 227 void* TextureCairo::GetTextureHandle() const { |
221 NOTIMPLEMENTED(); | 228 NOTIMPLEMENTED(); |
222 return reinterpret_cast<void*>(NULL); | 229 return reinterpret_cast<void*>(NULL); |
223 } | 230 } |
224 | 231 |
225 } // namespace o2d | 232 } // namespace o2d |
226 | 233 |
227 } // namespace o3d | 234 } // namespace o3d |
OLD | NEW |