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

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

Issue 2382883005: Implement OffscreenCanvas.commit() on Unaccelerated 2D on worker (Closed)
Patch Set: rebase Nits Created 4 years, 2 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
« no previous file with comments | « content/test/gpu/gpu_tests/pixel_test_pages.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 890eac6113d11496c250b27019dbdc0febb3d6bd..72e85946ba18f2ac8005b4e9bf4416328c9de968 100644
--- a/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp
+++ b/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp
@@ -65,75 +65,64 @@ void OffscreenCanvasFrameDispatcherImpl::dispatchFrame(
sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f,
SkXfermode::kSrcOver_Mode, 0);
- if (!image->isTextureBacked() && !isMainThread()) {
- // TODO(xlai): Implement unaccelerated 2d canvas on worker.
- // See crbug.com/563858.
- // This is a temporary code that submits a solidColor frame.
- cc::SolidColorDrawQuad* quad =
- pass->CreateAndAppendDrawQuad<cc::SolidColorDrawQuad>();
- const bool forceAntialiasingOff = false;
- quad->SetNew(sqs, bounds, bounds, SK_ColorGREEN, forceAntialiasingOff);
+ cc::TransferableResource resource;
+ resource.id = m_nextResourceId;
+ resource.format = cc::ResourceFormat::RGBA_8888;
+ // TODO(crbug.com/645590): filter should respect the image-rendering CSS property of associated canvas element.
+ resource.filter = GL_LINEAR;
+ resource.size = gfx::Size(m_width, m_height);
+ if (image->isTextureBacked()) {
+ image->ensureMailbox();
+ resource.mailbox_holder = gpu::MailboxHolder(
+ image->getMailbox(), image->getSyncToken(), GL_TEXTURE_2D);
+ resource.read_lock_fences_enabled = false;
+ resource.is_software = false;
+
+ // Hold ref to |image|, to keep it alive until the browser ReturnResources.
+ // It guarantees that the resource is not re-used or deleted.
+ m_cachedImages.add(getNextResourceIdAndIncrement(), std::move(image));
} else {
- cc::TransferableResource resource;
- resource.id = m_nextResourceId;
- resource.format = cc::ResourceFormat::RGBA_8888;
- // TODO(crbug.com/645590): filter should respect the image-rendering CSS property of associated canvas element.
- resource.filter = GL_LINEAR;
- resource.size = gfx::Size(m_width, m_height);
- if (!image->isTextureBacked()) {
- std::unique_ptr<cc::SharedBitmap> bitmap =
- Platform::current()->allocateSharedBitmap(IntSize(m_width, m_height));
- if (!bitmap)
- return;
- unsigned char* pixels = bitmap->pixels();
- DCHECK(pixels);
- SkImageInfo imageInfo =
- SkImageInfo::Make(m_width, m_height, kN32_SkColorType,
- image->isPremultiplied() ? kPremul_SkAlphaType
- : kUnpremul_SkAlphaType);
- // TODO(xlai): Optimize to avoid copying pixels. See crbug.com/651456.
- image->imageForCurrentFrame()->readPixels(imageInfo, pixels,
- imageInfo.minRowBytes(), 0, 0);
- resource.mailbox_holder.mailbox = bitmap->id();
- resource.is_software = true;
-
- // Hold ref to |bitmap|, to keep it alive until the browser ReturnResources.
- // It guarantees that the shared bitmap is not re-used or deleted.
- m_sharedBitmaps.add(getNextResourceIdAndIncrement(), std::move(bitmap));
- } else {
- image->ensureMailbox();
- resource.mailbox_holder = gpu::MailboxHolder(
- image->getMailbox(), image->getSyncToken(), GL_TEXTURE_2D);
- resource.read_lock_fences_enabled = false;
- resource.is_software = false;
-
- // Hold ref to |image|, to keep it alive until the browser ReturnResources.
- // It guarantees that the resource is not re-used or deleted.
- m_cachedImages.add(getNextResourceIdAndIncrement(), std::move(image));
- }
- // TODO(crbug.com/646022): making this overlay-able.
- 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;
- // TOOD(crbug.com/645993): this should be inherited from WebGL context's creation settings.
- 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;
- // TODO(crbug.com/645994): this should be true when using style "image-rendering: pixelated".
- const bool nearestNeighbor = false;
- quad->SetAll(sqs, bounds, bounds, bounds, needsBlending, resource.id,
- gfx::Size(), premultipliedAlpha, uvTopLeft, uvBottomRight,
- SK_ColorTRANSPARENT, vertexOpacity, yflipped, nearestNeighbor,
- false);
+ std::unique_ptr<cc::SharedBitmap> bitmap =
+ Platform::current()->allocateSharedBitmap(IntSize(m_width, m_height));
+ if (!bitmap)
+ return;
+ unsigned char* pixels = bitmap->pixels();
+ DCHECK(pixels);
+ SkImageInfo imageInfo = SkImageInfo::Make(
+ m_width, m_height, kN32_SkColorType,
+ image->isPremultiplied() ? kPremul_SkAlphaType : kUnpremul_SkAlphaType);
+ // TODO(xlai): Optimize to avoid copying pixels. See crbug.com/651456.
+ image->imageForCurrentFrame()->readPixels(imageInfo, pixels,
+ imageInfo.minRowBytes(), 0, 0);
+ resource.mailbox_holder.mailbox = bitmap->id();
+ resource.is_software = true;
+
+ // Hold ref to |bitmap|, to keep it alive until the browser ReturnResources.
+ // It guarantees that the shared bitmap is not re-used or deleted.
+ m_sharedBitmaps.add(getNextResourceIdAndIncrement(), std::move(bitmap));
}
+ // TODO(crbug.com/646022): making this overlay-able.
+ 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;
+ // TOOD(crbug.com/645993): this should be inherited from WebGL context's creation settings.
+ 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;
+ // TODO(crbug.com/645994): this should be true when using style "image-rendering: pixelated".
+ const bool nearestNeighbor = false;
+ 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));
« no previous file with comments | « content/test/gpu/gpu_tests/pixel_test_pages.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698