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

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: layout test fails 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
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.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) 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 if (!drawingBuffer())
639 return nullptr;
640 GrContext* grContext = drawingBuffer()->contextProvider()->grContext();
641 if (!grContext)
642 return nullptr;
643 SkAlphaType alphaType = (m_requestedAttributes.premultipliedAlpha()) ? kPrem ul_SkAlphaType : kOpaque_SkAlphaType;
644 SkImageInfo info = SkImageInfo::MakeN32(drawingBufferWidth(), drawingBufferH eight(), alphaType);
645 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry);
646 sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(grContext, SkBudgeted ::kNo, info, 0, (m_requestedAttributes.premultipliedAlpha()) ? &disableLCDProps : nullptr);
xidachen 2016/05/13 18:56:08 junov@: could you take a look? I am not sure what
Ken Russell (switch to Gerrit) 2016/05/13 20:08:30 The code above is referencing the Ganesh context f
Justin Novosad 2016/05/13 20:36:27 I agree with what Ken wrote. Sorry for the bad pa
647 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(surface->makeIma geSnapshot(SkBudgeted::kNo).release());
648 ImageBitmap* imageBitmap = ImageBitmap::create(image.release());
649 return imageBitmap;
650 }
651
636 namespace { 652 namespace {
637 653
638 // ES2 enums 654 // ES2 enums
639 static const GLenum kSupportedInternalFormatsES2[] = { 655 static const GLenum kSupportedInternalFormatsES2[] = {
640 GL_RGB, 656 GL_RGB,
641 GL_RGBA, 657 GL_RGBA,
642 GL_LUMINANCE_ALPHA, 658 GL_LUMINANCE_ALPHA,
643 GL_LUMINANCE, 659 GL_LUMINANCE,
644 GL_ALPHA, 660 GL_ALPHA,
645 }; 661 };
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 m_drawingBuffer.clear(); 1173 m_drawingBuffer.clear();
1158 } 1174 }
1159 1175
1160 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) 1176 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType)
1161 { 1177 {
1162 if (m_framebufferBinding || isContextLost()) 1178 if (m_framebufferBinding || isContextLost())
1163 return; 1179 return;
1164 1180
1165 drawingBuffer()->markContentsChanged(); 1181 drawingBuffer()->markContentsChanged();
1166 1182
1183 if (!canvas())
1184 return;
1185
1167 LayoutBox* layoutBox = canvas()->layoutBox(); 1186 LayoutBox* layoutBox = canvas()->layoutBox();
1168 if (layoutBox && layoutBox->hasAcceleratedCompositing()) { 1187 if (layoutBox && layoutBox->hasAcceleratedCompositing()) {
1169 m_markedCanvasDirty = true; 1188 m_markedCanvasDirty = true;
1170 canvas()->clearCopiedImage(); 1189 canvas()->clearCopiedImage();
1171 layoutBox->contentChanged(changeType); 1190 layoutBox->contentChanged(changeType);
1172 } else { 1191 } else {
1173 if (!m_markedCanvasDirty) { 1192 if (!m_markedCanvasDirty) {
1174 m_markedCanvasDirty = true; 1193 m_markedCanvasDirty = true;
1175 canvas()->didDraw(FloatRect(FloatPoint(0, 0), FloatSize(clampedCanva sSize()))); 1194 canvas()->didDraw(FloatRect(FloatPoint(0, 0), FloatSize(clampedCanva sSize())));
1176 } 1195 }
(...skipping 5184 matching lines...) Expand 10 before | Expand all | Expand 10 after
6361 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); 6380 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
6362 } 6381 }
6363 6382
6364 void WebGLRenderingContextBase::restoreUnpackParameters() 6383 void WebGLRenderingContextBase::restoreUnpackParameters()
6365 { 6384 {
6366 if (m_unpackAlignment != 1) 6385 if (m_unpackAlignment != 1)
6367 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 6386 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
6368 } 6387 }
6369 6388
6370 } // namespace blink 6389 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698