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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2139353003: Return a transparent black ImageBitmap when mailbox is invalid (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 { 635 {
636 shouldFailContextCreationForTesting = true; 636 shouldFailContextCreationForTesting = true;
637 } 637 }
638 638
639 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() 639 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase()
640 { 640 {
641 if (!drawingBuffer()) 641 if (!drawingBuffer())
642 return nullptr; 642 return nullptr;
643 WebExternalTextureMailbox mailbox; 643 WebExternalTextureMailbox mailbox;
644 drawingBuffer()->prepareMailbox(&mailbox, 0); 644 drawingBuffer()->prepareMailbox(&mailbox, 0);
645 ImageBitmap* imageBitmap = ImageBitmap::create(mailbox); 645 ImageBitmap* imageBitmap;
646 // If the mailbox is invalid, return an transparent black ImageBitmap
Ken Russell (switch to Gerrit) 2016/07/12 22:52:04 Could you add a comment saying that the only situa
647 if (mailbox.textureSize.width == 0 && mailbox.textureSize.height == 0) {
648 sk_sp<SkSurface>surface = SkSurface::MakeRasterN32Premul(drawingBuffer() ->size().width(), drawingBuffer()->size().height());
649 imageBitmap = ImageBitmap::create(StaticBitmapImage::create(fromSkSp(sur face->makeImageSnapshot())));
650 } else {
651 imageBitmap = ImageBitmap::create(mailbox);
652 }
646 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap RenderingContext's 653 // TODO(xidachen): Create a small pool of recycled textures from ImageBitmap RenderingContext's
647 // transferFromImageBitmap, and try to use them in DrawingBuffer. 654 // transferFromImageBitmap, and try to use them in DrawingBuffer.
648 return imageBitmap; 655 return imageBitmap;
649 } 656 }
650 657
651 namespace { 658 namespace {
652 659
653 // ES2 enums 660 // ES2 enums
654 static const GLenum kSupportedInternalFormatsES2[] = { 661 static const GLenum kSupportedInternalFormatsES2[] = {
655 GL_RGB, 662 GL_RGB,
(...skipping 5827 matching lines...) Expand 10 before | Expand all | Expand 10 after
6483 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); 6490 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
6484 } 6491 }
6485 6492
6486 void WebGLRenderingContextBase::restoreUnpackParameters() 6493 void WebGLRenderingContextBase::restoreUnpackParameters()
6487 { 6494 {
6488 if (m_unpackAlignment != 1) 6495 if (m_unpackAlignment != 1)
6489 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6496 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6490 } 6497 }
6491 6498
6492 } // namespace blink 6499 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698