Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp b/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a94807875bf45ebc4f268d023490c4eb73021371 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" |
| + |
| +#include "cc/output/delegated_frame_data.h" |
| +#include "cc/quads/render_pass.h" |
| +#include "cc/quads/shared_quad_state.h" |
| +#include "cc/quads/solid_color_draw_quad.h" |
| +#include "public/platform/InterfaceProvider.h" |
| +#include "public/platform/Platform.h" |
| +#include "third_party/skia/include/core/SkColor.h" |
| +#include "third_party/skia/include/core/SkXfermode.h" |
| +#include "ui/gfx/geometry/rect.h" |
| +#include "ui/gfx/transform.h" |
| + |
| +namespace blink { |
| + |
| +OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl(uint32_t clientId, uint32_t localId, uint64_t nonce) |
| + : m_surfaceId(cc::SurfaceId(clientId, localId, nonce)) |
| +{ |
| + DCHECK(!m_service.is_bound()); |
| + Platform::current()->interfaceProvider()->getInterface(mojo::GetProxy(&m_service)); |
| +} |
| + |
| +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
|
| +{ |
| + // TODO(563852): Currently this is just a simple solid-color compositor frame. |
| + // We need to update this function to extract the image data from canvas. |
| + cc::CompositorFrame frame; |
| + frame.metadata.device_scale_factor = 1.0f; |
| + 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.
|
| + 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.
|
| + |
| + const gfx::Rect bounds(width, height); |
| + const cc::RenderPassId renderPassId(1, 1); |
| + std::unique_ptr<cc::RenderPass> pass = cc::RenderPass::Create(); |
| + 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
|
| + |
| + cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| + sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, SkXfermode::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.
|
| + |
| + cc::SolidColorDrawQuad* quad = pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>(); |
| + const bool forceAntialiasingOff = false; |
| + const gfx::Rect opaqueRect(0, 0, 0, 0); |
| + const bool needsBlending = true; |
| + 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
|
| + |
| + frame.delegated_frame_data->render_pass_list.push_back(std::move(pass)); |
| + |
| + 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
|
| + |
| +} |
| + |
| +} // namespace blink |