Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: components/bitmap_uploader/bitmap_uploader.cc

Issue 2056483002: Move quads.mojom from Mus to cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/ipc/quads.mojom ('k') | components/mus/public/cpp/surfaces/custom_surface_converter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 width_ = width; 64 width_ = width;
65 height_ = height; 65 height_ = height;
66 bitmap_ = std::move(data); 66 bitmap_ = std::move(data);
67 format_ = format; 67 format_ = format;
68 if (surface_) 68 if (surface_)
69 Upload(); 69 Upload();
70 } 70 }
71 71
72 void BitmapUploader::Upload() { 72 void BitmapUploader::Upload() {
73 const gfx::Rect bounds(window_->bounds()); 73 const gfx::Rect bounds(window_->bounds());
74 mus::mojom::PassPtr pass = mojo::CreateDefaultPass(1, bounds); 74 cc::mojom::RenderPassPtr pass = mojo::CreateDefaultPass(1, bounds);
75 mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New(); 75 mus::mojom::CompositorFramePtr frame = mus::mojom::CompositorFrame::New();
76 76
77 // TODO(rjkroege): Support device scale factor in PDF viewer 77 // TODO(rjkroege): Support device scale factor in PDF viewer
78 frame->metadata.device_scale_factor = 1.0f; 78 frame->metadata.device_scale_factor = 1.0f;
79 79
80 frame->resources.resize(0u); 80 frame->resources.resize(0u);
81 81
82 pass->quads.resize(0u); 82 pass->quads.resize(0u);
83 pass->shared_quad_states.push_back(mojo::CreateDefaultSQS(bounds.size())); 83 pass->shared_quad_states.push_back(mojo::CreateDefaultSQS(bounds.size()));
84 84
(...skipping 20 matching lines...) Expand all
105 resource_to_texture_id_map_[resource.id] = texture_id; 105 resource_to_texture_id_map_[resource.id] = texture_id;
106 resource.format = cc::ResourceFormat::RGBA_8888; 106 resource.format = cc::ResourceFormat::RGBA_8888;
107 resource.filter = GL_LINEAR; 107 resource.filter = GL_LINEAR;
108 resource.size = bitmap_size; 108 resource.size = bitmap_size;
109 resource.mailbox_holder = 109 resource.mailbox_holder =
110 gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D); 110 gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D);
111 resource.read_lock_fences_enabled = false; 111 resource.read_lock_fences_enabled = false;
112 resource.is_software = false; 112 resource.is_software = false;
113 resource.is_overlay_candidate = false; 113 resource.is_overlay_candidate = false;
114 114
115 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); 115 cc::mojom::DrawQuadPtr quad = cc::mojom::DrawQuad::New();
116 quad->material = mus::mojom::Material::TEXTURE_CONTENT; 116 quad->material = cc::mojom::Material::TEXTURE_CONTENT;
117 117
118 gfx::Size rect_size; 118 gfx::Size rect_size;
119 if (width_ <= bounds.width() && height_ <= bounds.height()) { 119 if (width_ <= bounds.width() && height_ <= bounds.height()) {
120 rect_size.SetSize(width_, height_); 120 rect_size.SetSize(width_, height_);
121 } else { 121 } else {
122 // The source bitmap is larger than the viewport. Resize it while 122 // The source bitmap is larger than the viewport. Resize it while
123 // maintaining the aspect ratio. 123 // maintaining the aspect ratio.
124 float width_ratio = static_cast<float>(width_) / bounds.width(); 124 float width_ratio = static_cast<float>(width_) / bounds.width();
125 float height_ratio = static_cast<float>(height_) / bounds.height(); 125 float height_ratio = static_cast<float>(height_) / bounds.height();
126 if (width_ratio > height_ratio) { 126 if (width_ratio > height_ratio) {
127 rect_size.SetSize(bounds.width(), height_ / width_ratio); 127 rect_size.SetSize(bounds.width(), height_ / width_ratio);
128 } else { 128 } else {
129 rect_size.SetSize(width_ / height_ratio, bounds.height()); 129 rect_size.SetSize(width_ / height_ratio, bounds.height());
130 } 130 }
131 } 131 }
132 gfx::Rect rect(rect_size); 132 gfx::Rect rect(rect_size);
133 quad->rect = rect; 133 quad->rect = rect;
134 quad->opaque_rect = rect; 134 quad->opaque_rect = rect;
135 quad->visible_rect = rect; 135 quad->visible_rect = rect;
136 quad->needs_blending = true; 136 quad->needs_blending = true;
137 quad->shared_quad_state_index = 0u; 137 quad->shared_quad_state_index = 0u;
138 138
139 mus::mojom::TextureQuadStatePtr texture_state = 139 cc::mojom::TextureQuadStatePtr texture_state =
140 mus::mojom::TextureQuadState::New(); 140 cc::mojom::TextureQuadState::New();
141 texture_state->resource_id = resource.id; 141 texture_state->resource_id = resource.id;
142 texture_state->premultiplied_alpha = true; 142 texture_state->premultiplied_alpha = true;
143 texture_state->uv_top_left.SetPoint(0.f, 0.f); 143 texture_state->uv_top_left.SetPoint(0.f, 0.f);
144 texture_state->uv_bottom_right.SetPoint(1.f, 1.f); 144 texture_state->uv_bottom_right.SetPoint(1.f, 1.f);
145 texture_state->background_color = mus::mojom::Color::New(); 145 texture_state->background_color = cc::mojom::Color::New();
146 texture_state->background_color->rgba = g_transparent_color; 146 texture_state->background_color->rgba = g_transparent_color;
147 for (int i = 0; i < 4; ++i) 147 for (int i = 0; i < 4; ++i)
148 texture_state->vertex_opacity.push_back(1.f); 148 texture_state->vertex_opacity.push_back(1.f);
149 texture_state->y_flipped = false; 149 texture_state->y_flipped = false;
150 150
151 frame->resources.push_back(std::move(resource)); 151 frame->resources.push_back(std::move(resource));
152 quad->texture_quad_state = std::move(texture_state); 152 quad->texture_quad_state = std::move(texture_state);
153 pass->quads.push_back(std::move(quad)); 153 pass->quads.push_back(std::move(quad));
154 } 154 }
155 155
156 if (color_ != g_transparent_color) { 156 if (color_ != g_transparent_color) {
157 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); 157 cc::mojom::DrawQuadPtr quad = cc::mojom::DrawQuad::New();
158 quad->material = mus::mojom::Material::SOLID_COLOR; 158 quad->material = cc::mojom::Material::SOLID_COLOR;
159 quad->rect = bounds; 159 quad->rect = bounds;
160 quad->visible_rect = bounds; 160 quad->visible_rect = bounds;
161 quad->needs_blending = true; 161 quad->needs_blending = true;
162 quad->shared_quad_state_index = 0u; 162 quad->shared_quad_state_index = 0u;
163 163
164 mus::mojom::SolidColorQuadStatePtr color_state = 164 cc::mojom::SolidColorQuadStatePtr color_state =
165 mus::mojom::SolidColorQuadState::New(); 165 cc::mojom::SolidColorQuadState::New();
166 color_state->color = mus::mojom::Color::New(); 166 color_state->color = cc::mojom::Color::New();
167 color_state->color->rgba = color_; 167 color_state->color->rgba = color_;
168 color_state->force_anti_aliasing_off = false; 168 color_state->force_anti_aliasing_off = false;
169 169
170 quad->solid_color_quad_state = std::move(color_state); 170 quad->solid_color_quad_state = std::move(color_state);
171 pass->quads.push_back(std::move(quad)); 171 pass->quads.push_back(std::move(quad));
172 } 172 }
173 173
174 frame->passes.push_back(std::move(pass)); 174 frame->passes.push_back(std::move(pass));
175 175
176 // TODO(rjkroege, fsamuel): We should throttle frames. 176 // TODO(rjkroege, fsamuel): We should throttle frames.
(...skipping 28 matching lines...) Expand all
205 DCHECK_EQ(1, resource.count); 205 DCHECK_EQ(1, resource.count);
206 gl->WaitSyncTokenCHROMIUM(resource.sync_token.GetConstData()); 206 gl->WaitSyncTokenCHROMIUM(resource.sync_token.GetConstData());
207 uint32_t texture_id = resource_to_texture_id_map_[resource.id]; 207 uint32_t texture_id = resource_to_texture_id_map_[resource.id];
208 DCHECK_NE(0u, texture_id); 208 DCHECK_NE(0u, texture_id);
209 resource_to_texture_id_map_.erase(resource.id); 209 resource_to_texture_id_map_.erase(resource.id);
210 gl->DeleteTextures(1, &texture_id); 210 gl->DeleteTextures(1, &texture_id);
211 } 211 }
212 } 212 }
213 213
214 } // namespace bitmap_uploader 214 } // namespace bitmap_uploader
OLDNEW
« no previous file with comments | « cc/ipc/quads.mojom ('k') | components/mus/public/cpp/surfaces/custom_surface_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698