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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContextBase.cpp

Issue 179973004: Share Group plumbing in Blink; Remove WebGL from default share group (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed Ken's feedback Created 6 years, 9 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 | Annotate | Revision Log
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 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 clearIfComposited(); 826 clearIfComposited();
827 827
828 if (!m_markedCanvasDirty && !m_layerCleared) 828 if (!m_markedCanvasDirty && !m_layerCleared)
829 return; 829 return;
830 830
831 canvas()->clearCopiedImage(); 831 canvas()->clearCopiedImage();
832 m_markedCanvasDirty = false; 832 m_markedCanvasDirty = false;
833 833
834 m_drawingBuffer->commit(); 834 m_drawingBuffer->commit();
835 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBu ffer.get())) { 835 if (!(canvas()->buffer())->copyRenderingResultsFromDrawingBuffer(m_drawingBu ffer.get())) {
836 restoreCurrentTexture2D();
836 canvas()->ensureUnacceleratedImageBuffer(); 837 canvas()->ensureUnacceleratedImageBuffer();
837 if (canvas()->hasImageBuffer()) 838 if (canvas()->hasImageBuffer())
838 m_drawingBuffer->paintRenderingResultsToCanvas(canvas()->buffer()); 839 m_drawingBuffer->paintRenderingResultsToCanvas(canvas()->buffer());
840 } else {
841 restoreCurrentTexture2D();
839 } 842 }
840 843
841 if (m_framebufferBinding) 844 if (m_framebufferBinding)
842 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin ding.get())); 845 m_context->bindFramebuffer(GL_FRAMEBUFFER, objectOrZero(m_framebufferBin ding.get()));
843 else 846 else
844 m_drawingBuffer->bind(); 847 m_drawingBuffer->bind();
845 } 848 }
846 849
847 PassRefPtr<ImageData> WebGLRenderingContextBase::paintRenderingResultsToImageDat a() 850 PassRefPtr<ImageData> WebGLRenderingContextBase::paintRenderingResultsToImageDat a()
848 { 851 {
(...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after
3407 3410
3408 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); 3411 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true);
3409 // If possible, copy from the canvas element directly to the texture 3412 // If possible, copy from the canvas element directly to the texture
3410 // via the GPU, without a read-back to system memory. 3413 // via the GPU, without a read-back to system memory.
3411 if (GL_TEXTURE_2D == target && texture) { 3414 if (GL_TEXTURE_2D == target && texture) {
3412 if (!canvas->is3D()) { 3415 if (!canvas->is3D()) {
3413 ImageBuffer* buffer = canvas->buffer(); 3416 ImageBuffer* buffer = canvas->buffer();
3414 if (buffer && buffer->copyToPlatformTexture(m_context.get(), texture ->object(), internalformat, type, 3417 if (buffer && buffer->copyToPlatformTexture(m_context.get(), texture ->object(), internalformat, type,
3415 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3418 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3416 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type); 3419 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type);
3420 restoreCurrentTexture2D();
3417 return; 3421 return;
3418 } 3422 }
3419 } else { 3423 } else {
3420 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas-> renderingContext()); 3424 WebGLRenderingContextBase* gl = toWebGLRenderingContextBase(canvas-> renderingContext());
3421 if (gl && gl->m_drawingBuffer->copyToPlatformTexture(m_context.get() , texture->object(), internalformat, type, 3425 if (gl && gl->m_drawingBuffer->copyToPlatformTexture(m_context.get() , texture->object(), internalformat, type,
Ken Russell (switch to Gerrit) 2014/03/13 19:35:54 If the save/restore in DrawingBuffer::copyToPlatfo
3422 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) { 3426 level, m_unpackPremultiplyAlpha, m_unpackFlipY)) {
3423 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type); 3427 texture->setLevelInfo(target, level, internalformat, canvas->wid th(), canvas->height(), type);
3428 restoreCurrentTexture2D();
3424 return; 3429 return;
3425 } 3430 }
3426 } 3431 }
3432 restoreCurrentTexture2D();
Ken Russell (switch to Gerrit) 2014/03/13 19:35:54 It might be worth creating a class which makes the
3427 } 3433 }
3428 3434
3429 RefPtr<ImageData> imageData = canvas->getImageData(); 3435 RefPtr<ImageData> imageData = canvas->getImageData();
3430 if (imageData) 3436 if (imageData)
3431 texImage2D(target, level, internalformat, format, type, imageData.get(), exceptionState); 3437 texImage2D(target, level, internalformat, format, type, imageData.get(), exceptionState);
3432 else 3438 else
3433 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultip lyAlpha, exceptionState); 3439 texImage2DImpl(target, level, internalformat, format, type, canvas->copi edImage(), WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremultip lyAlpha, exceptionState);
3434 } 3440 }
3435 3441
3436 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy) 3442 PassRefPtr<Image> WebGLRenderingContextBase::videoFrameToImage(HTMLVideoElement* video, BackingStoreCopy backingStoreCopy)
(...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after
5331 LocalFrame* frame = canvas()->document().frame(); 5337 LocalFrame* frame = canvas()->document().frame();
5332 if (!frame) 5338 if (!frame)
5333 return; 5339 return;
5334 5340
5335 Settings* settings = frame->settings(); 5341 Settings* settings = frame->settings();
5336 5342
5337 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ())) 5343 if (!frame->loader().client()->allowWebGL(settings && settings->webGLEnabled ()))
5338 return; 5344 return;
5339 5345
5340 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings); 5346 blink::WebGraphicsContext3D::Attributes attributes = m_requestedAttributes-> attributes(canvas()->document().topDocument().url().string(), settings);
5341 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes)); 5347 OwnPtr<blink::WebGraphicsContext3D> context = adoptPtr(blink::Platform::curr ent()->createOffscreenGraphicsContext3D(attributes, 0));
5342 if (!context) { 5348 if (!context) {
5343 if (m_contextLostMode == RealLostContext) { 5349 if (m_contextLostMode == RealLostContext) {
5344 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE ); 5350 m_restoreTimer.startOneShot(secondsBetweenRestoreAttempts, FROM_HERE );
5345 } else { 5351 } else {
5346 // This likely shouldn't happen but is the best way to report it to the WebGL app. 5352 // This likely shouldn't happen but is the best way to report it to the WebGL app.
5347 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context "); 5353 synthesizeGLError(GL_INVALID_OPERATION, "", "error restoring context ");
5348 } 5354 }
5349 return; 5355 return;
5350 } 5356 }
5351 5357
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
5559 if (m_textureUnits[i].m_texture2DBinding 5565 if (m_textureUnits[i].m_texture2DBinding
5560 || m_textureUnits[i].m_textureCubeMapBinding) { 5566 || m_textureUnits[i].m_textureCubeMapBinding) {
5561 m_onePlusMaxNonDefaultTextureUnit = i + 1; 5567 m_onePlusMaxNonDefaultTextureUnit = i + 1;
5562 return; 5568 return;
5563 } 5569 }
5564 } 5570 }
5565 m_onePlusMaxNonDefaultTextureUnit = 0; 5571 m_onePlusMaxNonDefaultTextureUnit = 0;
5566 } 5572 }
5567 5573
5568 } // namespace WebCore 5574 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698