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

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: add description in test 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 498
499 ~ScopedTexture2DRestorer() 499 ~ScopedTexture2DRestorer()
500 { 500 {
501 m_context->restoreCurrentTexture2D(); 501 m_context->restoreCurrentTexture2D();
502 } 502 }
503 503
504 private: 504 private:
505 RawPtrWillBeMember<WebGLRenderingContextBase> m_context; 505 RawPtrWillBeMember<WebGLRenderingContextBase> m_context;
506 }; 506 };
507 507
508 class ScopedFramebufferRestorer {
509 STACK_ALLOCATED();
510 public:
511 explicit ScopedFramebufferRestorer(WebGLRenderingContextBase* context)
512 : m_context(context)
513 {
514 }
515
516 ~ScopedFramebufferRestorer()
517 {
518 m_context->restoreCurrentFramebuffer();
519 }
520
521 private:
522 RawPtrWillBeMember<WebGLRenderingContextBase> m_context;
523 };
524
508 class WebGLRenderingContextLostCallback final : public NoBaseWillBeGarbageCollec tedFinalized<WebGLRenderingContextLostCallback>, public blink::WebGraphicsContex t3D::WebGraphicsContextLostCallback { 525 class WebGLRenderingContextLostCallback final : public NoBaseWillBeGarbageCollec tedFinalized<WebGLRenderingContextLostCallback>, public blink::WebGraphicsContex t3D::WebGraphicsContextLostCallback {
509 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; 526 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
510 public: 527 public:
511 static PassOwnPtrWillBeRawPtr<WebGLRenderingContextLostCallback> create(WebG LRenderingContextBase* context) 528 static PassOwnPtrWillBeRawPtr<WebGLRenderingContextLostCallback> create(WebG LRenderingContextBase* context)
512 { 529 {
513 return adoptPtrWillBeNoop(new WebGLRenderingContextLostCallback(context) ); 530 return adoptPtrWillBeNoop(new WebGLRenderingContextLostCallback(context) );
514 } 531 }
515 532
516 virtual ~WebGLRenderingContextLostCallback() { } 533 virtual ~WebGLRenderingContextLostCallback() { }
517 534
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 return false; 922 return false;
906 923
907 bool mustClearNow = clearIfComposited() != Skipped; 924 bool mustClearNow = clearIfComposited() != Skipped;
908 if (!m_markedCanvasDirty && !mustClearNow) 925 if (!m_markedCanvasDirty && !mustClearNow)
909 return false; 926 return false;
910 927
911 canvas()->clearCopiedImage(); 928 canvas()->clearCopiedImage();
912 m_markedCanvasDirty = false; 929 m_markedCanvasDirty = false;
913 930
914 ScopedTexture2DRestorer restorer(this); 931 ScopedTexture2DRestorer restorer(this);
932 ScopedFramebufferRestorer fboRestorer(this);
915 933
916 drawingBuffer()->commit(); 934 drawingBuffer()->commit();
917 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(drawingBuffer (), sourceBuffer)) { 935 if (!canvas()->buffer()->copyRenderingResultsFromDrawingBuffer(drawingBuffer (), sourceBuffer)) {
918 canvas()->ensureUnacceleratedImageBuffer(); 936 canvas()->ensureUnacceleratedImageBuffer();
919 if (canvas()->hasImageBuffer()) 937 if (canvas()->hasImageBuffer())
920 drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer()); 938 drawingBuffer()->paintRenderingResultsToCanvas(canvas()->buffer());
921 } 939 }
922 940
923 restoreCurrentFramebuffer();
924 return true; 941 return true;
925 } 942 }
926 943
927 PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul tsToImageData(SourceDrawingBuffer sourceBuffer) 944 PassRefPtrWillBeRawPtr<ImageData> WebGLRenderingContextBase::paintRenderingResul tsToImageData(SourceDrawingBuffer sourceBuffer)
928 { 945 {
929 if (isContextLost()) 946 if (isContextLost())
930 return nullptr; 947 return nullptr;
948 if (m_requestedAttributes.premultipliedAlpha())
949 return nullptr;
931 950
932 clearIfComposited(); 951 clearIfComposited();
933 drawingBuffer()->commit(); 952 drawingBuffer()->commit();
953 ScopedFramebufferRestorer restorer(this);
934 int width, height; 954 int width, height;
935 RefPtr<Uint8ClampedArray> imageDataPixels = 955 RefPtr<Uint8ClampedArray> imageDataPixels =
936 drawingBuffer()->paintRenderingResultsToImageData(width, height, sourceB uffer); 956 drawingBuffer()->paintRenderingResultsToImageData(width, height, sourceB uffer);
937 if (!imageDataPixels) 957 if (!imageDataPixels)
938 return nullptr; 958 return nullptr;
939 959
940 return ImageData::create(IntSize(width, height), imageDataPixels); 960 return ImageData::create(IntSize(width, height), imageDataPixels);
941 } 961 }
942 962
943 void WebGLRenderingContextBase::reshape(int width, int height) 963 void WebGLRenderingContextBase::reshape(int width, int height)
(...skipping 5006 matching lines...) Expand 10 before | Expand all | Expand 10 after
5950 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 5970 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
5951 } 5971 }
5952 #else 5972 #else
5953 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 5973 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
5954 { 5974 {
5955 return m_drawingBuffer.get(); 5975 return m_drawingBuffer.get();
5956 } 5976 }
5957 #endif 5977 #endif
5958 5978
5959 } // 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