| 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 #include "examples/bitmap_uploader/bitmap_uploader.h" | 5 #include "examples/bitmap_uploader/bitmap_uploader.h" |
| 6 | 6 |
| 7 #ifndef GL_GLEXT_PROTOTYPES | 7 #ifndef GL_GLEXT_PROTOTYPES |
| 8 #define GL_GLEXT_PROTOTYPES | 8 #define GL_GLEXT_PROTOTYPES |
| 9 #endif // GL_GLEXT_PROTOTYPES | 9 #endif // GL_GLEXT_PROTOTYPES |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 &((*bitmap_)[0])); | 144 &((*bitmap_)[0])); |
| 145 | 145 |
| 146 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 146 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
| 147 glGenMailboxCHROMIUM(mailbox); | 147 glGenMailboxCHROMIUM(mailbox); |
| 148 glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); | 148 glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); |
| 149 GLuint sync_point = glInsertSyncPointCHROMIUM(); | 149 GLuint sync_point = glInsertSyncPointCHROMIUM(); |
| 150 | 150 |
| 151 TransferableResourcePtr resource = TransferableResource::New(); | 151 TransferableResourcePtr resource = TransferableResource::New(); |
| 152 resource->id = next_resource_id_++; | 152 resource->id = next_resource_id_++; |
| 153 resource_to_texture_id_map_[resource->id] = texture_id; | 153 resource_to_texture_id_map_[resource->id] = texture_id; |
| 154 resource->format = mojo::RESOURCE_FORMAT_RGBA_8888; | 154 resource->format = mojo::ResourceFormat::RGBA_8888; |
| 155 resource->filter = GL_LINEAR; | 155 resource->filter = GL_LINEAR; |
| 156 resource->size = bitmap_size.Clone(); | 156 resource->size = bitmap_size.Clone(); |
| 157 MailboxHolderPtr mailbox_holder = MailboxHolder::New(); | 157 MailboxHolderPtr mailbox_holder = MailboxHolder::New(); |
| 158 mailbox_holder->mailbox = Mailbox::New(); | 158 mailbox_holder->mailbox = Mailbox::New(); |
| 159 for (int i = 0; i < GL_MAILBOX_SIZE_CHROMIUM; ++i) | 159 for (int i = 0; i < GL_MAILBOX_SIZE_CHROMIUM; ++i) |
| 160 mailbox_holder->mailbox->name.push_back(mailbox[i]); | 160 mailbox_holder->mailbox->name.push_back(mailbox[i]); |
| 161 mailbox_holder->texture_target = GL_TEXTURE_2D; | 161 mailbox_holder->texture_target = GL_TEXTURE_2D; |
| 162 mailbox_holder->sync_point = sync_point; | 162 mailbox_holder->sync_point = sync_point; |
| 163 resource->mailbox_holder = mailbox_holder.Pass(); | 163 resource->mailbox_holder = mailbox_holder.Pass(); |
| 164 resource->is_repeated = false; | 164 resource->is_repeated = false; |
| 165 resource->is_software = false; | 165 resource->is_software = false; |
| 166 | 166 |
| 167 QuadPtr quad = Quad::New(); | 167 QuadPtr quad = Quad::New(); |
| 168 quad->material = MATERIAL_TEXTURE_CONTENT; | 168 quad->material = Material::TEXTURE_CONTENT; |
| 169 | 169 |
| 170 RectPtr rect = Rect::New(); | 170 RectPtr rect = Rect::New(); |
| 171 if (width_ <= size.width && height_ <= size.height) { | 171 if (width_ <= size.width && height_ <= size.height) { |
| 172 rect->width = width_; | 172 rect->width = width_; |
| 173 rect->height = height_; | 173 rect->height = height_; |
| 174 } else { | 174 } else { |
| 175 // The source bitmap is larger than the viewport. Resize it while | 175 // The source bitmap is larger than the viewport. Resize it while |
| 176 // maintaining the aspect ratio. | 176 // maintaining the aspect ratio. |
| 177 float width_ratio = static_cast<float>(width_) / size.width; | 177 float width_ratio = static_cast<float>(width_) / size.width; |
| 178 float height_ratio = static_cast<float>(height_) / size.height; | 178 float height_ratio = static_cast<float>(height_) / size.height; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 203 texture_state->vertex_opacity.push_back(1.f); | 203 texture_state->vertex_opacity.push_back(1.f); |
| 204 texture_state->flipped = false; | 204 texture_state->flipped = false; |
| 205 | 205 |
| 206 frame->resources.push_back(resource.Pass()); | 206 frame->resources.push_back(resource.Pass()); |
| 207 quad->texture_quad_state = texture_state.Pass(); | 207 quad->texture_quad_state = texture_state.Pass(); |
| 208 pass->quads.push_back(quad.Pass()); | 208 pass->quads.push_back(quad.Pass()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 if (color_ != TRANSPARENT_COLOR) { | 211 if (color_ != TRANSPARENT_COLOR) { |
| 212 QuadPtr quad = Quad::New(); | 212 QuadPtr quad = Quad::New(); |
| 213 quad->material = MATERIAL_SOLID_COLOR; | 213 quad->material = Material::SOLID_COLOR; |
| 214 quad->rect = bounds.Clone(); | 214 quad->rect = bounds.Clone(); |
| 215 quad->opaque_rect = Rect::New(); | 215 quad->opaque_rect = Rect::New(); |
| 216 quad->visible_rect = bounds.Clone(); | 216 quad->visible_rect = bounds.Clone(); |
| 217 quad->needs_blending = true; | 217 quad->needs_blending = true; |
| 218 quad->shared_quad_state_index = 0u; | 218 quad->shared_quad_state_index = 0u; |
| 219 | 219 |
| 220 SolidColorQuadStatePtr color_state = SolidColorQuadState::New(); | 220 SolidColorQuadStatePtr color_state = SolidColorQuadState::New(); |
| 221 color_state->color = Color::New(); | 221 color_state->color = Color::New(); |
| 222 color_state->color->rgba = color_; | 222 color_state->color->rgba = color_; |
| 223 color_state->force_anti_aliasing_off = false; | 223 color_state->force_anti_aliasing_off = false; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 0); | 267 0); |
| 268 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 268 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 269 return texture; | 269 return texture; |
| 270 } | 270 } |
| 271 | 271 |
| 272 uint32_t BitmapUploader::TextureFormat() { | 272 uint32_t BitmapUploader::TextureFormat() { |
| 273 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA; | 273 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA; |
| 274 } | 274 } |
| 275 | 275 |
| 276 } // namespace mojo | 276 } // namespace mojo |
| OLD | NEW |