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

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

Issue 1814263004: Remove create/delete methods from WebGraphicsContext3D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@complex-casts
Patch Set: Created 4 years, 9 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) 432 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox)
433 { 433 {
434 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { 434 for (size_t i = 0; i < m_textureMailboxes.size(); i++) {
435 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { 435 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) {
436 if (mailbox.validSyncToken) 436 if (mailbox.validSyncToken)
437 m_gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); 437 m_gl->WaitSyncTokenCHROMIUM(mailbox.syncToken);
438 438
439 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); 439 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo);
440 440
441 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI d); 441 m_gl->DeleteTextures(1, &m_textureMailboxes[i]->textureInfo.textureI d);
442 m_textureMailboxes.remove(i); 442 m_textureMailboxes.remove(i);
443 return; 443 return;
444 } 444 }
445 } 445 }
446 ASSERT_NOT_REACHED(); 446 ASSERT_NOT_REACHED();
447 } 447 }
448 448
449 bool DrawingBuffer::initialize(const IntSize& size) 449 bool DrawingBuffer::initialize(const IntSize& size)
450 { 450 {
451 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { 451 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
452 // Need to try to restore the context again later. 452 // Need to try to restore the context again later.
453 return false; 453 return false;
454 } 454 }
455 455
456 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); 456 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize);
457 457
458 int maxSampleCount = 0; 458 int maxSampleCount = 0;
459 m_antiAliasingMode = None; 459 m_antiAliasingMode = None;
460 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) { 460 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) {
461 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); 461 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount);
462 m_antiAliasingMode = MSAAExplicitResolve; 462 m_antiAliasingMode = MSAAExplicitResolve;
463 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) { 463 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) {
464 m_antiAliasingMode = MSAAImplicitResolve; 464 m_antiAliasingMode = MSAAImplicitResolve;
465 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) { 465 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) {
466 m_antiAliasingMode = ScreenSpaceAntialiasing; 466 m_antiAliasingMode = ScreenSpaceAntialiasing;
467 } 467 }
468 } 468 }
469 m_sampleCount = std::min(4, maxSampleCount); 469 m_sampleCount = std::min(4, maxSampleCount);
470 470
471 m_fbo = m_context->createFramebuffer(); 471 m_gl->GenFramebuffers(1, &m_fbo);
472 472
473 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); 473 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
474 createSecondaryBuffers(); 474 createSecondaryBuffers();
475 // We first try to initialize everything with the requested attributes. 475 // We first try to initialize everything with the requested attributes.
476 if (!reset(size)) 476 if (!reset(size))
477 return false; 477 return false;
478 // If that succeeds, we then see what we actually got and update our actual attributes to reflect that. 478 // If that succeeds, we then see what we actually got and update our actual attributes to reflect that.
479 m_actualAttributes = m_requestedAttributes; 479 m_actualAttributes = m_requestedAttributes;
480 if (m_requestedAttributes.alpha) { 480 if (m_requestedAttributes.alpha) {
481 WGC3Dint alphaBits = 0; 481 WGC3Dint alphaBits = 0;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 541
542 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; 542 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE;
543 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; 543 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE;
544 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr emultiplyAlpha) 544 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr emultiplyAlpha)
545 unpackUnpremultiplyAlphaNeeded = GL_TRUE; 545 unpackUnpremultiplyAlphaNeeded = GL_TRUE;
546 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha && premultiplyAlpha) 546 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha && premultiplyAlpha)
547 unpackPremultiplyAlphaNeeded = GL_TRUE; 547 unpackPremultiplyAlphaNeeded = GL_TRUE;
548 548
549 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl ipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded); 549 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl ipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded);
550 550
551 context->deleteTexture(sourceTexture); 551 gl->DeleteTextures(1, &sourceTexture);
552 552
553 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); 553 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM();
554 554
555 gl->Flush(); 555 gl->Flush();
556 GLbyte syncToken[24]; 556 GLbyte syncToken[24];
557 if (context->genSyncTokenCHROMIUM(fenceSync, syncToken)) 557 if (context->genSyncTokenCHROMIUM(fenceSync, syncToken))
558 m_gl->WaitSyncTokenCHROMIUM(syncToken); 558 m_gl->WaitSyncTokenCHROMIUM(syncToken);
559 559
560 return true; 560 return true;
561 } 561 }
(...skipping 30 matching lines...) Expand all
592 { 592 {
593 ASSERT(!m_destructionInProgress); 593 ASSERT(!m_destructionInProgress);
594 m_destructionInProgress = true; 594 m_destructionInProgress = true;
595 595
596 clearPlatformLayer(); 596 clearPlatformLayer();
597 597
598 while (!m_recycledMailboxQueue.isEmpty()) 598 while (!m_recycledMailboxQueue.isEmpty())
599 deleteMailbox(m_recycledMailboxQueue.takeLast()); 599 deleteMailbox(m_recycledMailboxQueue.takeLast());
600 600
601 if (m_multisampleFBO) 601 if (m_multisampleFBO)
602 m_context->deleteFramebuffer(m_multisampleFBO); 602 m_gl->DeleteFramebuffers(1, &m_multisampleFBO);
603 603
604 if (m_fbo) 604 if (m_fbo)
605 m_context->deleteFramebuffer(m_fbo); 605 m_gl->DeleteFramebuffers(1, &m_fbo);
606 606
607 if (m_multisampleColorBuffer) 607 if (m_multisampleColorBuffer)
608 m_context->deleteRenderbuffer(m_multisampleColorBuffer); 608 m_gl->DeleteRenderbuffers(1, &m_multisampleColorBuffer);
609 609
610 if (m_depthStencilBuffer) 610 if (m_depthStencilBuffer)
611 m_context->deleteRenderbuffer(m_depthStencilBuffer); 611 m_gl->DeleteRenderbuffers(1, &m_depthStencilBuffer);
612 612
613 if (m_colorBuffer.textureId) { 613 if (m_colorBuffer.textureId) {
614 deleteChromiumImageForTexture(&m_colorBuffer); 614 deleteChromiumImageForTexture(&m_colorBuffer);
615 m_context->deleteTexture(m_colorBuffer.textureId); 615 m_gl->DeleteTextures(1, &m_colorBuffer.textureId);
616 } 616 }
617 617
618 setSize(IntSize()); 618 setSize(IntSize());
619 619
620 m_colorBuffer = TextureInfo(); 620 m_colorBuffer = TextureInfo();
621 m_frontColorBuffer = FrontBufferInfo(); 621 m_frontColorBuffer = FrontBufferInfo();
622 m_multisampleColorBuffer = 0; 622 m_multisampleColorBuffer = 0;
623 m_depthStencilBuffer = 0; 623 m_depthStencilBuffer = 0;
624 m_multisampleFBO = 0; 624 m_multisampleFBO = 0;
625 m_fbo = 0; 625 m_fbo = 0;
626 626
627 if (m_layer) 627 if (m_layer)
628 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); 628 GraphicsLayer::unregisterContentsLayer(m_layer->layer());
629 } 629 }
630 630
631 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) 631 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters)
632 { 632 {
633 WebGLId offscreenColorTexture = m_context->createTexture(); 633 uint32_t offscreenColorTexture;
634 m_gl->GenTextures(1, &offscreenColorTexture);
634 if (!offscreenColorTexture) 635 if (!offscreenColorTexture)
635 return 0; 636 return 0;
636 637
637 m_gl->BindTexture(parameters.target, offscreenColorTexture); 638 m_gl->BindTexture(parameters.target, offscreenColorTexture);
638 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 639 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
639 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 640 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
640 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 641 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
641 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 642 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
642 643
643 return offscreenColorTexture; 644 return offscreenColorTexture;
644 } 645 }
645 646
646 void DrawingBuffer::createSecondaryBuffers() 647 void DrawingBuffer::createSecondaryBuffers()
647 { 648 {
648 // create a multisample FBO 649 // create a multisample FBO
649 if (m_antiAliasingMode == MSAAExplicitResolve) { 650 if (m_antiAliasingMode == MSAAExplicitResolve) {
650 m_multisampleFBO = m_context->createFramebuffer(); 651 m_gl->GenFramebuffers(1, &m_multisampleFBO);
651 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); 652 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
652 m_multisampleColorBuffer = m_context->createRenderbuffer(); 653 m_gl->GenRenderbuffers(1, &m_multisampleColorBuffer);
653 } 654 }
654 } 655 }
655 656
656 bool DrawingBuffer::resizeFramebuffer(const IntSize& size) 657 bool DrawingBuffer::resizeFramebuffer(const IntSize& size)
657 { 658 {
658 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); 659 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
659 if (m_antiAliasingMode != MSAAExplicitResolve) 660 if (m_antiAliasingMode != MSAAExplicitResolve)
660 resizeDepthStencil(size); 661 resizeDepthStencil(size);
661 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) 662 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
662 return false; 663 return false;
(...skipping 20 matching lines...) Expand all
683 684
684 return true; 685 return true;
685 } 686 }
686 687
687 void DrawingBuffer::resizeDepthStencil(const IntSize& size) 688 void DrawingBuffer::resizeDepthStencil(const IntSize& size)
688 { 689 {
689 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) 690 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil)
690 return; 691 return;
691 692
692 if (!m_depthStencilBuffer) 693 if (!m_depthStencilBuffer)
693 m_depthStencilBuffer = m_context->createRenderbuffer(); 694 m_gl->GenRenderbuffers(1, &m_depthStencilBuffer);
694 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); 695 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer);
695 if (m_antiAliasingMode == MSAAImplicitResolve) 696 if (m_antiAliasingMode == MSAAImplicitResolve)
696 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); 697 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height());
697 else if (m_antiAliasingMode == MSAAExplicitResolve) 698 else if (m_antiAliasingMode == MSAAExplicitResolve)
698 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); 699 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height());
699 else 700 else
700 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size .width(), size.height()); 701 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size .width(), size.height());
701 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G L_RENDERBUFFER, m_depthStencilBuffer); 702 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G L_RENDERBUFFER, m_depthStencilBuffer);
702 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); 703 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0);
703 } 704 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 height = size().height(); 870 height = size().height();
870 871
871 Checked<int, RecordOverflow> dataSize = 4; 872 Checked<int, RecordOverflow> dataSize = 4;
872 dataSize *= width; 873 dataSize *= width;
873 dataSize *= height; 874 dataSize *= height;
874 if (dataSize.hasOverflowed()) 875 if (dataSize.hasOverflowed())
875 return false; 876 return false;
876 877
877 WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents: :NotShared, WTF::ArrayBufferContents::DontInitialize); 878 WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents: :NotShared, WTF::ArrayBufferContents::DontInitialize);
878 879
879 GLint fbo = 0; 880 uint32_t fbo = 0;
880 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { 881 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) {
881 fbo = m_context->createFramebuffer(); 882 m_gl->GenFramebuffers(1, &fbo);
882 m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); 883 m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
883 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0); 884 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0);
884 } else { 885 } else {
885 m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer()); 886 m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer());
886 } 887 }
887 888
888 readBackFramebuffer(static_cast<unsigned char*>(pixels.data()), width, heigh t, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing); 889 readBackFramebuffer(static_cast<unsigned char*>(pixels.data()), width, heigh t, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing);
889 flipVertically(static_cast<uint8_t*>(pixels.data()), width, height); 890 flipVertically(static_cast<uint8_t*>(pixels.data()), width, height);
890 891
891 if (fbo) { 892 if (fbo) {
892 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, 0, 0); 893 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, 0, 0);
893 m_context->deleteFramebuffer(fbo); 894 m_gl->DeleteFramebuffers(1, &fbo);
894 } 895 }
895 896
896 restoreFramebufferBindings(); 897 restoreFramebufferBindings();
897 898
898 pixels.transfer(contents); 899 pixels.transfer(contents);
899 return true; 900 return true;
900 } 901 }
901 902
902 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op) 903 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op)
903 { 904 {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1037
1037 if (m_antiAliasingMode == MSAAImplicitResolve) 1038 if (m_antiAliasingMode == MSAAImplicitResolve)
1038 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); 1039 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount);
1039 else 1040 else
1040 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_colorBuffer.textureId, 0); 1041 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_colorBuffer.textureId, 0);
1041 1042
1042 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1043 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1043 } 1044 }
1044 1045
1045 } // namespace blink 1046 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698