OLD | NEW |
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 Loading... |
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); |
462 // We reuse the same mailbox name from above since our texture id was consum
ed from it. | 464 // We reuse the same mailbox name from above since our texture id was consum
ed from it. |
463 const auto& skImageMailbox = textureMailbox.mailbox(); | 465 const auto& skImageMailbox = textureMailbox.mailbox(); |
464 // Use the sync token generated after producing the mailbox. Waiting for thi
s before trying to use | 466 // Use the sync token generated after producing the mailbox. Waiting for thi
s before trying to use |
465 // the mailbox with some other context will ensure it is valid. We wouldn't
need to wait for the | 467 // the mailbox with some other context will ensure it is valid. We wouldn't
need to wait for the |
466 // consume done in this function because the texture id it generated would o
nly be valid for the | 468 // consume done in this function because the texture id it generated would o
nly be valid for the |
467 // DrawingBuffer's context anyways. | 469 // DrawingBuffer's context anyways. |
468 const auto& skImageSyncToken = textureMailbox.sync_token(); | 470 const auto& skImageSyncToken = textureMailbox.sync_token(); |
469 | 471 |
470 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap
RenderingContext's | 472 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap
RenderingContext's |
471 // transferFromImageBitmap, and try to use them in DrawingBuffer. | 473 // transferFromImageBitmap, and try to use them in DrawingBuffer. |
472 return AcceleratedStaticBitmapImage::createFromWebGLContextImage(std::move(s
kImage), skImageMailbox, skImageSyncToken); | 474 return AcceleratedStaticBitmapImage::create(std::move(skImage), grContextRef
, skImageMailbox, skImageSyncToken); |
473 } | 475 } |
474 | 476 |
475 DrawingBuffer::TextureParameters DrawingBuffer::chromiumImageTextureParameters() | 477 DrawingBuffer::TextureParameters DrawingBuffer::chromiumImageTextureParameters() |
476 { | 478 { |
477 #if OS(MACOSX) | 479 #if OS(MACOSX) |
478 // A CHROMIUM_image backed texture requires a specialized set of parameters | 480 // A CHROMIUM_image backed texture requires a specialized set of parameters |
479 // on OSX. | 481 // on OSX. |
480 TextureParameters parameters; | 482 TextureParameters parameters; |
481 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB; | 483 parameters.target = GC3D_TEXTURE_RECTANGLE_ARB; |
482 | 484 |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 | 1228 |
1227 void DrawingBuffer::restoreTextureBindings() | 1229 void DrawingBuffer::restoreTextureBindings() |
1228 { | 1230 { |
1229 // This class potentially modifies the bindings for GL_TEXTURE_2D and | 1231 // This class potentially modifies the bindings for GL_TEXTURE_2D and |
1230 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | 1232 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since |
1231 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1233 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
1232 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1234 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
1233 } | 1235 } |
1234 | 1236 |
1235 } // namespace blink | 1237 } // namespace blink |
OLD | NEW |