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

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

Issue 805273005: WebGL: paintRenderingResultsToImageData() must restore FBO. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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 | « Source/core/html/canvas/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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 ~ScopedTexture2DRestorer() 500 ~ScopedTexture2DRestorer()
501 { 501 {
502 m_context->restoreCurrentTexture2D(); 502 m_context->restoreCurrentTexture2D();
503 } 503 }
504 504
505 private: 505 private:
506 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; 506 RawPtrWillBeMember<WebGLRenderingContextBase> m_context;
507 }; 507 };
508 508
509 class ScopedFramebufferRestorer {
510 STACK_ALLOCATED();
511 public:
512 explicit ScopedFramebufferRestorer(WebGLRenderingContextBase* context)
513 : m_context(context)
514 {
515 }
516
517 ~ScopedFramebufferRestorer()
518 {
519 m_context->restoreCurrentFramebuffer();
520 }
521
522 private:
523 RawPtrWillBeMember<WebGLRenderingContextBase> m_context;
524 };
525
509 class WebGLRenderingContextLostCallback final : public NoBaseWillBeGarbageCollec tedFinalized<WebGLRenderingContextLostCallback>, public blink::WebGraphicsContex t3D::WebGraphicsContextLostCallback { 526 class WebGLRenderingContextLostCallback final : public NoBaseWillBeGarbageCollec tedFinalized<WebGLRenderingContextLostCallback>, public blink::WebGraphicsContex t3D::WebGraphicsContextLostCallback {
510 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; 527 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
511 public: 528 public:
512 static PassOwnPtrWillBeRawPtr<WebGLRenderingContextLostCallback> create(WebG LRenderingContextBase* context) 529 static PassOwnPtrWillBeRawPtr<WebGLRenderingContextLostCallback> create(WebG LRenderingContextBase* context)
513 { 530 {
514 return adoptPtrWillBeNoop(new WebGLRenderingContextLostCallback(context) ); 531 return adoptPtrWillBeNoop(new WebGLRenderingContextLostCallback(context) );
515 } 532 }
516 533
517 virtual ~WebGLRenderingContextLostCallback() { } 534 virtual ~WebGLRenderingContextLostCallback() { }
518 535
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 return false; 923 return false;
907 924
908 bool mustClearNow = clearIfComposited() != Skipped; 925 bool mustClearNow = clearIfComposited() != Skipped;
909 if (!m_markedCanvasDirty && !mustClearNow) 926 if (!m_markedCanvasDirty && !mustClearNow)
910 return false; 927 return false;
911 928
912 canvas()->clearCopiedImage(); 929 canvas()->clearCopiedImage();
913 m_markedCanvasDirty = false; 930 m_markedCanvasDirty = false;
914 931
915 ScopedTexture2DRestorer restorer(this); 932 ScopedTexture2DRestorer restorer(this);
933 ScopedFramebufferRestorer fboRestorer(this);
916 934
917 drawingBuffer()->commit(); 935 drawingBuffer()->commit();
918 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(drawingBuffer (), sourceBuffer)) { 936 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(drawingBuffer (), sourceBuffer)) {
919 canvas()->ensureUnacceleratedImageBuffer(); 937 canvas()->ensureUnacceleratedImageBuffer();
920 if (canvas()->hasImageBuffer()) 938 if (canvas()->hasImageBuffer())
921 drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer()); 939 drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer());
922 } 940 }
923 941
924 restoreCurrentFramebuffer();
925 return true; 942 return true;
926 } 943 }
927 944
928 PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul tsToImageData(SourceDrawingBuffer sourceBuffer) 945 PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul tsToImageData(SourceDrawingBuffer sourceBuffer)
929 { 946 {
930 if (isContextLost()) 947 if (isContextLost())
931 return nullptr; 948 return nullptr;
932 949
933 clearIfComposited(); 950 clearIfComposited();
934 drawingBuffer()->commit(); 951 drawingBuffer()->commit();
952 ScopedFramebufferRestorer restorer(this);
935 int width, height; 953 int width, height;
936 WTF::ArrayBufferContents contents; 954 WTF::ArrayBufferContents contents;
937 if (!drawingBuffer()->paintRenderingResultsToImageData(width, height, source Buffer, contents)) 955 if (!drawingBuffer()->paintRenderingResultsToImageData(width, height, source Buffer, contents))
dshwang 2015/01/05 16:44:26 drawingBuffer()->commit() binds DrawingBuffer::m_f
938 return nullptr; 956 return nullptr;
939 RefPtr<DOMArrayBuffer> imageDataPixels = DOMArrayBuffer::create(contents); 957 RefPtr<DOMArrayBuffer> imageDataPixels = DOMArrayBuffer::create(contents);
940 958
941 return ImageData::create( 959 return ImageData::create(
942 IntSize(width, height), 960 IntSize(width, height),
943 DOMUint8ClampedArray::create(imageDataPixels, 0, imageDataPixels->byteLe ngth())); 961 DOMUint8ClampedArray::create(imageDataPixels, 0, imageDataPixels->byteLe ngth()));
944 } 962 }
945 963
946 void WebGLRenderingContextBase::reshape(int width, int height) 964 void WebGLRenderingContextBase::reshape(int width, int height)
947 { 965 {
(...skipping 5004 matching lines...) Expand 10 before | Expand all | Expand 10 after
5952 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 5970 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
5953 } 5971 }
5954 #else 5972 #else
5955 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 5973 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
5956 { 5974 {
5957 return m_drawingBuffer.get(); 5975 return m_drawingBuffer.get();
5958 } 5976 }
5959 #endif 5977 #endif
5960 5978
5961 } // namespace blink 5979 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698