OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/bitmap_uploader/bitmap_uploader.h" | 5 #include "components/bitmap_uploader/bitmap_uploader.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 next_resource_id_(1u), | 45 next_resource_id_(1u), |
46 id_namespace_(0u), | 46 id_namespace_(0u), |
47 local_id_(0u), | 47 local_id_(0u), |
48 surface_client_binding_(this) {} | 48 surface_client_binding_(this) {} |
49 | 49 |
50 BitmapUploader::~BitmapUploader() { | 50 BitmapUploader::~BitmapUploader() { |
51 MojoGLES2DestroyContext(gles2_context_); | 51 MojoGLES2DestroyContext(gles2_context_); |
52 } | 52 } |
53 | 53 |
54 void BitmapUploader::Init(mojo::Shell* shell) { | 54 void BitmapUploader::Init(mojo::Shell* shell) { |
55 surface_ = window_->RequestSurface(mus::mojom::SURFACE_TYPE_DEFAULT); | 55 surface_ = window_->RequestSurface(mus::mojom::SurfaceType::DEFAULT); |
56 surface_->BindToThread(); | 56 surface_->BindToThread(); |
57 | 57 |
58 mojo::ServiceProviderPtr gpu_service_provider; | 58 mojo::ServiceProviderPtr gpu_service_provider; |
59 mojo::URLRequestPtr request2(mojo::URLRequest::New()); | 59 mojo::URLRequestPtr request2(mojo::URLRequest::New()); |
60 request2->url = mojo::String::From("mojo:mus"); | 60 request2->url = mojo::String::From("mojo:mus"); |
61 shell->ConnectToApplication(std::move(request2), | 61 shell->ConnectToApplication(std::move(request2), |
62 mojo::GetProxy(&gpu_service_provider), nullptr, | 62 mojo::GetProxy(&gpu_service_provider), nullptr, |
63 mojo::CreatePermissiveCapabilityFilter(), | 63 mojo::CreatePermissiveCapabilityFilter(), |
64 base::Bind(&OnGotContentHandlerID)); | 64 base::Bind(&OnGotContentHandlerID)); |
65 ConnectToService(gpu_service_provider.get(), &gpu_service_); | 65 ConnectToService(gpu_service_provider.get(), &gpu_service_); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 131 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
132 glGenMailboxCHROMIUM(mailbox); | 132 glGenMailboxCHROMIUM(mailbox); |
133 glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); | 133 glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); |
134 gpu::SyncToken sync_token(glInsertSyncPointCHROMIUM()); | 134 gpu::SyncToken sync_token(glInsertSyncPointCHROMIUM()); |
135 | 135 |
136 mus::mojom::TransferableResourcePtr resource = | 136 mus::mojom::TransferableResourcePtr resource = |
137 mus::mojom::TransferableResource::New(); | 137 mus::mojom::TransferableResource::New(); |
138 resource->id = next_resource_id_++; | 138 resource->id = next_resource_id_++; |
139 resource_to_texture_id_map_[resource->id] = texture_id; | 139 resource_to_texture_id_map_[resource->id] = texture_id; |
140 resource->format = mus::mojom::RESOURCE_FORMAT_RGBA_8888; | 140 resource->format = mus::mojom::ResourceFormat::RGBA_8888; |
141 resource->filter = GL_LINEAR; | 141 resource->filter = GL_LINEAR; |
142 resource->size = bitmap_size.Clone(); | 142 resource->size = bitmap_size.Clone(); |
143 mus::mojom::MailboxHolderPtr mailbox_holder = | 143 mus::mojom::MailboxHolderPtr mailbox_holder = |
144 mus::mojom::MailboxHolder::New(); | 144 mus::mojom::MailboxHolder::New(); |
145 mailbox_holder->mailbox = mus::mojom::Mailbox::New(); | 145 mailbox_holder->mailbox = mus::mojom::Mailbox::New(); |
146 for (int i = 0; i < GL_MAILBOX_SIZE_CHROMIUM; ++i) | 146 for (int i = 0; i < GL_MAILBOX_SIZE_CHROMIUM; ++i) |
147 mailbox_holder->mailbox->name.push_back(mailbox[i]); | 147 mailbox_holder->mailbox->name.push_back(mailbox[i]); |
148 mailbox_holder->texture_target = GL_TEXTURE_2D; | 148 mailbox_holder->texture_target = GL_TEXTURE_2D; |
149 mailbox_holder->sync_token = | 149 mailbox_holder->sync_token = |
150 mus::mojom::SyncToken::From<gpu::SyncToken>(sync_token); | 150 mus::mojom::SyncToken::From<gpu::SyncToken>(sync_token); |
151 resource->mailbox_holder = std::move(mailbox_holder); | 151 resource->mailbox_holder = std::move(mailbox_holder); |
152 resource->is_repeated = false; | 152 resource->is_repeated = false; |
153 resource->is_software = false; | 153 resource->is_software = false; |
154 | 154 |
155 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); | 155 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); |
156 quad->material = mus::mojom::MATERIAL_TEXTURE_CONTENT; | 156 quad->material = mus::mojom::Material::TEXTURE_CONTENT; |
157 | 157 |
158 mojo::RectPtr rect = mojo::Rect::New(); | 158 mojo::RectPtr rect = mojo::Rect::New(); |
159 if (width_ <= bounds.width() && height_ <= bounds.height()) { | 159 if (width_ <= bounds.width() && height_ <= bounds.height()) { |
160 rect->width = width_; | 160 rect->width = width_; |
161 rect->height = height_; | 161 rect->height = height_; |
162 } else { | 162 } else { |
163 // The source bitmap is larger than the viewport. Resize it while | 163 // The source bitmap is larger than the viewport. Resize it while |
164 // maintaining the aspect ratio. | 164 // maintaining the aspect ratio. |
165 float width_ratio = static_cast<float>(width_) / bounds.width(); | 165 float width_ratio = static_cast<float>(width_) / bounds.width(); |
166 float height_ratio = static_cast<float>(height_) / bounds.height(); | 166 float height_ratio = static_cast<float>(height_) / bounds.height(); |
(...skipping 25 matching lines...) Expand all Loading... |
192 texture_state->vertex_opacity.push_back(1.f); | 192 texture_state->vertex_opacity.push_back(1.f); |
193 texture_state->y_flipped = false; | 193 texture_state->y_flipped = false; |
194 | 194 |
195 frame->resources.push_back(std::move(resource)); | 195 frame->resources.push_back(std::move(resource)); |
196 quad->texture_quad_state = std::move(texture_state); | 196 quad->texture_quad_state = std::move(texture_state); |
197 pass->quads.push_back(std::move(quad)); | 197 pass->quads.push_back(std::move(quad)); |
198 } | 198 } |
199 | 199 |
200 if (color_ != g_transparent_color) { | 200 if (color_ != g_transparent_color) { |
201 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); | 201 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); |
202 quad->material = mus::mojom::MATERIAL_SOLID_COLOR; | 202 quad->material = mus::mojom::Material::SOLID_COLOR; |
203 quad->rect = mojo::Rect::From(bounds); | 203 quad->rect = mojo::Rect::From(bounds); |
204 quad->opaque_rect = mojo::Rect::New(); | 204 quad->opaque_rect = mojo::Rect::New(); |
205 quad->visible_rect = mojo::Rect::From(bounds); | 205 quad->visible_rect = mojo::Rect::From(bounds); |
206 quad->needs_blending = true; | 206 quad->needs_blending = true; |
207 quad->shared_quad_state_index = 0u; | 207 quad->shared_quad_state_index = 0u; |
208 | 208 |
209 mus::mojom::SolidColorQuadStatePtr color_state = | 209 mus::mojom::SolidColorQuadStatePtr color_state = |
210 mus::mojom::SolidColorQuadState::New(); | 210 mus::mojom::SolidColorQuadState::New(); |
211 color_state->color = mus::mojom::Color::New(); | 211 color_state->color = mus::mojom::Color::New(); |
212 color_state->color->rgba = color_; | 212 color_state->color->rgba = color_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 glWaitSyncTokenCHROMIUM( | 256 glWaitSyncTokenCHROMIUM( |
257 resource->sync_token.To<gpu::SyncToken>().GetConstData()); | 257 resource->sync_token.To<gpu::SyncToken>().GetConstData()); |
258 uint32_t texture_id = resource_to_texture_id_map_[resource->id]; | 258 uint32_t texture_id = resource_to_texture_id_map_[resource->id]; |
259 DCHECK_NE(0u, texture_id); | 259 DCHECK_NE(0u, texture_id); |
260 resource_to_texture_id_map_.erase(resource->id); | 260 resource_to_texture_id_map_.erase(resource->id); |
261 glDeleteTextures(1, &texture_id); | 261 glDeleteTextures(1, &texture_id); |
262 } | 262 } |
263 } | 263 } |
264 | 264 |
265 } // namespace bitmap_uploader | 265 } // namespace bitmap_uploader |
OLD | NEW |