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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 gpu::Mailbox mailbox; | 106 gpu::Mailbox mailbox; |
107 gl->GenMailboxCHROMIUM(mailbox.name); | 107 gl->GenMailboxCHROMIUM(mailbox.name); |
108 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 108 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
109 | 109 |
110 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 110 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
111 gl->ShallowFlushCHROMIUM(); | 111 gl->ShallowFlushCHROMIUM(); |
112 | 112 |
113 gpu::SyncToken sync_token; | 113 gpu::SyncToken sync_token; |
114 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 114 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
115 | 115 |
116 mus::mojom::TransferableResourcePtr resource = | 116 cc::TransferableResource resource; |
117 mus::mojom::TransferableResource::New(); | 117 resource.id = next_resource_id_++; |
118 resource->id = next_resource_id_++; | 118 resource_to_texture_id_map_[resource.id] = texture_id; |
119 resource_to_texture_id_map_[resource->id] = texture_id; | 119 resource.format = cc::ResourceFormat::RGBA_8888; |
120 resource->format = mus::mojom::ResourceFormat::RGBA_8888; | 120 resource.filter = GL_LINEAR; |
121 resource->filter = GL_LINEAR; | 121 resource.size = bitmap_size; |
122 resource->size = bitmap_size; | 122 resource.mailbox_holder = |
123 resource->mailbox_holder = | |
124 gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D); | 123 gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D); |
125 resource->read_lock_fences_enabled = false; | 124 resource.read_lock_fences_enabled = false; |
126 resource->is_software = false; | 125 resource.is_software = false; |
127 resource->is_overlay_candidate = false; | 126 resource.is_overlay_candidate = false; |
128 | 127 |
129 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); | 128 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); |
130 quad->material = mus::mojom::Material::TEXTURE_CONTENT; | 129 quad->material = mus::mojom::Material::TEXTURE_CONTENT; |
131 | 130 |
132 gfx::Size rect_size; | 131 gfx::Size rect_size; |
133 if (width_ <= bounds.width() && height_ <= bounds.height()) { | 132 if (width_ <= bounds.width() && height_ <= bounds.height()) { |
134 rect_size.SetSize(width_, height_); | 133 rect_size.SetSize(width_, height_); |
135 } else { | 134 } else { |
136 // The source bitmap is larger than the viewport. Resize it while | 135 // The source bitmap is larger than the viewport. Resize it while |
137 // maintaining the aspect ratio. | 136 // maintaining the aspect ratio. |
138 float width_ratio = static_cast<float>(width_) / bounds.width(); | 137 float width_ratio = static_cast<float>(width_) / bounds.width(); |
139 float height_ratio = static_cast<float>(height_) / bounds.height(); | 138 float height_ratio = static_cast<float>(height_) / bounds.height(); |
140 if (width_ratio > height_ratio) { | 139 if (width_ratio > height_ratio) { |
141 rect_size.SetSize(bounds.width(), height_ / width_ratio); | 140 rect_size.SetSize(bounds.width(), height_ / width_ratio); |
142 } else { | 141 } else { |
143 rect_size.SetSize(width_ / height_ratio, bounds.height()); | 142 rect_size.SetSize(width_ / height_ratio, bounds.height()); |
144 } | 143 } |
145 } | 144 } |
146 gfx::Rect rect(rect_size); | 145 gfx::Rect rect(rect_size); |
147 quad->rect = rect; | 146 quad->rect = rect; |
148 quad->opaque_rect = rect; | 147 quad->opaque_rect = rect; |
149 quad->visible_rect = rect; | 148 quad->visible_rect = rect; |
150 quad->needs_blending = true; | 149 quad->needs_blending = true; |
151 quad->shared_quad_state_index = 0u; | 150 quad->shared_quad_state_index = 0u; |
152 | 151 |
153 mus::mojom::TextureQuadStatePtr texture_state = | 152 mus::mojom::TextureQuadStatePtr texture_state = |
154 mus::mojom::TextureQuadState::New(); | 153 mus::mojom::TextureQuadState::New(); |
155 texture_state->resource_id = resource->id; | 154 texture_state->resource_id = resource.id; |
156 texture_state->premultiplied_alpha = true; | 155 texture_state->premultiplied_alpha = true; |
157 texture_state->uv_top_left.SetPoint(0.f, 0.f); | 156 texture_state->uv_top_left.SetPoint(0.f, 0.f); |
158 texture_state->uv_bottom_right.SetPoint(1.f, 1.f); | 157 texture_state->uv_bottom_right.SetPoint(1.f, 1.f); |
159 texture_state->background_color = mus::mojom::Color::New(); | 158 texture_state->background_color = mus::mojom::Color::New(); |
160 texture_state->background_color->rgba = g_transparent_color; | 159 texture_state->background_color->rgba = g_transparent_color; |
161 for (int i = 0; i < 4; ++i) | 160 for (int i = 0; i < 4; ++i) |
162 texture_state->vertex_opacity.push_back(1.f); | 161 texture_state->vertex_opacity.push_back(1.f); |
163 texture_state->y_flipped = false; | 162 texture_state->y_flipped = false; |
164 | 163 |
165 frame->resources.push_back(std::move(resource)); | 164 frame->resources.push_back(std::move(resource)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 DCHECK_EQ(1, resource.count); | 218 DCHECK_EQ(1, resource.count); |
220 gl->WaitSyncTokenCHROMIUM(resource.sync_token.GetConstData()); | 219 gl->WaitSyncTokenCHROMIUM(resource.sync_token.GetConstData()); |
221 uint32_t texture_id = resource_to_texture_id_map_[resource.id]; | 220 uint32_t texture_id = resource_to_texture_id_map_[resource.id]; |
222 DCHECK_NE(0u, texture_id); | 221 DCHECK_NE(0u, texture_id); |
223 resource_to_texture_id_map_.erase(resource.id); | 222 resource_to_texture_id_map_.erase(resource.id); |
224 gl->DeleteTextures(1, &texture_id); | 223 gl->DeleteTextures(1, &texture_id); |
225 } | 224 } |
226 } | 225 } |
227 | 226 |
228 } // namespace bitmap_uploader | 227 } // namespace bitmap_uploader |
OLD | NEW |