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

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

Issue 1962413002: Implement transferToImageBitmap() in WebGLRenderingContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(ScriptState* scriptState, WebGLContextAttributes attribut es, unsigned webGLVersion) 626 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(ScriptState* scriptState, WebGLContextAttributes attribut es, unsigned webGLVersion)
627 { 627 {
628 return createContextProviderInternal(nullptr, scriptState, attributes, webGL Version); 628 return createContextProviderInternal(nullptr, scriptState, attributes, webGL Version);
629 } 629 }
630 630
631 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail() 631 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail()
632 { 632 {
633 shouldFailContextCreationForTesting = true; 633 shouldFailContextCreationForTesting = true;
634 } 634 }
635 635
636 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase()
637 {
638 ImageData* imageData = paintRenderingResultsToImageData(BackBuffer);
Ken Russell (switch to Gerrit) 2016/05/10 23:11:42 This needs to be much better optimized in the futu
xidachen 2016/05/11 00:17:52 In the case of 2d canvas context, it contains a Im
639 if (!imageData)
640 return nullptr;
641 return ImageBitmap::create(imageData, IntRect(0, 0, imageData->width(), imag eData->height()));
642 }
643
636 namespace { 644 namespace {
637 645
638 // ES2 enums 646 // ES2 enums
639 static const GLenum kSupportedInternalFormatsES2[] = { 647 static const GLenum kSupportedInternalFormatsES2[] = {
640 GL_RGB, 648 GL_RGB,
641 GL_RGBA, 649 GL_RGBA,
642 GL_LUMINANCE_ALPHA, 650 GL_LUMINANCE_ALPHA,
643 GL_LUMINANCE, 651 GL_LUMINANCE,
644 GL_ALPHA, 652 GL_ALPHA,
645 }; 653 };
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 m_drawingBuffer.clear(); 1165 m_drawingBuffer.clear();
1158 } 1166 }
1159 1167
1160 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) 1168 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType)
1161 { 1169 {
1162 if (m_framebufferBinding || isContextLost()) 1170 if (m_framebufferBinding || isContextLost())
1163 return; 1171 return;
1164 1172
1165 drawingBuffer()->markContentsChanged(); 1173 drawingBuffer()->markContentsChanged();
1166 1174
1175 if (!canvas())
1176 return;
1177
1167 LayoutBox* layoutBox = canvas()->layoutBox(); 1178 LayoutBox* layoutBox = canvas()->layoutBox();
1168 if (layoutBox && layoutBox->hasAcceleratedCompositing()) { 1179 if (layoutBox && layoutBox->hasAcceleratedCompositing()) {
1169 m_markedCanvasDirty = true; 1180 m_markedCanvasDirty = true;
1170 canvas()->clearCopiedImage(); 1181 canvas()->clearCopiedImage();
1171 layoutBox->contentChanged(changeType); 1182 layoutBox->contentChanged(changeType);
1172 } else { 1183 } else {
1173 if (!m_markedCanvasDirty) { 1184 if (!m_markedCanvasDirty) {
1174 m_markedCanvasDirty = true; 1185 m_markedCanvasDirty = true;
1175 canvas()->didDraw(FloatRect(FloatPoint(0, 0), FloatSize(clampedCanva sSize()))); 1186 canvas()->didDraw(FloatRect(FloatPoint(0, 0), FloatSize(clampedCanva sSize())));
1176 } 1187 }
(...skipping 5184 matching lines...) Expand 10 before | Expand all | Expand 10 after
6361 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); 6372 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
6362 } 6373 }
6363 6374
6364 void WebGLRenderingContextBase::restoreUnpackParameters() 6375 void WebGLRenderingContextBase::restoreUnpackParameters()
6365 { 6376 {
6366 if (m_unpackAlignment != 1) 6377 if (m_unpackAlignment != 1)
6367 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6378 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6368 } 6379 }
6369 6380
6370 } // namespace blink 6381 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698