| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 goto fail1; | 107 goto fail1; |
| 108 } | 108 } |
| 109 image_surface_context = cairo_create(image_surface); | 109 image_surface_context = cairo_create(image_surface); |
| 110 status = cairo_status(image_surface_context); | 110 status = cairo_status(image_surface_context); |
| 111 if (CAIRO_STATUS_SUCCESS != status) { | 111 if (CAIRO_STATUS_SUCCESS != status) { |
| 112 DLOG(ERROR) << "Error creating Cairo image surface draw context: " | 112 DLOG(ERROR) << "Error creating Cairo image surface draw context: " |
| 113 << status; | 113 << status; |
| 114 goto fail2; | 114 goto fail2; |
| 115 } | 115 } |
| 116 | 116 |
| 117 cairo_set_operator(image_surface_context, CAIRO_OPERATOR_SOURCE); |
| 118 |
| 117 return new TextureCairo(service_locator, | 119 return new TextureCairo(service_locator, |
| 118 image_surface, | 120 image_surface, |
| 119 image_surface_context, | 121 image_surface_context, |
| 120 format, | 122 format, |
| 121 levels, | 123 levels, |
| 122 width, | 124 width, |
| 123 height, | 125 height, |
| 124 enable_render_surfaces); | 126 enable_render_surfaces); |
| 125 | 127 |
| 126 fail2: | 128 fail2: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 147 // Set the image data to the renderer | 149 // Set the image data to the renderer |
| 148 void TextureCairo::SetRect(int level, | 150 void TextureCairo::SetRect(int level, |
| 149 unsigned dst_left, | 151 unsigned dst_left, |
| 150 unsigned dst_top, | 152 unsigned dst_top, |
| 151 unsigned src_width, | 153 unsigned src_width, |
| 152 unsigned src_height, | 154 unsigned src_height, |
| 153 const void* src_data, | 155 const void* src_data, |
| 154 int src_pitch) { | 156 int src_pitch) { |
| 155 DLOG(INFO) << "Texture2DCairo SetRect"; | 157 DLOG(INFO) << "Texture2DCairo SetRect"; |
| 156 | 158 |
| 159 if (0 != level) { |
| 160 // Cairo does not support/need mip-maps. |
| 161 return; |
| 162 } |
| 163 |
| 157 // Create image surface to represent the source. | 164 // Create image surface to represent the source. |
| 158 cairo_surface_t* source_image_surface = cairo_image_surface_create_for_data( | 165 cairo_surface_t* source_image_surface = cairo_image_surface_create_for_data( |
| 159 const_cast<unsigned char*>( | 166 const_cast<unsigned char*>( |
| 160 static_cast<const unsigned char*>(src_data)), | 167 static_cast<const unsigned char*>(src_data)), |
| 161 cairo_image_surface_get_format(image_surface_), | 168 cairo_image_surface_get_format(image_surface_), |
| 162 src_width, | 169 src_width, |
| 163 src_height, | 170 src_height, |
| 164 src_pitch); | 171 src_pitch); |
| 165 | 172 |
| 166 // Set that surface as the source for paint operations to our texture. | 173 // Set that surface as the source for paint operations to our texture. |
| 167 cairo_set_source_surface(image_surface_context_, | 174 cairo_set_source_surface(image_surface_context_, |
| 168 source_image_surface, | 175 source_image_surface, |
| 169 dst_left, | 176 dst_left, |
| 170 dst_top); | 177 dst_top); |
| 171 | 178 |
| 172 // Paint to the texture. This copies the data. | 179 // Paint to the texture. This copies the data. |
| 173 cairo_paint(image_surface_context_); | 180 cairo_paint(image_surface_context_); |
| 174 | 181 |
| 175 // Discard our reference to the source surface. | 182 // Discard our reference to the source surface. |
| 176 cairo_surface_destroy(source_image_surface); | 183 cairo_surface_destroy(source_image_surface); |
| 177 | 184 |
| 178 if (level == 0) { | 185 TextureUpdated(); |
| 179 TextureUpdated(); | |
| 180 } | |
| 181 } | 186 } |
| 182 | 187 |
| 183 // Locks the given mipmap level of this texture for loading from main memory, | 188 // Locks the given mipmap level of this texture for loading from main memory, |
| 184 // and returns a pointer to the buffer. | 189 // and returns a pointer to the buffer. |
| 185 bool TextureCairo::PlatformSpecificLock( | 190 bool TextureCairo::PlatformSpecificLock( |
| 186 int level, void** data, int* pitch, Texture::AccessMode mode) { | 191 int level, void** data, int* pitch, Texture::AccessMode mode) { |
| 187 NOTIMPLEMENTED(); | 192 NOTIMPLEMENTED(); |
| 188 return true; | 193 return true; |
| 189 } | 194 } |
| 190 | 195 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 207 | 212 |
| 208 // Returns the implementation-specific texture handle for this texture. | 213 // Returns the implementation-specific texture handle for this texture. |
| 209 void* TextureCairo::GetTextureHandle() const { | 214 void* TextureCairo::GetTextureHandle() const { |
| 210 NOTIMPLEMENTED(); | 215 NOTIMPLEMENTED(); |
| 211 return reinterpret_cast<void*>(NULL); | 216 return reinterpret_cast<void*>(NULL); |
| 212 } | 217 } |
| 213 | 218 |
| 214 } // namespace o2d | 219 } // namespace o2d |
| 215 | 220 |
| 216 } // namespace o3d | 221 } // namespace o3d |
| OLD | NEW |