OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" |
| 6 |
| 7 #include "cc/output/compositor_frame.h" |
| 8 #include "cc/output/delegated_frame_data.h" |
| 9 #include "cc/quads/render_pass.h" |
| 10 #include "cc/quads/shared_quad_state.h" |
| 11 #include "cc/quads/solid_color_draw_quad.h" |
| 12 #include "public/platform/InterfaceProvider.h" |
| 13 #include "public/platform/Platform.h" |
| 14 #include "third_party/skia/include/core/SkColor.h" |
| 15 #include "third_party/skia/include/core/SkXfermode.h" |
| 16 #include "ui/gfx/geometry/rect.h" |
| 17 #include "ui/gfx/transform.h" |
| 18 |
| 19 namespace blink { |
| 20 |
| 21 OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl(uint32_t
clientId, uint32_t localId, uint64_t nonce, int width, int height) |
| 22 : m_surfaceId(cc::SurfaceId(clientId, localId, nonce)) |
| 23 , m_width(width) |
| 24 , m_height(height) |
| 25 { |
| 26 DCHECK(!m_service.is_bound()); |
| 27 Platform::current()->interfaceProvider()->getInterface(mojo::GetProxy(&m_ser
vice)); |
| 28 } |
| 29 |
| 30 void OffscreenCanvasFrameDispatcherImpl::dispatchFrame() |
| 31 { |
| 32 // TODO(563852/xlai): Currently this is just a simple solid-color compositor |
| 33 // frame. We need to update this function to extract the image data from can
vas. |
| 34 cc::CompositorFrame frame; |
| 35 frame.metadata.device_scale_factor = 1.0f; |
| 36 frame.delegated_frame_data.reset(new cc::DelegatedFrameData); |
| 37 |
| 38 const gfx::Rect bounds(m_width, m_height); |
| 39 const cc::RenderPassId renderPassId(1, 1); |
| 40 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); |
| 41 pass->SetAll(renderPassId, bounds, bounds, gfx::Transform(), false); |
| 42 |
| 43 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 44 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, SkX
fermode::kSrcOver_Mode, 0); |
| 45 |
| 46 cc::SolidColorDrawQuad* quad = pass->CreateAndAppendDrawQuad<cc::SolidColorD
rawQuad>(); |
| 47 const bool forceAntialiasingOff = false; |
| 48 quad->SetNew(sqs, bounds, bounds, SK_ColorGREEN, forceAntialiasingOff); |
| 49 |
| 50 frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| 51 |
| 52 m_service->SubmitCompositorFrame(m_surfaceId, std::move(frame)); |
| 53 } |
| 54 |
| 55 } // namespace blink |
OLD | NEW |