Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 #include "platform/CheckedInt.h" | 85 #include "platform/CheckedInt.h" |
| 86 #include "platform/RuntimeEnabledFeatures.h" | 86 #include "platform/RuntimeEnabledFeatures.h" |
| 87 #include "platform/ThreadSafeFunctional.h" | 87 #include "platform/ThreadSafeFunctional.h" |
| 88 #include "platform/WaitableEvent.h" | 88 #include "platform/WaitableEvent.h" |
| 89 #include "platform/geometry/IntSize.h" | 89 #include "platform/geometry/IntSize.h" |
| 90 #include "platform/graphics/GraphicsContext.h" | 90 #include "platform/graphics/GraphicsContext.h" |
| 91 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 91 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 92 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 92 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
| 93 #include "public/platform/Platform.h" | 93 #include "public/platform/Platform.h" |
| 94 #include "public/platform/functional/WebFunction.h" | 94 #include "public/platform/functional/WebFunction.h" |
| 95 #include "skia/ext/texture_handle.h" | |
| 95 #include "wtf/Functional.h" | 96 #include "wtf/Functional.h" |
| 96 #include "wtf/PassOwnPtr.h" | 97 #include "wtf/PassOwnPtr.h" |
| 97 #include "wtf/text/StringBuilder.h" | 98 #include "wtf/text/StringBuilder.h" |
| 98 #include "wtf/text/StringUTF8Adaptor.h" | 99 #include "wtf/text/StringUTF8Adaptor.h" |
| 99 #include "wtf/typed_arrays/ArrayBufferContents.h" | 100 #include "wtf/typed_arrays/ArrayBufferContents.h" |
| 100 | 101 |
| 101 #include <memory> | 102 #include <memory> |
| 102 | 103 |
| 103 namespace blink { | 104 namespace blink { |
| 104 | 105 |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(ScriptState* scriptState, WebGLContextAttributes attribut es, unsigned webGLVersion) | 628 PassOwnPtr<WebGraphicsContext3DProvider> WebGLRenderingContextBase::createWebGra phicsContext3DProvider(ScriptState* scriptState, WebGLContextAttributes attribut es, unsigned webGLVersion) |
| 628 { | 629 { |
| 629 return createContextProviderInternal(nullptr, scriptState, attributes, webGL Version); | 630 return createContextProviderInternal(nullptr, scriptState, attributes, webGL Version); |
| 630 } | 631 } |
| 631 | 632 |
| 632 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail() | 633 void WebGLRenderingContextBase::forceNextWebGLContextCreationToFail() |
| 633 { | 634 { |
| 634 shouldFailContextCreationForTesting = true; | 635 shouldFailContextCreationForTesting = true; |
| 635 } | 636 } |
| 636 | 637 |
| 638 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() | |
| 639 { | |
| 640 if (!drawingBuffer()) | |
| 641 return nullptr; | |
| 642 GrContext* grContext = drawingBuffer()->contextProvider()->grContext(); | |
| 643 if (!grContext) | |
| 644 return nullptr; | |
| 645 SkAlphaType alphaType = (m_requestedAttributes.premultipliedAlpha()) ? kPrem ul_SkAlphaType : kOpaque_SkAlphaType; | |
| 646 SkImageInfo info = SkImageInfo::MakeN32(drawingBufferWidth(), drawingBufferH eight(), alphaType); | |
| 647 SkSurfaceProps disableLCDProps(0, kUnknown_SkPixelGeometry); | |
| 648 sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(grContext, SkBudgeted ::kYes, info, 0, (m_requestedAttributes.premultipliedAlpha()) ? &disableLCDProps : nullptr); | |
| 649 gpu::gles2::GLES2Interface* gl = drawingBuffer()->contextProvider()->context GL(); | |
| 650 GLuint textureId = skia::GrBackendObjectToGrGLTextureInfo(surface->getTextur eHandle(SkSurface::kDiscardWrite_TextureHandleAccess))->fID; | |
| 651 if (!textureId) | |
| 652 return nullptr; | |
| 653 gl->Flush(); | |
| 654 if (!(drawingBuffer()->copyToPlatformTexture(gl, textureId, GL_RGBA, GL_UNSI GNED_BYTE, 0, true, false, BackBuffer))) | |
|
xidachen
2016/05/17 17:02:00
It turns out that we can consume the texture in he
Ken Russell (switch to Gerrit)
2016/05/18 01:20:41
DrawingBuffer::copyToPlatformTexture, as the name
xidachen
2016/05/18 15:13:36
Sorry for the delay. I should have used mailbox fr
| |
| 655 return nullptr; | |
| 656 RefPtr<StaticBitmapImage> image = StaticBitmapImage::create(fromSkSp(surface ->makeImageSnapshot())); | |
| 657 ImageBitmap* imageBitmap = ImageBitmap::create(image.release()); | |
| 658 return imageBitmap; | |
| 659 } | |
| 660 | |
| 637 namespace { | 661 namespace { |
| 638 | 662 |
| 639 // ES2 enums | 663 // ES2 enums |
| 640 static const GLenum kSupportedInternalFormatsES2[] = { | 664 static const GLenum kSupportedInternalFormatsES2[] = { |
| 641 GL_RGB, | 665 GL_RGB, |
| 642 GL_RGBA, | 666 GL_RGBA, |
| 643 GL_LUMINANCE_ALPHA, | 667 GL_LUMINANCE_ALPHA, |
| 644 GL_LUMINANCE, | 668 GL_LUMINANCE, |
| 645 GL_ALPHA, | 669 GL_ALPHA, |
| 646 }; | 670 }; |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 m_drawingBuffer.clear(); | 1182 m_drawingBuffer.clear(); |
| 1159 } | 1183 } |
| 1160 | 1184 |
| 1161 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) | 1185 void WebGLRenderingContextBase::markContextChanged(ContentChangeType changeType) |
| 1162 { | 1186 { |
| 1163 if (m_framebufferBinding || isContextLost()) | 1187 if (m_framebufferBinding || isContextLost()) |
| 1164 return; | 1188 return; |
| 1165 | 1189 |
| 1166 drawingBuffer()->markContentsChanged(); | 1190 drawingBuffer()->markContentsChanged(); |
| 1167 | 1191 |
| 1192 if (!canvas()) | |
| 1193 return; | |
| 1194 | |
| 1168 LayoutBox* layoutBox = canvas()->layoutBox(); | 1195 LayoutBox* layoutBox = canvas()->layoutBox(); |
| 1169 if (layoutBox && layoutBox->hasAcceleratedCompositing()) { | 1196 if (layoutBox && layoutBox->hasAcceleratedCompositing()) { |
| 1170 m_markedCanvasDirty = true; | 1197 m_markedCanvasDirty = true; |
| 1171 canvas()->clearCopiedImage(); | 1198 canvas()->clearCopiedImage(); |
| 1172 layoutBox->contentChanged(changeType); | 1199 layoutBox->contentChanged(changeType); |
| 1173 } else { | 1200 } else { |
| 1174 if (!m_markedCanvasDirty) { | 1201 if (!m_markedCanvasDirty) { |
| 1175 m_markedCanvasDirty = true; | 1202 m_markedCanvasDirty = true; |
| 1176 canvas()->didDraw(FloatRect(FloatPoint(0, 0), FloatSize(clampedCanva sSize()))); | 1203 canvas()->didDraw(FloatRect(FloatPoint(0, 0), FloatSize(clampedCanva sSize()))); |
| 1177 } | 1204 } |
| (...skipping 5206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6384 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); | 6411 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 6385 } | 6412 } |
| 6386 | 6413 |
| 6387 void WebGLRenderingContextBase::restoreUnpackParameters() | 6414 void WebGLRenderingContextBase::restoreUnpackParameters() |
| 6388 { | 6415 { |
| 6389 if (m_unpackAlignment != 1) | 6416 if (m_unpackAlignment != 1) |
| 6390 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 6417 contextGL()->PixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 6391 } | 6418 } |
| 6392 | 6419 |
| 6393 } // namespace blink | 6420 } // namespace blink |
| OLD | NEW |