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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 2300633004: Allow canvases to be GPU-accelerated in Workers (Closed)
Patch Set: test expectation 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 textureInfo.fTarget = GL_TEXTURE_2D; 452 textureInfo.fTarget = GL_TEXTURE_2D;
453 textureInfo.fID = textureId; 453 textureInfo.fID = textureId;
454 GrBackendTextureDesc backendTexture; 454 GrBackendTextureDesc backendTexture;
455 backendTexture.fOrigin = kBottomLeft_GrSurfaceOrigin; 455 backendTexture.fOrigin = kBottomLeft_GrSurfaceOrigin;
456 backendTexture.fWidth = m_size.width(); 456 backendTexture.fWidth = m_size.width();
457 backendTexture.fHeight = m_size.height(); 457 backendTexture.fHeight = m_size.height();
458 backendTexture.fConfig = kSkia8888_GrPixelConfig; 458 backendTexture.fConfig = kSkia8888_GrPixelConfig;
459 backendTexture.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(textu reInfo); 459 backendTexture.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(textu reInfo);
460 sk_sp<SkImage> skImage = SkImage::MakeFromAdoptedTexture(grContext, backendT exture); 460 sk_sp<SkImage> skImage = SkImage::MakeFromAdoptedTexture(grContext, backendT exture);
461 461
462 // Hold a ref on the GrContext for the texture backing the |skImage|.
463 sk_sp<GrContext> grContextRef = sk_ref_sp(grContext);
464 // We reuse the same mailbox name from above since our texture id was consum ed from it. 462 // We reuse the same mailbox name from above since our texture id was consum ed from it.
465 const auto& skImageMailbox = textureMailbox.mailbox(); 463 const auto& skImageMailbox = textureMailbox.mailbox();
466 // Use the sync token generated after producing the mailbox. Waiting for thi s before trying to use 464 // Use the sync token generated after producing the mailbox. Waiting for thi s before trying to use
467 // the mailbox with some other context will ensure it is valid. We wouldn't need to wait for the 465 // the mailbox with some other context will ensure it is valid. We wouldn't need to wait for the
468 // consume done in this function because the texture id it generated would o nly be valid for the 466 // consume done in this function because the texture id it generated would o nly be valid for the
469 // DrawingBuffer's context anyways. 467 // DrawingBuffer's context anyways.
470 const auto& skImageSyncToken = textureMailbox.sync_token(); 468 const auto& skImageSyncToken = textureMailbox.sync_token();
471 469
472 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap RenderingContext's 470 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap RenderingContext's
473 // transferFromImageBitmap, and try to use them in DrawingBuffer. 471 // transferFromImageBitmap, and try to use them in DrawingBuffer.
474 return AcceleratedStaticBitmapImage::create(std::move(skImage), grContextRef , skImageMailbox, skImageSyncToken); 472 return AcceleratedStaticBitmapImage::createFromWebGLContextImage(std::move(s kImage), skImageMailbox, skImageSyncToken);
475 } 473 }
476 474
477 DrawingBuffer::TextureParameters DrawingBuffer::chromiumImageTextureParameters() 475 DrawingBuffer::TextureParameters DrawingBuffer::chromiumImageTextureParameters()
478 { 476 {
479 #if OS(MACOSX) 477 #if OS(MACOSX)
480 // A CHROMIUM_image backed texture requires a specialized set of parameters 478 // A CHROMIUM_image backed texture requires a specialized set of parameters
481 // on OSX. 479 // on OSX.
482 TextureParameters parameters; 480 TextureParameters parameters;
483 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB; 481 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB;
484 482
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 1226
1229 void DrawingBuffer::restoreTextureBindings() 1227 void DrawingBuffer::restoreTextureBindings()
1230 { 1228 {
1231 // This class potentially modifies the bindings for GL_TEXTURE_2D and 1229 // This class potentially modifies the bindings for GL_TEXTURE_2D and
1232 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since 1230 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since
1233 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1231 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1234 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1232 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1235 } 1233 }
1236 1234
1237 } // namespace blink 1235 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698