OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 #include <algorithm> | 35 #include <algorithm> |
36 #include "platform/TraceEvent.h" | 36 #include "platform/TraceEvent.h" |
37 #include "platform/graphics/GraphicsLayer.h" | 37 #include "platform/graphics/GraphicsLayer.h" |
38 #include "platform/graphics/gpu/Extensions3DUtil.h" | 38 #include "platform/graphics/gpu/Extensions3DUtil.h" |
39 #include "public/platform/Platform.h" | 39 #include "public/platform/Platform.h" |
40 #include "public/platform/WebCompositorSupport.h" | 40 #include "public/platform/WebCompositorSupport.h" |
41 #include "public/platform/WebExternalBitmap.h" | 41 #include "public/platform/WebExternalBitmap.h" |
42 #include "public/platform/WebExternalTextureLayer.h" | 42 #include "public/platform/WebExternalTextureLayer.h" |
43 #include "public/platform/WebGraphicsContext3D.h" | 43 #include "public/platform/WebGraphicsContext3D.h" |
| 44 #include "public/platform/WebGraphicsContext3DProvider.h" |
44 | 45 |
45 using namespace std; | 46 using namespace std; |
46 | 47 |
47 namespace WebCore { | 48 namespace WebCore { |
48 | 49 |
49 // Global resource ceiling (expressed in terms of pixels) for DrawingBuffer crea
tion and resize. | 50 // Global resource ceiling (expressed in terms of pixels) for DrawingBuffer crea
tion and resize. |
50 // When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() ca
lls that would | 51 // When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() ca
lls that would |
51 // exceed the global cap will instead clear the buffer. | 52 // exceed the global cap will instead clear the buffer. |
52 static const int s_maximumResourceUsePixels = 16 * 1024 * 1024; | 53 static const int s_maximumResourceUsePixels = 16 * 1024 * 1024; |
53 static int s_currentResourceUsePixels = 0; | 54 static int s_currentResourceUsePixels = 0; |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 405 |
405 void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer) | 406 void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer) |
406 { | 407 { |
407 if (!m_context || !m_context->makeContextCurrent() || m_context->getGraphics
ResetStatusARB() != GL_NO_ERROR) | 408 if (!m_context || !m_context->makeContextCurrent() || m_context->getGraphics
ResetStatusARB() != GL_NO_ERROR) |
408 return; | 409 return; |
409 | 410 |
410 if (!imageBuffer) | 411 if (!imageBuffer) |
411 return; | 412 return; |
412 Platform3DObject tex = imageBuffer->getBackingTexture(); | 413 Platform3DObject tex = imageBuffer->getBackingTexture(); |
413 if (tex) { | 414 if (tex) { |
414 m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_frontColorBuffer, | 415 RefPtr<MailboxInfo> bufferMailbox = adoptRef(new MailboxInfo()); |
| 416 m_context->genMailboxCHROMIUM(bufferMailbox->mailbox.name); |
| 417 m_context->bindTexture(GL_TEXTURE_2D, m_frontColorBuffer); |
| 418 m_context->produceTextureCHROMIUM(GL_TEXTURE_2D, bufferMailbox->mailbox.
name); |
| 419 m_context->flush(); |
| 420 |
| 421 bufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); |
| 422 OwnPtr<blink::WebGraphicsContext3DProvider> provider = |
| 423 adoptPtr(blink::Platform::current()->createSharedOffscreenGraphicsCo
ntext3DProvider()); |
| 424 if (!provider) |
| 425 return; |
| 426 blink::WebGraphicsContext3D* context = provider->context3d(); |
| 427 if (!context || !context->makeContextCurrent()) |
| 428 return; |
| 429 |
| 430 Platform3DObject sourceTexture = context->createTexture(); |
| 431 GLint boundTexture = 0; |
| 432 context->getIntegerv(GL_TEXTURE_BINDING_2D, &boundTexture); |
| 433 context->bindTexture(GL_TEXTURE_2D, sourceTexture); |
| 434 context->waitSyncPoint(bufferMailbox->mailbox.syncPoint); |
| 435 context->consumeTextureCHROMIUM(GL_TEXTURE_2D, bufferMailbox->mailbox.na
me); |
| 436 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, |
415 tex, 0, GL_RGBA, GL_UNSIGNED_BYTE); | 437 tex, 0, GL_RGBA, GL_UNSIGNED_BYTE); |
416 m_context->flush(); | 438 context->bindTexture(GL_TEXTURE_2D, boundTexture); |
| 439 context->deleteTexture(sourceTexture); |
| 440 context->flush(); |
| 441 m_context->waitSyncPoint(context->insertSyncPoint()); |
417 return; | 442 return; |
418 } | 443 } |
419 | 444 |
420 // Since the m_frontColorBuffer was produced and sent to the compositor, it
cannot be bound to an fbo. | 445 // Since the m_frontColorBuffer was produced and sent to the compositor, it
cannot be bound to an fbo. |
421 // We have to make a copy of it here and bind that copy instead. | 446 // We have to make a copy of it here and bind that copy instead. |
422 // FIXME: That's not true any more, provided we don't change texture | 447 // FIXME: That's not true any more, provided we don't change texture |
423 // parameters. | 448 // parameters. |
424 unsigned sourceTexture = createColorTexture(m_size); | 449 unsigned sourceTexture = createColorTexture(m_size); |
425 m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_frontColorBuffer, sourceText
ure, 0, GL_RGBA, GL_UNSIGNED_BYTE); | 450 m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_frontColorBuffer, sourceText
ure, 0, GL_RGBA, GL_UNSIGNED_BYTE); |
426 | 451 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 } | 946 } |
922 } | 947 } |
923 | 948 |
924 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in
ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum
type, GLint unpackAlignment) | 949 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in
ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum
type, GLint unpackAlignment) |
925 { | 950 { |
926 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4
|| unpackAlignment == 8); | 951 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4
|| unpackAlignment == 8); |
927 m_context->texImage2D(target, level, internalformat, width, height, border,
format, type, 0); | 952 m_context->texImage2D(target, level, internalformat, width, height, border,
format, type, 0); |
928 } | 953 } |
929 | 954 |
930 } // namespace WebCore | 955 } // namespace WebCore |
OLD | NEW |