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

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

Issue 749653002: WebGL: clarify which Front or Back buffer is used by each API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address nits Created 6 years 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
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (m_requestedAttributes.stencil) { 452 if (m_requestedAttributes.stencil) {
453 WGC3Dint stencilBits = 0; 453 WGC3Dint stencilBits = 0;
454 m_context->getIntegerv(GL_STENCIL_BITS, &stencilBits); 454 m_context->getIntegerv(GL_STENCIL_BITS, &stencilBits);
455 m_actualAttributes.stencil = stencilBits > 0; 455 m_actualAttributes.stencil = stencilBits > 0;
456 } 456 }
457 m_actualAttributes.antialias = multisample(); 457 m_actualAttributes.antialias = multisample();
458 return true; 458 return true;
459 } 459 }
460 460
461 bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platfor m3DObject texture, GLenum internalFormat, 461 bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platfor m3DObject texture, GLenum internalFormat,
462 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceBuffe r source) 462 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY, SourceDrawi ngBuffer sourceBuffer)
463 { 463 {
464 if (m_contentsChanged) { 464 if (m_contentsChanged) {
465 if (m_multisampleMode != None) { 465 if (m_multisampleMode != None) {
466 commit(); 466 commit();
467 if (!m_framebufferBinding) 467 if (!m_framebufferBinding)
468 bind(); 468 bind();
469 else 469 else
470 restoreFramebufferBinding(); 470 restoreFramebufferBinding();
471 } 471 }
472 m_context->flush(); 472 m_context->flush();
473 } 473 }
474 474
475 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, l evel)) 475 if (!Extensions3DUtil::canUseCopyTextureCHROMIUM(internalFormat, destType, l evel))
476 return false; 476 return false;
477 477
478 // Contexts may be in a different share group. We must transfer the texture through a mailbox first 478 // Contexts may be in a different share group. We must transfer the texture through a mailbox first
479 WebExternalTextureMailbox mailbox; 479 WebExternalTextureMailbox mailbox;
480 GLint textureId = 0; 480 GLint textureId = 0;
481 if (source == Front && m_frontColorBuffer.texInfo.textureId) { 481 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) {
482 textureId = m_frontColorBuffer.texInfo.textureId; 482 textureId = m_frontColorBuffer.texInfo.textureId;
483 mailbox = m_frontColorBuffer.mailbox; 483 mailbox = m_frontColorBuffer.mailbox;
484 } else { 484 } else {
485 textureId = m_colorBuffer.textureId; 485 textureId = m_colorBuffer.textureId;
486 m_context->genMailboxCHROMIUM(mailbox.name); 486 m_context->genMailboxCHROMIUM(mailbox.name);
487 m_context->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo x.name); 487 m_context->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo x.name);
488 m_context->flush(); 488 m_context->flush();
489 mailbox.syncPoint = m_context->insertSyncPoint(); 489 mailbox.syncPoint = m_context->insertSyncPoint();
490 } 490 }
491 491
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 void DrawingBuffer::setPackAlignment(GLint param) 880 void DrawingBuffer::setPackAlignment(GLint param)
881 { 881 {
882 m_packAlignment = param; 882 m_packAlignment = param;
883 } 883 }
884 884
885 void DrawingBuffer::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer) 885 void DrawingBuffer::paintRenderingResultsToCanvas(ImageBuffer* imageBuffer)
886 { 886 {
887 paintFramebufferToCanvas(framebuffer(), size().width(), size().height(), !m_ actualAttributes.premultipliedAlpha, imageBuffer); 887 paintFramebufferToCanvas(framebuffer(), size().width(), size().height(), !m_ actualAttributes.premultipliedAlpha, imageBuffer);
888 } 888 }
889 889
890 PassRefPtr<Uint8ClampedArray> DrawingBuffer::paintRenderingResultsToImageData(in t& width, int& height) 890 PassRefPtr<Uint8ClampedArray> DrawingBuffer::paintRenderingResultsToImageData(in t& width, int& height, SourceDrawingBuffer sourceBuffer)
891 { 891 {
892 if (m_actualAttributes.premultipliedAlpha) 892 if (m_actualAttributes.premultipliedAlpha)
893 return nullptr; 893 return nullptr;
894 894
895 width = size().width(); 895 width = size().width();
896 height = size().height(); 896 height = size().height();
897 897
898 Checked<int, RecordOverflow> dataSize = 4; 898 Checked<int, RecordOverflow> dataSize = 4;
899 dataSize *= width; 899 dataSize *= width;
900 dataSize *= height; 900 dataSize *= height;
901 if (dataSize.hasOverflowed()) 901 if (dataSize.hasOverflowed())
902 return nullptr; 902 return nullptr;
903 903
904 RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(wi dth * height * 4); 904 RefPtr<Uint8ClampedArray> pixels = Uint8ClampedArray::createUninitialized(wi dth * height * 4);
905 905
906 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer()); 906 GLint fbo = 0;
907 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) {
908 GLint fbo = m_context->createFramebuffer();
Yuki 2014/11/27 04:30:22 Hi dongseong.hwang, It seems that you're shadowin
dshwang 2014/11/27 09:46:30 Thank you very much for noting! it's a mistake.
909 m_context->bindFramebuffer(GL_FRAMEBUFFER, fbo);
910 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL _TEXTURE_2D, m_frontColorBuffer.texInfo.textureId, 0);
911 } else {
912 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer());
913 }
914
907 readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, WebGLImageC onversion::AlphaDoNothing); 915 readBackFramebuffer(pixels->data(), width, height, ReadbackRGBA, WebGLImageC onversion::AlphaDoNothing);
908 flipVertically(pixels->data(), width, height); 916 flipVertically(pixels->data(), width, height);
909 917
918 if (fbo) {
919 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL _TEXTURE_2D, 0, 0);
920 m_context->deleteFramebuffer(fbo);
921 }
922
923 if (m_framebufferBinding) {
924 restoreFramebufferBinding();
925 } else {
926 bind();
927 }
928
910 return pixels.release(); 929 return pixels.release();
911 } 930 }
912 931
913 void DrawingBuffer::paintFramebufferToCanvas(int framebuffer, int width, int hei ght, bool premultiplyAlpha, ImageBuffer* imageBuffer) 932 void DrawingBuffer::paintFramebufferToCanvas(int framebuffer, int width, int hei ght, bool premultiplyAlpha, ImageBuffer* imageBuffer)
914 { 933 {
915 unsigned char* pixels = 0; 934 unsigned char* pixels = 0;
916 935
917 const SkBitmap& canvasBitmap = imageBuffer->bitmap(); 936 const SkBitmap& canvasBitmap = imageBuffer->bitmap();
918 const SkBitmap* readbackBitmap = 0; 937 const SkBitmap* readbackBitmap = 0;
919 ASSERT(canvasBitmap.colorType() == kN32_SkColorType); 938 ASSERT(canvasBitmap.colorType() == kN32_SkColorType);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) 1040 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info)
1022 { 1041 {
1023 if (info->imageId) { 1042 if (info->imageId) {
1024 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); 1043 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId);
1025 m_context->destroyImageCHROMIUM(info->imageId); 1044 m_context->destroyImageCHROMIUM(info->imageId);
1026 info->imageId = 0; 1045 info->imageId = 0;
1027 } 1046 }
1028 } 1047 }
1029 1048
1030 } // namespace blink 1049 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698