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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 350 |
351 // No buffer available to recycle, create a new one. | 351 // No buffer available to recycle, create a new one. |
352 if (!mailboxInfo) | 352 if (!mailboxInfo) |
353 mailboxInfo = createNewMailbox(createTextureAndAllocateMemory(m_size)); | 353 mailboxInfo = createNewMailbox(createTextureAndAllocateMemory(m_size)); |
354 | 354 |
355 if (m_preserveDrawingBuffer == Discard) { | 355 if (m_preserveDrawingBuffer == Discard) { |
356 std::swap(mailboxInfo->textureInfo, m_colorBuffer); | 356 std::swap(mailboxInfo->textureInfo, m_colorBuffer); |
357 attachColorBufferToReadFramebuffer(); | 357 attachColorBufferToReadFramebuffer(); |
358 | 358 |
359 if (m_discardFramebufferSupported) { | 359 if (m_discardFramebufferSupported) { |
360 // Explicitly discard framebuffer to save GPU memory bandwidth for tile-ba
sed GPU arch. | 360 // Explicitly discard the framebuffer to save GPU memory bandwidth for |
| 361 // tile-based GPU arch. |
361 const GLenum attachments[3] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, | 362 const GLenum attachments[3] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, |
362 GL_STENCIL_ATTACHMENT}; | 363 GL_STENCIL_ATTACHMENT}; |
363 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 364 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
364 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); | 365 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); |
365 } | 366 } |
366 } else { | 367 } else { |
367 m_gl->CopySubTextureCHROMIUM( | 368 m_gl->CopySubTextureCHROMIUM( |
368 m_colorBuffer.textureId, mailboxInfo->textureInfo.textureId, 0, 0, 0, 0, | 369 m_colorBuffer.textureId, mailboxInfo->textureInfo.textureId, 0, 0, 0, 0, |
369 m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_FALSE); | 370 m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_FALSE); |
370 } | 371 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 bool lostResource) { | 433 bool lostResource) { |
433 DCHECK(!syncToken.HasData()); // No sync tokens for software resources. | 434 DCHECK(!syncToken.HasData()); // No sync tokens for software resources. |
434 if (m_destructionInProgress || lostResource || m_isHidden || size != m_size) | 435 if (m_destructionInProgress || lostResource || m_isHidden || size != m_size) |
435 return; // Just delete the bitmap. | 436 return; // Just delete the bitmap. |
436 | 437 |
437 RecycledBitmap recycled = {std::move(bitmap), m_size}; | 438 RecycledBitmap recycled = {std::move(bitmap), m_size}; |
438 m_recycledBitmaps.append(std::move(recycled)); | 439 m_recycledBitmaps.append(std::move(recycled)); |
439 } | 440 } |
440 | 441 |
441 PassRefPtr<StaticBitmapImage> DrawingBuffer::transferToStaticBitmapImage() { | 442 PassRefPtr<StaticBitmapImage> DrawingBuffer::transferToStaticBitmapImage() { |
442 // This can be null if the context is lost before the first call to grContext(
). | 443 // This can be null if the context is lost before the first call to |
| 444 // grContext(). |
443 GrContext* grContext = m_contextProvider->grContext(); | 445 GrContext* grContext = m_contextProvider->grContext(); |
444 | 446 |
445 cc::TextureMailbox textureMailbox; | 447 cc::TextureMailbox textureMailbox; |
446 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; | 448 std::unique_ptr<cc::SingleReleaseCallback> releaseCallback; |
447 bool success = false; | 449 bool success = false; |
448 if (grContext) { | 450 if (grContext) { |
449 bool forceGpuResult = true; | 451 bool forceGpuResult = true; |
450 success = prepareTextureMailboxInternal(&textureMailbox, &releaseCallback, | 452 success = prepareTextureMailboxInternal(&textureMailbox, &releaseCallback, |
451 forceGpuResult); | 453 forceGpuResult); |
452 } | 454 } |
453 if (!success) { | 455 if (!success) { |
454 // If we can't get a mailbox, return an transparent black ImageBitmap. | 456 // If we can't get a mailbox, return an transparent black ImageBitmap. |
455 // The only situation this could happen is when two or more calls to transfe
rToImageBitmap are made back-to-back, or when the context gets lost. | 457 // The only situation in which this could happen is when two or more calls |
| 458 // to transferToImageBitmap are made back-to-back, or when the context gets |
| 459 // lost. |
456 sk_sp<SkSurface> surface = | 460 sk_sp<SkSurface> surface = |
457 SkSurface::MakeRasterN32Premul(m_size.width(), m_size.height()); | 461 SkSurface::MakeRasterN32Premul(m_size.width(), m_size.height()); |
458 return StaticBitmapImage::create(surface->makeImageSnapshot()); | 462 return StaticBitmapImage::create(surface->makeImageSnapshot()); |
459 } | 463 } |
460 | 464 |
461 DCHECK_EQ(m_size.width(), textureMailbox.size_in_pixels().width()); | 465 DCHECK_EQ(m_size.width(), textureMailbox.size_in_pixels().width()); |
462 DCHECK_EQ(m_size.height(), textureMailbox.size_in_pixels().height()); | 466 DCHECK_EQ(m_size.height(), textureMailbox.size_in_pixels().height()); |
463 | 467 |
464 // Make our own textureId that is a reference on the same texture backing bein
g used as the front | 468 // Make our own textureId that is a reference on the same texture backing |
465 // buffer (which was returned from PrepareTextureMailbox()). | 469 // being used as the front buffer (which was returned from |
466 // We do not need to wait on the sync token in |textureMailbox| since the mail
box was produced on | 470 // PrepareTextureMailbox()). We do not need to wait on the sync token in |
467 // the same |m_gl| context that we are using here. Similarly, the |releaseCall
back| will run on | 471 // |textureMailbox| since the mailbox was produced on the same |m_gl| context |
468 // the same context so we don't need to send a sync token for this consume act
ion back to it. | 472 // that we are using here. Similarly, the |releaseCallback| will run on the |
469 // TODO(danakj): Instead of using PrepareTextureMailbox(), we could just use t
he actual texture id and | 473 // same context so we don't need to send a sync token for this consume action |
470 // avoid needing to produce/consume a mailbox. | 474 // back to it. |
| 475 // TODO(danakj): Instead of using PrepareTextureMailbox(), we could just use |
| 476 // the actual texture id and avoid needing to produce/consume a mailbox. |
471 GLuint textureId = m_gl->CreateAndConsumeTextureCHROMIUM( | 477 GLuint textureId = m_gl->CreateAndConsumeTextureCHROMIUM( |
472 GL_TEXTURE_2D, textureMailbox.name()); | 478 GL_TEXTURE_2D, textureMailbox.name()); |
473 // Return the mailbox but report that the resource is lost to prevent trying t
o use | 479 // Return the mailbox but report that the resource is lost to prevent trying |
474 // the backing for future frames. We keep it alive with our own reference to t
he | 480 // to use the backing for future frames. We keep it alive with our own |
475 // backing via our |textureId|. | 481 // reference to the backing via our |textureId|. |
476 releaseCallback->Run(gpu::SyncToken(), true /* lostResource */); | 482 releaseCallback->Run(gpu::SyncToken(), true /* lostResource */); |
477 | 483 |
478 // Store that texture id as the backing for an SkImage. | 484 // Store that texture id as the backing for an SkImage. |
479 GrGLTextureInfo textureInfo; | 485 GrGLTextureInfo textureInfo; |
480 textureInfo.fTarget = GL_TEXTURE_2D; | 486 textureInfo.fTarget = GL_TEXTURE_2D; |
481 textureInfo.fID = textureId; | 487 textureInfo.fID = textureId; |
482 GrBackendTextureDesc backendTexture; | 488 GrBackendTextureDesc backendTexture; |
483 backendTexture.fOrigin = kBottomLeft_GrSurfaceOrigin; | 489 backendTexture.fOrigin = kBottomLeft_GrSurfaceOrigin; |
484 backendTexture.fWidth = m_size.width(); | 490 backendTexture.fWidth = m_size.width(); |
485 backendTexture.fHeight = m_size.height(); | 491 backendTexture.fHeight = m_size.height(); |
486 backendTexture.fConfig = kSkia8888_GrPixelConfig; | 492 backendTexture.fConfig = kSkia8888_GrPixelConfig; |
487 backendTexture.fTextureHandle = | 493 backendTexture.fTextureHandle = |
488 skia::GrGLTextureInfoToGrBackendObject(textureInfo); | 494 skia::GrGLTextureInfoToGrBackendObject(textureInfo); |
489 sk_sp<SkImage> skImage = | 495 sk_sp<SkImage> skImage = |
490 SkImage::MakeFromAdoptedTexture(grContext, backendTexture); | 496 SkImage::MakeFromAdoptedTexture(grContext, backendTexture); |
491 | 497 |
492 // We reuse the same mailbox name from above since our texture id was consumed
from it. | 498 // We reuse the same mailbox name from above since our texture id was consumed |
| 499 // from it. |
493 const auto& skImageMailbox = textureMailbox.mailbox(); | 500 const auto& skImageMailbox = textureMailbox.mailbox(); |
494 // Use the sync token generated after producing the mailbox. Waiting for this
before trying to use | 501 // Use the sync token generated after producing the mailbox. Waiting for this |
495 // the mailbox with some other context will ensure it is valid. We wouldn't ne
ed to wait for the | 502 // before trying to use the mailbox with some other context will ensure it is |
496 // consume done in this function because the texture id it generated would onl
y be valid for the | 503 // valid. We wouldn't need to wait for the consume done in this function |
| 504 // because the texture id it generated would only be valid for the |
497 // DrawingBuffer's context anyways. | 505 // DrawingBuffer's context anyways. |
498 const auto& skImageSyncToken = textureMailbox.sync_token(); | 506 const auto& skImageSyncToken = textureMailbox.sync_token(); |
499 | 507 |
500 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmapRe
nderingContext's | 508 // TODO(xidachen): Create a small pool of recycled textures from |
501 // transferFromImageBitmap, and try to use them in DrawingBuffer. | 509 // ImageBitmapRenderingContext's transferFromImageBitmap, and try to use them |
| 510 // in DrawingBuffer. |
502 return AcceleratedStaticBitmapImage::createFromWebGLContextImage( | 511 return AcceleratedStaticBitmapImage::createFromWebGLContextImage( |
503 std::move(skImage), skImageMailbox, skImageSyncToken); | 512 std::move(skImage), skImageMailbox, skImageSyncToken); |
504 } | 513 } |
505 | 514 |
506 DrawingBuffer::TextureParameters | 515 DrawingBuffer::TextureParameters |
507 DrawingBuffer::chromiumImageTextureParameters() { | 516 DrawingBuffer::chromiumImageTextureParameters() { |
508 #if OS(MACOSX) | 517 #if OS(MACOSX) |
509 // A CHROMIUM_image backed texture requires a specialized set of parameters | 518 // A CHROMIUM_image backed texture requires a specialized set of parameters |
510 // on OSX. | 519 // on OSX. |
511 TextureParameters parameters; | 520 TextureParameters parameters; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); | 642 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); |
634 m_antiAliasingMode = MSAAExplicitResolve; | 643 m_antiAliasingMode = MSAAExplicitResolve; |
635 if (m_extensionsUtil->supportsExtension( | 644 if (m_extensionsUtil->supportsExtension( |
636 "GL_EXT_multisampled_render_to_texture")) { | 645 "GL_EXT_multisampled_render_to_texture")) { |
637 m_antiAliasingMode = MSAAImplicitResolve; | 646 m_antiAliasingMode = MSAAImplicitResolve; |
638 } else if (m_extensionsUtil->supportsExtension( | 647 } else if (m_extensionsUtil->supportsExtension( |
639 "GL_CHROMIUM_screen_space_antialiasing")) { | 648 "GL_CHROMIUM_screen_space_antialiasing")) { |
640 m_antiAliasingMode = ScreenSpaceAntialiasing; | 649 m_antiAliasingMode = ScreenSpaceAntialiasing; |
641 } | 650 } |
642 } | 651 } |
643 // TODO(dshwang): enable storage texture on all platform. crbug.com/557848 | 652 // TODO(dshwang): Enable storage textures on all platforms. crbug.com/557848 |
644 // Linux ATI bot fails WebglConformance.conformance_textures_misc_tex_image_we
bgl | 653 // The Linux ATI bot fails |
645 // So use storage texture only if ScreenSpaceAntialiasing is enabled, | 654 // WebglConformance.conformance_textures_misc_tex_image_webgl, so use storage |
646 // because ScreenSpaceAntialiasing is much faster with storage texture. | 655 // textures only if ScreenSpaceAntialiasing is enabled, because |
| 656 // ScreenSpaceAntialiasing is much faster with storage textures. |
647 m_storageTextureSupported = | 657 m_storageTextureSupported = |
648 (m_webGLVersion > WebGL1 || | 658 (m_webGLVersion > WebGL1 || |
649 m_extensionsUtil->supportsExtension("GL_EXT_texture_storage")) && | 659 m_extensionsUtil->supportsExtension("GL_EXT_texture_storage")) && |
650 m_antiAliasingMode == ScreenSpaceAntialiasing; | 660 m_antiAliasingMode == ScreenSpaceAntialiasing; |
651 m_sampleCount = std::min(4, maxSampleCount); | 661 m_sampleCount = std::min(4, maxSampleCount); |
652 | 662 |
653 m_gl->GenFramebuffers(1, &m_fbo); | 663 m_gl->GenFramebuffers(1, &m_fbo); |
654 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 664 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
655 if (wantExplicitResolve()) { | 665 if (wantExplicitResolve()) { |
656 m_gl->GenFramebuffers(1, &m_multisampleFBO); | 666 m_gl->GenFramebuffers(1, &m_multisampleFBO); |
657 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | 667 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); |
658 m_gl->GenRenderbuffers(1, &m_multisampleRenderbuffer); | 668 m_gl->GenRenderbuffers(1, &m_multisampleRenderbuffer); |
659 } | 669 } |
660 if (!reset(size)) | 670 if (!reset(size)) |
661 return false; | 671 return false; |
662 | 672 |
663 if (m_depthStencilBuffer) { | 673 if (m_depthStencilBuffer) { |
664 DCHECK(wantDepthOrStencil()); | 674 DCHECK(wantDepthOrStencil()); |
665 m_hasImplicitStencilBuffer = !m_wantStencil; | 675 m_hasImplicitStencilBuffer = !m_wantStencil; |
666 } | 676 } |
667 | 677 |
668 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 678 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
669 // It's possible that the drawing buffer allocation provokes a context loss,
so check again just in case. http://crbug.com/512302 | 679 // It's possible that the drawing buffer allocation provokes a context loss, |
| 680 // so check again just in case. http://crbug.com/512302 |
670 return false; | 681 return false; |
671 } | 682 } |
672 | 683 |
673 return true; | 684 return true; |
674 } | 685 } |
675 | 686 |
676 bool DrawingBuffer::copyToPlatformTexture(gpu::gles2::GLES2Interface* gl, | 687 bool DrawingBuffer::copyToPlatformTexture(gpu::gles2::GLES2Interface* gl, |
677 GLuint texture, | 688 GLuint texture, |
678 GLenum internalFormat, | 689 GLenum internalFormat, |
679 GLenum destType, | 690 GLenum destType, |
680 GLint level, | 691 GLint level, |
681 bool premultiplyAlpha, | 692 bool premultiplyAlpha, |
682 bool flipY, | 693 bool flipY, |
683 SourceDrawingBuffer sourceBuffer) { | 694 SourceDrawingBuffer sourceBuffer) { |
684 if (m_contentsChanged) { | 695 if (m_contentsChanged) { |
685 if (m_antiAliasingMode != None) { | 696 if (m_antiAliasingMode != None) { |
686 commit(); | 697 commit(); |
687 restoreFramebufferBindings(); | 698 restoreFramebufferBindings(); |
688 } | 699 } |
689 m_gl->Flush(); | 700 m_gl->Flush(); |
690 } | 701 } |
691 | 702 |
692 // Assume that the destination target is GL_TEXTURE_2D. | 703 // Assume that the destination target is GL_TEXTURE_2D. |
693 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM( | 704 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM( |
694 GL_TEXTURE_2D, internalFormat, destType, level)) | 705 GL_TEXTURE_2D, internalFormat, destType, level)) |
695 return false; | 706 return false; |
696 | 707 |
697 // Contexts may be in a different share group. We must transfer the texture th
rough a mailbox first | 708 // Contexts may be in a different share group. We must transfer the texture |
| 709 // through a mailbox first. |
698 GLint textureId = 0; | 710 GLint textureId = 0; |
699 GLenum target = 0; | 711 GLenum target = 0; |
700 gpu::Mailbox mailbox; | 712 gpu::Mailbox mailbox; |
701 gpu::SyncToken produceSyncToken; | 713 gpu::SyncToken produceSyncToken; |
702 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { | 714 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { |
703 textureId = m_frontColorBuffer.texInfo.textureId; | 715 textureId = m_frontColorBuffer.texInfo.textureId; |
704 target = m_frontColorBuffer.texInfo.parameters.target; | 716 target = m_frontColorBuffer.texInfo.parameters.target; |
705 mailbox = m_frontColorBuffer.mailbox; | 717 mailbox = m_frontColorBuffer.mailbox; |
706 produceSyncToken = m_frontColorBuffer.produceSyncToken; | 718 produceSyncToken = m_frontColorBuffer.produceSyncToken; |
707 } else { | 719 } else { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, | 856 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, |
845 GL_DEPTH24_STENCIL8_OES, | 857 GL_DEPTH24_STENCIL8_OES, |
846 size.width(), size.height()); | 858 size.width(), size.height()); |
847 else if (m_antiAliasingMode == MSAAExplicitResolve) | 859 else if (m_antiAliasingMode == MSAAExplicitResolve) |
848 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCount, | 860 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCount, |
849 GL_DEPTH24_STENCIL8_OES, | 861 GL_DEPTH24_STENCIL8_OES, |
850 size.width(), size.height()); | 862 size.width(), size.height()); |
851 else | 863 else |
852 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, | 864 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, |
853 size.width(), size.height()); | 865 size.width(), size.height()); |
854 // For ES 2.0 contexts DEPTH_STENCIL is not available natively, so we emulate
it | 866 // For ES 2.0 contexts DEPTH_STENCIL is not available natively, so we emulate |
855 // at the command buffer level for WebGL contexts. | 867 // it at the command buffer level for WebGL contexts. |
856 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, | 868 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, |
857 GL_RENDERBUFFER, m_depthStencilBuffer); | 869 GL_RENDERBUFFER, m_depthStencilBuffer); |
858 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); | 870 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); |
859 } | 871 } |
860 | 872 |
861 bool DrawingBuffer::resizeDefaultFramebuffer(const IntSize& size) { | 873 bool DrawingBuffer::resizeDefaultFramebuffer(const IntSize& size) { |
862 // Resize or create m_colorBuffer. | 874 // Resize or create m_colorBuffer. |
863 if (m_colorBuffer.textureId) { | 875 if (m_colorBuffer.textureId) { |
864 resizeTextureMemory(&m_colorBuffer, size); | 876 resizeTextureMemory(&m_colorBuffer, size); |
865 } else { | 877 } else { |
(...skipping 15 matching lines...) Expand all Loading... |
881 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | 893 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
882 return false; | 894 return false; |
883 } | 895 } |
884 | 896 |
885 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 897 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
886 return m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) == | 898 return m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
887 GL_FRAMEBUFFER_COMPLETE; | 899 GL_FRAMEBUFFER_COMPLETE; |
888 } | 900 } |
889 | 901 |
890 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) { | 902 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) { |
891 // We will clear the multisample FBO, but we also need to clear the non-multis
ampled buffer. | 903 // We will clear the multisample FBO, but we also need to clear the |
| 904 // non-multisampled buffer. |
892 if (m_multisampleFBO) { | 905 if (m_multisampleFBO) { |
893 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 906 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
894 m_gl->Clear(GL_COLOR_BUFFER_BIT); | 907 m_gl->Clear(GL_COLOR_BUFFER_BIT); |
895 } | 908 } |
896 | 909 |
897 m_gl->BindFramebuffer(GL_FRAMEBUFFER, | 910 m_gl->BindFramebuffer(GL_FRAMEBUFFER, |
898 m_multisampleFBO ? m_multisampleFBO : m_fbo); | 911 m_multisampleFBO ? m_multisampleFBO : m_fbo); |
899 m_gl->Clear(clearMask); | 912 m_gl->Clear(clearMask); |
900 } | 913 } |
901 | 914 |
902 void DrawingBuffer::setSize(const IntSize& size) { | 915 void DrawingBuffer::setSize(const IntSize& size) { |
903 if (m_size == size) | 916 if (m_size == size) |
904 return; | 917 return; |
905 | 918 |
906 m_size = size; | 919 m_size = size; |
907 } | 920 } |
908 | 921 |
909 IntSize DrawingBuffer::adjustSize(const IntSize& desiredSize, | 922 IntSize DrawingBuffer::adjustSize(const IntSize& desiredSize, |
910 const IntSize& curSize, | 923 const IntSize& curSize, |
911 int maxTextureSize) { | 924 int maxTextureSize) { |
912 IntSize adjustedSize = desiredSize; | 925 IntSize adjustedSize = desiredSize; |
913 | 926 |
914 // Clamp if the desired size is greater than the maximum texture size for the
device. | 927 // Clamp if the desired size is greater than the maximum texture size for the |
| 928 // device. |
915 if (adjustedSize.height() > maxTextureSize) | 929 if (adjustedSize.height() > maxTextureSize) |
916 adjustedSize.setHeight(maxTextureSize); | 930 adjustedSize.setHeight(maxTextureSize); |
917 | 931 |
918 if (adjustedSize.width() > maxTextureSize) | 932 if (adjustedSize.width() > maxTextureSize) |
919 adjustedSize.setWidth(maxTextureSize); | 933 adjustedSize.setWidth(maxTextureSize); |
920 | 934 |
921 return adjustedSize; | 935 return adjustedSize; |
922 } | 936 } |
923 | 937 |
924 bool DrawingBuffer::reset(const IntSize& newSize) { | 938 bool DrawingBuffer::reset(const IntSize& newSize) { |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1333 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
1320 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1334 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
1321 } | 1335 } |
1322 | 1336 |
1323 bool DrawingBuffer::shouldUseChromiumImage() { | 1337 bool DrawingBuffer::shouldUseChromiumImage() { |
1324 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && | 1338 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && |
1325 m_chromiumImageUsage == AllowChromiumImage; | 1339 m_chromiumImageUsage == AllowChromiumImage; |
1326 } | 1340 } |
1327 | 1341 |
1328 } // namespace blink | 1342 } // namespace blink |
OLD | NEW |