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

Unified Diff: third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp

Issue 2328463004: Implement WebGL's commit on the main thread (Closed)
Patch Set: written as a gpu pixel test Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
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
index 137299ee91d4b4ba89685e00a6a616e0bef09cb3..c4ea45e5f6c355d4350ecffac6712573cf949569 100644
--- a/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp
+++ b/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp
@@ -9,8 +9,11 @@
#include "cc/quads/render_pass.h"
#include "cc/quads/shared_quad_state.h"
#include "cc/quads/solid_color_draw_quad.h"
+#include "cc/quads/texture_draw_quad.h"
+#include "platform/graphics/StaticBitmapImage.h"
#include "public/platform/InterfaceProvider.h"
#include "public/platform/Platform.h"
+#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkXfermode.h"
#include "ui/gfx/geometry/rect.h"
@@ -27,10 +30,8 @@ OffscreenCanvasFrameDispatcherImpl::OffscreenCanvasFrameDispatcherImpl(uint32_t
Platform::current()->interfaceProvider()->getInterface(mojo::GetProxy(&m_service));
}
-void OffscreenCanvasFrameDispatcherImpl::dispatchFrame()
+void OffscreenCanvasFrameDispatcherImpl::dispatchFrame(PassRefPtr<StaticBitmapImage> image)
{
- // TODO(563852/xlai): 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);
@@ -43,9 +44,37 @@ void OffscreenCanvasFrameDispatcherImpl::dispatchFrame()
cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, SkXfermode::kSrcOver_Mode, 0);
- cc::SolidColorDrawQuad* quad = pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
- const bool forceAntialiasingOff = false;
- quad->SetNew(sqs, bounds, bounds, SK_ColorGREEN, forceAntialiasingOff);
+ // TODO(xidachen): for now, we just submit a SolidColor frame to compositor in the 2d case,
+ // we should extract data from image.
+ if (!image) {
+ cc::SolidColorDrawQuad* quad = pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
+ const bool forceAntialiasingOff = false;
+ quad->SetNew(sqs, bounds, bounds, SK_ColorGREEN, forceAntialiasingOff);
+ } else { // WebGL
+ cc::TransferableResource resource;
Justin Novosad 2016/09/09 19:10:51 Here, we should probably assert that 'image' is gp
xidachen 2016/09/09 19:23:42 Done.
+ resource.id = image->getTextureId();
Justin Novosad 2016/09/09 19:10:50 I suspect is wrong. The texture Id is useless out
xidachen 2016/09/09 19:23:42 I am not very sure. I looked at this example: http
+ resource.format = cc::ResourceFormat::RGBA_8888;
Justin Novosad 2016/09/09 19:10:51 we should be extracting format from 'image' instea
xidachen 2016/09/09 19:23:42 My impression was that this mailbox is a resource
+ resource.filter = GL_LINEAR;
Justin Novosad 2016/09/09 19:10:51 Please add a TODO and create a crbug for this: the
xidachen 2016/09/09 19:23:42 Done.
+ resource.size = gfx::Size(m_width, m_height);
+ resource.mailbox_holder = gpu::MailboxHolder(image->getMailbox(), image->getSyncToken(), GL_TEXTURE_2D);
+ resource.read_lock_fences_enabled = false;
+ resource.is_software = false;
+ resource.is_overlay_candidate = false;
+ frame.delegated_frame_data->resource_list.push_back(std::move(resource));
+
+ cc::TextureDrawQuad* quad = pass->CreateAndAppendDrawQuad<cc::TextureDrawQuad>();
+ gfx::Size rectSize(m_width, m_height);
+
+ const bool needsBlending = true;
+ const bool premultipliedAlpha = true;
+ const gfx::PointF uvTopLeft(0.f, 0.f);
+ const gfx::PointF uvBottomRight(1.f, 1.f);
+ float vertexOpacity[4] = {1.f, 1.f, 1.f, 1.f};
+ const bool yflipped = false;
+ const bool nearestNeighbor = false;
Justin Novosad 2016/09/09 19:10:50 TODO: needs to be true when using style "image-ren
xidachen 2016/09/09 19:23:42 Done.
+ quad->SetAll(sqs, bounds, bounds, bounds, needsBlending, resource.id, gfx::Size(), premultipliedAlpha,
+ uvTopLeft, uvBottomRight, SK_ColorTRANSPARENT, vertexOpacity, yflipped, nearestNeighbor, false);
+ }
frame.delegated_frame_data->render_pass_list.push_back(std::move(pass));

Powered by Google App Engine
This is Rietveld 408576698