Chromium Code Reviews| 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/delegated_frame_data.h" | |
| 8 #include "cc/quads/render_pass.h" | |
| 9 #include "cc/quads/shared_quad_state.h" | |
| 10 #include "cc/quads/solid_color_draw_quad.h" | |
| 11 #include "public/platform/InterfaceProvider.h" | |
| 12 #include "public/platform/Platform.h" | |
| 13 #include "third_party/skia/include/core/SkColor.h" | |
| 14 #include "third_party/skia/include/core/SkXfermode.h" | |
| 15 #include "ui/gfx/geometry/rect.h" | |
| 16 #include "ui/gfx/transform.h" | |
| 17 | |
| 18 namespace blink { | |
| 19 | |
| 20 OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl(uint32_t clientId, uint32_t localId, uint64_t nonce) | |
| 21 : m_surfaceId(cc::SurfaceId(clientId, localId, nonce)) | |
| 22 { | |
| 23 DCHECK(!m_service.is_bound()); | |
| 24 Platform::current()->interfaceProvider()->getInterface(mojo::GetProxy(&m_ser vice)); | |
| 25 } | |
| 26 | |
| 27 void OffscreenCanvasFrameDispatcherImpl::uploadImage(int width, int height) | |
|
danakj
2016/09/02 19:12:43
I thought width and height never change, why arent
Justin Novosad
2016/09/02 19:20:08
This is just temporary. Once we start pushing actu
danakj
2016/09/02 19:20:59
Do sizes change? Because then we have to deal with
xlai (Olivia)
2016/09/02 20:10:07
Made width and height to be const member in Offscr
| |
| 28 { | |
| 29 // TODO(563852): Currently this is just a simple solid-color compositor fram e. | |
| 30 // We need to update this function to extract the image data from canvas. | |
| 31 cc::CompositorFrame frame; | |
| 32 frame.metadata.device_scale_factor = 1.0f; | |
| 33 frame.delegated_frame_data.reset(new cc::DelegatedFrameData()); | |
|
danakj
2016/09/02 19:12:42
nit: no () needed
xlai (Olivia)
2016/09/02 20:10:07
Done.
| |
| 34 frame.delegated_frame_data->resource_list.resize(0u); | |
|
danakj
2016/09/02 19:12:42
it already starts empty so i dont think u need thi
xlai (Olivia)
2016/09/02 20:10:06
Done.
| |
| 35 | |
| 36 const gfx::Rect bounds(width, height); | |
| 37 const cc::RenderPassId renderPassId(1, 1); | |
| 38 std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); | |
| 39 pass->SetAll(renderPassId, bounds, bounds, gfx::Transform(), true); | |
|
danakj
2016/09/02 19:12:42
background is normally not transparent for the roo
xlai (Olivia)
2016/09/02 20:10:06
Yah you're right; I think it's more logical if can
| |
| 40 | |
| 41 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | |
| 42 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, SkX fermode::kSrc_Mode, 0); | |
|
danakj
2016/09/02 19:12:42
pass an empty clip rect since is_clipped is false
xlai (Olivia)
2016/09/02 20:10:07
Done.
| |
| 43 | |
| 44 cc::SolidColorDrawQuad* quad = pass->CreateAndAppendDrawQuad<cc::SolidColorD rawQuad>(); | |
| 45 const bool forceAntialiasingOff = false; | |
| 46 const gfx::Rect opaqueRect(0, 0, 0, 0); | |
| 47 const bool needsBlending = true; | |
| 48 quad->SetAll(sqs, bounds, opaqueRect, bounds, needsBlending, SK_ColorGREEN, forceAntialiasingOff); | |
|
danakj
2016/09/02 19:12:42
you can use SetNew here it's helpful and decides t
xlai (Olivia)
2016/09/02 20:10:06
Done. The solidcolorQuad::setNew() will set needsb
| |
| 49 | |
| 50 frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); | |
| 51 | |
| 52 m_service->SubmitCompositorFrame(m_surfaceId, std::move(frame)); | |
|
danakj
2016/09/02 19:12:42
The frame doesn't look totally wrong or anything t
xlai (Olivia)
2016/09/02 20:10:06
I see. That's a useful way to debug for me. Right
| |
| 53 | |
| 54 } | |
| 55 | |
| 56 } // namespace blink | |
| OLD | NEW |