| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/compositor/mus_browser_compositor_output_surface.h" | 5 #include "content/browser/compositor/mus_browser_compositor_output_surface.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/output_surface_frame.h" | 10 #include "cc/output/output_surface_frame.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {} | 41 MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {} |
| 42 | 42 |
| 43 void MusBrowserCompositorOutputSurface::SwapBuffers( | 43 void MusBrowserCompositorOutputSurface::SwapBuffers( |
| 44 cc::OutputSurfaceFrame frame) { | 44 cc::OutputSurfaceFrame frame) { |
| 45 const gfx::Rect bounds(ui_window_->bounds().size()); | 45 const gfx::Rect bounds(ui_window_->bounds().size()); |
| 46 cc::CompositorFrame ui_frame; | 46 cc::CompositorFrame ui_frame; |
| 47 ui_frame.metadata.latency_info = std::move(frame.latency_info); | 47 ui_frame.metadata.latency_info = std::move(frame.latency_info); |
| 48 // Reset latency_info to known empty state after moving contents. | 48 // Reset latency_info to known empty state after moving contents. |
| 49 frame.latency_info.clear(); | 49 frame.latency_info.clear(); |
| 50 ui_frame.delegated_frame_data = base::MakeUnique<cc::DelegatedFrameData>(); | |
| 51 const cc::RenderPassId render_pass_id(1, 1); | 50 const cc::RenderPassId render_pass_id(1, 1); |
| 52 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); | 51 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); |
| 53 const bool has_transparent_background = true; | 52 const bool has_transparent_background = true; |
| 54 pass->SetAll(render_pass_id, bounds, bounds, gfx::Transform(), | 53 pass->SetAll(render_pass_id, bounds, bounds, gfx::Transform(), |
| 55 has_transparent_background); | 54 has_transparent_background); |
| 56 // The SharedQuadState is owned by the SharedQuadStateList | 55 // The SharedQuadState is owned by the SharedQuadStateList |
| 57 // shared_quad_state_list. | 56 // shared_quad_state_list. |
| 58 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 57 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 59 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, | 58 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, |
| 60 false /* is_clipped */, 1.f /* opacity */, SkXfermode::kSrc_Mode, | 59 false /* is_clipped */, 1.f /* opacity */, SkXfermode::kSrc_Mode, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 81 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); | 80 const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); |
| 82 gl->ShallowFlushCHROMIUM(); | 81 gl->ShallowFlushCHROMIUM(); |
| 83 gpu::SyncToken sync_token; | 82 gpu::SyncToken sync_token; |
| 84 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 83 gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 85 | 84 |
| 86 resource.mailbox_holder = | 85 resource.mailbox_holder = |
| 87 gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D); | 86 gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D); |
| 88 resource.read_lock_fences_enabled = false; | 87 resource.read_lock_fences_enabled = false; |
| 89 resource.is_software = false; | 88 resource.is_software = false; |
| 90 resource.is_overlay_candidate = false; | 89 resource.is_overlay_candidate = false; |
| 91 ui_frame.delegated_frame_data->resource_list.push_back(std::move(resource)); | 90 ui_frame.resource_list.push_back(std::move(resource)); |
| 92 | 91 |
| 93 const bool needs_blending = true; | 92 const bool needs_blending = true; |
| 94 const bool premultiplied_alpha = true; | 93 const bool premultiplied_alpha = true; |
| 95 const gfx::PointF uv_top_left(0.f, 0.f); | 94 const gfx::PointF uv_top_left(0.f, 0.f); |
| 96 const gfx::PointF uv_bottom_right(1.f, 1.f); | 95 const gfx::PointF uv_bottom_right(1.f, 1.f); |
| 97 const uint32_t background_color = 0x00000000; | 96 const uint32_t background_color = 0x00000000; |
| 98 const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f}; | 97 const float vertex_opacity[4] = {1.f, 1.f, 1.f, 1.f}; |
| 99 const bool y_flipped = true; | 98 const bool y_flipped = true; |
| 100 const bool nearest_neighbor = false; | 99 const bool nearest_neighbor = false; |
| 101 const bool secure_output_only = false; | 100 const bool secure_output_only = false; |
| 102 | 101 |
| 103 cc::TextureDrawQuad* quad = | 102 cc::TextureDrawQuad* quad = |
| 104 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); | 103 pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>(); |
| 105 quad->SetAll(sqs, rect, rect, rect, needs_blending, resource.id, gfx::Size(), | 104 quad->SetAll(sqs, rect, rect, rect, needs_blending, resource.id, gfx::Size(), |
| 106 premultiplied_alpha, uv_top_left, uv_bottom_right, | 105 premultiplied_alpha, uv_top_left, uv_bottom_right, |
| 107 background_color, vertex_opacity, y_flipped, nearest_neighbor, | 106 background_color, vertex_opacity, y_flipped, nearest_neighbor, |
| 108 secure_output_only); | 107 secure_output_only); |
| 109 | 108 |
| 110 ui_frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); | 109 ui_frame.render_pass_list.push_back(std::move(pass)); |
| 111 ui_compositor_frame_sink_->SubmitCompositorFrame(std::move(ui_frame)); | 110 ui_compositor_frame_sink_->SubmitCompositorFrame(std::move(ui_frame)); |
| 112 return; | 111 return; |
| 113 } | 112 } |
| 114 | 113 |
| 115 void MusBrowserCompositorOutputSurface::SetBeginFrameSource( | 114 void MusBrowserCompositorOutputSurface::SetBeginFrameSource( |
| 116 cc::BeginFrameSource* source) {} | 115 cc::BeginFrameSource* source) {} |
| 117 | 116 |
| 118 void MusBrowserCompositorOutputSurface::ReclaimResources( | 117 void MusBrowserCompositorOutputSurface::ReclaimResources( |
| 119 const cc::ReturnedResourceArray& resources) { | 118 const cc::ReturnedResourceArray& resources) { |
| 120 for (const auto& resource : resources) { | 119 for (const auto& resource : resources) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 169 |
| 171 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( | 170 const gpu::Mailbox& MusBrowserCompositorOutputSurface::GetMailboxFromResourceId( |
| 172 uint32_t id) { | 171 uint32_t id) { |
| 173 DCHECK_LT(id, mailboxes_.size()); | 172 DCHECK_LT(id, mailboxes_.size()); |
| 174 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == | 173 DCHECK(std::find(free_resource_ids_.begin(), free_resource_ids_.end(), id) == |
| 175 free_resource_ids_.end()); | 174 free_resource_ids_.end()); |
| 176 return mailboxes_[id]; | 175 return mailboxes_[id]; |
| 177 } | 176 } |
| 178 | 177 |
| 179 } // namespace content | 178 } // namespace content |
| OLD | NEW |