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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2294383002: Make OffscreenCanvas a member of CanvasImageSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 shouldFailContextCreationForTesting = true; 642 shouldFailContextCreationForTesting = true;
643 } 643 }
644 644
645 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() 645 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase()
646 { 646 {
647 if (!drawingBuffer()) 647 if (!drawingBuffer())
648 return nullptr; 648 return nullptr;
649 return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage()); 649 return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage());
650 } 650 }
651 651
652 PassRefPtr<Image> WebGLRenderingContextBase::getImage(SnapshotReason reason) con st
653 {
654 if (!drawingBuffer())
655 return nullptr;
656
657 drawingBuffer()->commit();
658 IntSize size = clampedCanvasSize();
659 OpacityMode opacityMode = hasAlpha() ? NonOpaque : Opaque;
660 std::unique_ptr<AcceleratedImageBufferSurface> surface = wrapUnique(new Acce leratedImageBufferSurface(size, opacityMode));
661 if (!surface->isValid())
662 return nullptr;
663 std::unique_ptr<ImageBuffer> buffer = ImageBuffer::create(std::move(surface) );
664 if (!buffer->copyRenderingResultsFromDrawingBuffer(drawingBuffer(), BackBuff er)) {
665 // copyRenderingResultsFromDrawingBuffer is expected to always succeed b ecause we've
666 // explicitly created an Accelerated surface and have already validated it.
667 NOTREACHED();
668 return nullptr;
669 }
670 return buffer->newImageSnapshot(PreferAcceleration, reason);
671 }
672
652 namespace { 673 namespace {
653 674
654 // ES2 enums 675 // ES2 enums
655 static const GLenum kSupportedInternalFormatsES2[] = { 676 static const GLenum kSupportedInternalFormatsES2[] = {
656 GL_RGB, 677 GL_RGB,
657 GL_RGBA, 678 GL_RGBA,
658 GL_LUMINANCE_ALPHA, 679 GL_LUMINANCE_ALPHA,
659 GL_LUMINANCE, 680 GL_LUMINANCE,
660 GL_ALPHA, 681 GL_ALPHA,
661 }; 682 };
(...skipping 5631 matching lines...) Expand 10 before | Expand all | Expand 10 after
6293 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable) 6314 void WebGLRenderingContextBase::enableOrDisable(GLenum capability, bool enable)
6294 { 6315 {
6295 if (isContextLost()) 6316 if (isContextLost())
6296 return; 6317 return;
6297 if (enable) 6318 if (enable)
6298 contextGL()->Enable(capability); 6319 contextGL()->Enable(capability);
6299 else 6320 else
6300 contextGL()->Disable(capability); 6321 contextGL()->Disable(capability);
6301 } 6322 }
6302 6323
6303 IntSize WebGLRenderingContextBase::clampedCanvasSize() 6324 IntSize WebGLRenderingContextBase::clampedCanvasSize() const
6304 { 6325 {
6305 int width, height; 6326 int width, height;
6306 if (canvas()) { 6327 if (canvas()) {
6307 width = canvas()->width(); 6328 width = canvas()->width();
6308 height = canvas()->height(); 6329 height = canvas()->height();
6309 } else { 6330 } else {
6310 width = getOffscreenCanvas()->width(); 6331 width = getOffscreenCanvas()->width();
6311 height = getOffscreenCanvas()->height(); 6332 height = getOffscreenCanvas()->height();
6312 } 6333 }
6313 return IntSize(clamp(width, 1, m_maxViewportDims[0]), 6334 return IntSize(clamp(width, 1, m_maxViewportDims[0]),
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
6491 6512
6492 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const 6513 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const
6493 { 6514 {
6494 if (canvas()) 6515 if (canvas())
6495 result.setHTMLCanvasElement(canvas()); 6516 result.setHTMLCanvasElement(canvas());
6496 else 6517 else
6497 result.setOffscreenCanvas(getOffscreenCanvas()); 6518 result.setOffscreenCanvas(getOffscreenCanvas());
6498 } 6519 }
6499 6520
6500 } // namespace blink 6521 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698