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

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: complex-create: . 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 269
270 // We must restore the texture binding since creating new textures, 270 // We must restore the texture binding since creating new textures,
271 // consuming and producing mailboxes changes it. 271 // consuming and producing mailboxes changes it.
272 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text ure2DBinding); 272 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text ure2DBinding);
273 273
274 // First try to recycle an old buffer. 274 // First try to recycle an old buffer.
275 RefPtr<MailboxInfo> frontColorBufferMailbox = recycledMailbox(); 275 RefPtr<MailboxInfo> frontColorBufferMailbox = recycledMailbox();
276 276
277 // No buffer available to recycle, create a new one. 277 // No buffer available to recycle, create a new one.
278 if (!frontColorBufferMailbox) { 278 if (!frontColorBufferMailbox) {
279 TextureInfo newTexture = createTextureAndAllocateMemory(m_size); 279 frontColorBufferMailbox = createNewMailbox(createTextureAndAllocateMemor y(m_size));
280 // Bad things happened, abandon ship.
281 if (!newTexture.textureId)
282 return false;
283
284 frontColorBufferMailbox = createNewMailbox(newTexture);
285 } 280 }
286 281
287 if (m_preserveDrawingBuffer == Discard) { 282 if (m_preserveDrawingBuffer == Discard) {
288 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer); 283 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer);
289 // It appears safe to overwrite the context's framebuffer binding in the Discard case since there will always be a 284 // It appears safe to overwrite the context's framebuffer binding in the Discard case since there will always be a
290 // WebGLRenderingContext::clearIfComposited() call made before the next draw call which restores the framebuffer binding. 285 // WebGLRenderingContext::clearIfComposited() call made before the next draw call which restores the framebuffer binding.
291 // If this stops being true at some point, we should track the current f ramebuffer binding in the DrawingBuffer and restore 286 // If this stops being true at some point, we should track the current f ramebuffer binding in the DrawingBuffer and restore
292 // it after attaching the new back buffer here. 287 // it after attaching the new back buffer here.
293 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); 288 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
294 attachColorBufferToCurrentFBO(); 289 attachColorBufferToCurrentFBO();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 427
433 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) 428 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox)
434 { 429 {
435 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { 430 for (size_t i = 0; i < m_textureMailboxes.size(); i++) {
436 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { 431 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) {
437 if (mailbox.validSyncToken) 432 if (mailbox.validSyncToken)
438 m_gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); 433 m_gl->WaitSyncTokenCHROMIUM(mailbox.syncToken);
439 434
440 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); 435 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo);
441 436
442 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI d); 437 m_gl->DeleteTextures(1, &m_textureMailboxes[i]->textureInfo.textureI d);
443 m_textureMailboxes.remove(i); 438 m_textureMailboxes.remove(i);
444 return; 439 return;
445 } 440 }
446 } 441 }
447 ASSERT_NOT_REACHED(); 442 ASSERT_NOT_REACHED();
448 } 443 }
449 444
450 bool DrawingBuffer::initialize(const IntSize& size) 445 bool DrawingBuffer::initialize(const IntSize& size)
451 { 446 {
452 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { 447 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) {
453 // Need to try to restore the context again later. 448 // Need to try to restore the context again later.
454 return false; 449 return false;
455 } 450 }
456 451
457 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); 452 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize);
458 453
459 int maxSampleCount = 0; 454 int maxSampleCount = 0;
460 m_antiAliasingMode = None; 455 m_antiAliasingMode = None;
461 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) { 456 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) {
462 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); 457 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount);
463 m_antiAliasingMode = MSAAExplicitResolve; 458 m_antiAliasingMode = MSAAExplicitResolve;
464 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) { 459 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) {
465 m_antiAliasingMode = MSAAImplicitResolve; 460 m_antiAliasingMode = MSAAImplicitResolve;
466 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) { 461 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) {
467 m_antiAliasingMode = ScreenSpaceAntialiasing; 462 m_antiAliasingMode = ScreenSpaceAntialiasing;
468 } 463 }
469 } 464 }
470 m_sampleCount = std::min(4, maxSampleCount); 465 m_sampleCount = std::min(4, maxSampleCount);
471 466
472 m_fbo = m_context->createFramebuffer(); 467 m_gl->GenFramebuffers(1, &m_fbo);
473 468
474 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); 469 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
475 createSecondaryBuffers(); 470 createSecondaryBuffers();
476 // We first try to initialize everything with the requested attributes. 471 // We first try to initialize everything with the requested attributes.
477 if (!reset(size)) 472 if (!reset(size))
478 return false; 473 return false;
479 // If that succeeds, we then see what we actually got and update our actual attributes to reflect that. 474 // If that succeeds, we then see what we actually got and update our actual attributes to reflect that.
480 m_actualAttributes = m_requestedAttributes; 475 m_actualAttributes = m_requestedAttributes;
481 if (m_requestedAttributes.alpha) { 476 if (m_requestedAttributes.alpha) {
482 WGC3Dint alphaBits = 0; 477 WGC3Dint alphaBits = 0;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 538
544 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; 539 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE;
545 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; 540 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE;
546 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr emultiplyAlpha) 541 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr emultiplyAlpha)
547 unpackUnpremultiplyAlphaNeeded = GL_TRUE; 542 unpackUnpremultiplyAlphaNeeded = GL_TRUE;
548 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha && premultiplyAlpha) 543 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha && premultiplyAlpha)
549 unpackPremultiplyAlphaNeeded = GL_TRUE; 544 unpackPremultiplyAlphaNeeded = GL_TRUE;
550 545
551 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl ipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded); 546 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl ipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded);
552 547
553 context->deleteTexture(sourceTexture); 548 gl->DeleteTextures(1, &sourceTexture);
554 549
555 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); 550 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM();
556 551
557 gl->Flush(); 552 gl->Flush();
558 GLbyte syncToken[24]; 553 GLbyte syncToken[24];
559 gl->GenSyncTokenCHROMIUM(fenceSync, syncToken); 554 gl->GenSyncTokenCHROMIUM(fenceSync, syncToken);
560 m_gl->WaitSyncTokenCHROMIUM(syncToken); 555 m_gl->WaitSyncTokenCHROMIUM(syncToken);
561 556
562 return true; 557 return true;
563 } 558 }
(...skipping 30 matching lines...) Expand all
594 { 589 {
595 ASSERT(!m_destructionInProgress); 590 ASSERT(!m_destructionInProgress);
596 m_destructionInProgress = true; 591 m_destructionInProgress = true;
597 592
598 clearPlatformLayer(); 593 clearPlatformLayer();
599 594
600 while (!m_recycledMailboxQueue.isEmpty()) 595 while (!m_recycledMailboxQueue.isEmpty())
601 deleteMailbox(m_recycledMailboxQueue.takeLast()); 596 deleteMailbox(m_recycledMailboxQueue.takeLast());
602 597
603 if (m_multisampleFBO) 598 if (m_multisampleFBO)
604 m_context->deleteFramebuffer(m_multisampleFBO); 599 m_gl->DeleteFramebuffers(1, &m_multisampleFBO);
605 600
606 if (m_fbo) 601 if (m_fbo)
607 m_context->deleteFramebuffer(m_fbo); 602 m_gl->DeleteFramebuffers(1, &m_fbo);
608 603
609 if (m_multisampleColorBuffer) 604 if (m_multisampleColorBuffer)
610 m_context->deleteRenderbuffer(m_multisampleColorBuffer); 605 m_gl->DeleteRenderbuffers(1, &m_multisampleColorBuffer);
611 606
612 if (m_depthStencilBuffer) 607 if (m_depthStencilBuffer)
613 m_context->deleteRenderbuffer(m_depthStencilBuffer); 608 m_gl->DeleteRenderbuffers(1, &m_depthStencilBuffer);
614 609
615 if (m_colorBuffer.textureId) { 610 if (m_colorBuffer.textureId) {
616 deleteChromiumImageForTexture(&m_colorBuffer); 611 deleteChromiumImageForTexture(&m_colorBuffer);
617 m_context->deleteTexture(m_colorBuffer.textureId); 612 m_gl->DeleteTextures(1, &m_colorBuffer.textureId);
618 } 613 }
619 614
620 setSize(IntSize()); 615 setSize(IntSize());
621 616
622 m_colorBuffer = TextureInfo(); 617 m_colorBuffer = TextureInfo();
623 m_frontColorBuffer = FrontBufferInfo(); 618 m_frontColorBuffer = FrontBufferInfo();
624 m_multisampleColorBuffer = 0; 619 m_multisampleColorBuffer = 0;
625 m_depthStencilBuffer = 0; 620 m_depthStencilBuffer = 0;
626 m_multisampleFBO = 0; 621 m_multisampleFBO = 0;
627 m_fbo = 0; 622 m_fbo = 0;
628 623
629 if (m_layer) 624 if (m_layer)
630 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); 625 GraphicsLayer::unregisterContentsLayer(m_layer->layer());
631 } 626 }
632 627
633 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) 628 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters)
634 { 629 {
635 WebGLId offscreenColorTexture = m_context->createTexture(); 630 GLuint offscreenColorTexture;
636 if (!offscreenColorTexture) 631 m_gl->GenTextures(1, &offscreenColorTexture);
637 return 0;
638
639 m_gl->BindTexture(parameters.target, offscreenColorTexture); 632 m_gl->BindTexture(parameters.target, offscreenColorTexture);
640 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 633 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
641 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 634 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
642 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 635 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
643 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 636 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
644
645 return offscreenColorTexture; 637 return offscreenColorTexture;
646 } 638 }
647 639
648 void DrawingBuffer::createSecondaryBuffers() 640 void DrawingBuffer::createSecondaryBuffers()
649 { 641 {
650 // create a multisample FBO 642 // create a multisample FBO
651 if (m_antiAliasingMode == MSAAExplicitResolve) { 643 if (m_antiAliasingMode == MSAAExplicitResolve) {
652 m_multisampleFBO = m_context->createFramebuffer(); 644 m_gl->GenFramebuffers(1, &m_multisampleFBO);
653 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); 645 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO);
654 m_multisampleColorBuffer = m_context->createRenderbuffer(); 646 m_gl->GenRenderbuffers(1, &m_multisampleColorBuffer);
655 } 647 }
656 } 648 }
657 649
658 bool DrawingBuffer::resizeFramebuffer(const IntSize& size) 650 bool DrawingBuffer::resizeFramebuffer(const IntSize& size)
659 { 651 {
660 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); 652 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo);
661 if (m_antiAliasingMode != MSAAExplicitResolve) 653 if (m_antiAliasingMode != MSAAExplicitResolve)
662 resizeDepthStencil(size); 654 resizeDepthStencil(size);
663 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) 655 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
664 return false; 656 return false;
(...skipping 20 matching lines...) Expand all
685 677
686 return true; 678 return true;
687 } 679 }
688 680
689 void DrawingBuffer::resizeDepthStencil(const IntSize& size) 681 void DrawingBuffer::resizeDepthStencil(const IntSize& size)
690 { 682 {
691 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) 683 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil)
692 return; 684 return;
693 685
694 if (!m_depthStencilBuffer) 686 if (!m_depthStencilBuffer)
695 m_depthStencilBuffer = m_context->createRenderbuffer(); 687 m_gl->GenRenderbuffers(1, &m_depthStencilBuffer);
696 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); 688 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer);
697 if (m_antiAliasingMode == MSAAImplicitResolve) 689 if (m_antiAliasingMode == MSAAImplicitResolve)
698 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); 690 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height());
699 else if (m_antiAliasingMode == MSAAExplicitResolve) 691 else if (m_antiAliasingMode == MSAAExplicitResolve)
700 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); 692 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height());
701 else 693 else
702 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size .width(), size.height()); 694 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size .width(), size.height());
703 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G L_RENDERBUFFER, m_depthStencilBuffer); 695 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G L_RENDERBUFFER, m_depthStencilBuffer);
704 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); 696 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0);
705 } 697 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 height = size().height(); 863 height = size().height();
872 864
873 Checked<int, RecordOverflow> dataSize = 4; 865 Checked<int, RecordOverflow> dataSize = 4;
874 dataSize *= width; 866 dataSize *= width;
875 dataSize *= height; 867 dataSize *= height;
876 if (dataSize.hasOverflowed()) 868 if (dataSize.hasOverflowed())
877 return false; 869 return false;
878 870
879 WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents: :NotShared, WTF::ArrayBufferContents::DontInitialize); 871 WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents: :NotShared, WTF::ArrayBufferContents::DontInitialize);
880 872
881 GLint fbo = 0; 873 GLuint fbo = 0;
882 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { 874 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) {
883 fbo = m_context->createFramebuffer(); 875 m_gl->GenFramebuffers(1, &fbo);
884 m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); 876 m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
885 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0); 877 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0);
886 } else { 878 } else {
887 m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer()); 879 m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer());
888 } 880 }
889 881
890 readBackFramebuffer(static_cast<unsigned char*>(pixels.data()), width, heigh t, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing); 882 readBackFramebuffer(static_cast<unsigned char*>(pixels.data()), width, heigh t, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing);
891 flipVertically(static_cast<uint8_t*>(pixels.data()), width, height); 883 flipVertically(static_cast<uint8_t*>(pixels.data()), width, height);
892 884
893 if (fbo) { 885 if (fbo) {
894 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, 0, 0); 886 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, 0, 0);
895 m_context->deleteFramebuffer(fbo); 887 m_gl->DeleteFramebuffers(1, &fbo);
896 } 888 }
897 889
898 restoreFramebufferBindings(); 890 restoreFramebufferBindings();
899 891
900 pixels.transfer(contents); 892 pixels.transfer(contents);
901 return true; 893 return true;
902 } 894 }
903 895
904 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op) 896 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op)
905 { 897 {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 return createDefaultTextureAndAllocateMemory(size); 967 return createDefaultTextureAndAllocateMemory(size);
976 968
977 // First, try to allocate a CHROMIUM_image. This always has the potential to 969 // First, try to allocate a CHROMIUM_image. This always has the potential to
978 // fail. 970 // fail.
979 TextureParameters parameters = chromiumImageTextureParameters(); 971 TextureParameters parameters = chromiumImageTextureParameters();
980 WGC3Duint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s ize.height(), parameters.internalColorFormat, GC3D_SCANOUT_CHROMIUM); 972 WGC3Duint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s ize.height(), parameters.internalColorFormat, GC3D_SCANOUT_CHROMIUM);
981 if (!imageId) 973 if (!imageId)
982 return createDefaultTextureAndAllocateMemory(size); 974 return createDefaultTextureAndAllocateMemory(size);
983 975
984 WebGLId textureId = createColorTexture(parameters); 976 WebGLId textureId = createColorTexture(parameters);
985 if (!textureId) {
986 m_gl->DestroyImageCHROMIUM(imageId);
987 return createDefaultTextureAndAllocateMemory(size);
988 }
989
990 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); 977 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId);
991 978
992 TextureInfo info; 979 TextureInfo info;
993 info.textureId = textureId; 980 info.textureId = textureId;
994 info.imageId = imageId; 981 info.imageId = imageId;
995 info.parameters = parameters; 982 info.parameters = parameters;
996 return info; 983 return info;
997 } 984 }
998 985
999 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory( const IntSize& size) 986 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory( const IntSize& size)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 1025
1039 if (m_antiAliasingMode == MSAAImplicitResolve) 1026 if (m_antiAliasingMode == MSAAImplicitResolve)
1040 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); 1027 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount);
1041 else 1028 else
1042 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_colorBuffer.textureId, 0); 1029 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_colorBuffer.textureId, 0);
1043 1030
1044 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1031 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1045 } 1032 }
1046 1033
1047 } // namespace blink 1034 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698