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

Unified Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 2643343002: DrawingBuffer: Use gfx::GpuMemoryBuffer directly and set color space (Closed)
Patch Set: Fix buffer format Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
index 713c351f8cd66290fb73679d89f8dacea603abf7..ade85d1269a5b9133885ca3c2fb402c300b0981c 100644
--- a/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp
@@ -33,7 +33,9 @@
#include "cc/resources/shared_bitmap.h"
#include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h"
+#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
#include "gpu/command_buffer/common/capabilities.h"
+#include "gpu/command_buffer/common/gpu_memory_buffer_support.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/graphics/AcceleratedStaticBitmapImage.h"
#include "platform/graphics/GraphicsLayer.h"
@@ -152,6 +154,7 @@ DrawingBuffer::DrawingBuffer(
m_softwareRendering(this->contextProvider()->isSoftwareRendering()),
m_wantDepth(wantDepth),
m_wantStencil(wantStencil),
+ m_colorSpace(gfx::ColorSpace::CreateSRGB()),
m_chromiumImageUsage(chromiumImageUsage) {
// Used by browser tests to detect the use of a DrawingBuffer.
TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation",
@@ -311,6 +314,7 @@ bool DrawingBuffer::finishPrepareTextureMailboxSoftware(
}
*outMailbox = cc::TextureMailbox(bitmap.get(), m_size);
+ outMailbox->set_color_space(m_colorSpace);
// This holds a ref on the DrawingBuffer that will keep it alive until the
// mailbox is released (and while the release callback is running). It also
@@ -383,6 +387,7 @@ bool DrawingBuffer::finishPrepareTextureMailboxGpu(
colorBufferForMailbox->mailbox, colorBufferForMailbox->produceSyncToken,
colorBufferForMailbox->parameters.target, gfx::Size(m_size),
isOverlayCandidate, secureOutputOnly);
+ outMailbox->set_color_space(m_colorSpace);
// This holds a ref on the DrawingBuffer that will keep it alive until the
// mailbox is released (and while the release callback is running).
@@ -572,16 +577,19 @@ DrawingBuffer::createOrRecycleColorBuffer() {
return createColorBuffer(m_size);
}
-DrawingBuffer::ColorBuffer::ColorBuffer(DrawingBuffer* drawingBuffer,
- const ColorBufferParameters& parameters,
- const IntSize& size,
- GLuint textureId,
- GLuint imageId)
+DrawingBuffer::ColorBuffer::ColorBuffer(
+ DrawingBuffer* drawingBuffer,
+ const ColorBufferParameters& parameters,
+ const IntSize& size,
+ GLuint textureId,
+ GLuint imageId,
+ std::unique_ptr<gfx::GpuMemoryBuffer> gpuMemoryBuffer)
: drawingBuffer(drawingBuffer),
parameters(parameters),
size(size),
textureId(textureId),
- imageId(imageId) {
+ imageId(imageId),
+ gpuMemoryBuffer(std::move(gpuMemoryBuffer)) {
drawingBuffer->contextGL()->GenMailboxCHROMIUM(mailbox.name);
}
@@ -608,6 +616,7 @@ DrawingBuffer::ColorBuffer::~ColorBuffer() {
NOTREACHED();
break;
}
+ gpuMemoryBuffer.reset();
}
gl->DeleteTextures(1, &textureId);
}
@@ -1129,11 +1138,25 @@ RefPtr<DrawingBuffer::ColorBuffer> DrawingBuffer::createColorBuffer(
// GpuMemoryBuffer and GLImage, if one is going to be used.
ColorBufferParameters parameters;
GLuint imageId = 0;
- if (shouldUseChromiumImage()) {
+ std::unique_ptr<gfx::GpuMemoryBuffer> gpuMemoryBuffer;
+ gpu::GpuMemoryBufferManager* gpuMemoryBufferManager =
+ Platform::current()->getGpuMemoryBufferManager();
+ if (shouldUseChromiumImage() && gpuMemoryBufferManager) {
parameters = gpuMemoryBufferColorBufferParameters();
- imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(
- size.width(), size.height(), parameters.creationInternalColorFormat,
- GC3D_SCANOUT_CHROMIUM);
+ gfx::BufferFormat bufferFormat = gpu::DefaultBufferFormatForImageFormat(
+ parameters.creationInternalColorFormat);
+ gpuMemoryBuffer = gpuMemoryBufferManager->CreateGpuMemoryBuffer(
+ gfx::Size(size), bufferFormat, gfx::BufferUsage::SCANOUT,
+ gpu::kNullSurfaceHandle);
+ if (gpuMemoryBuffer) {
+ if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled())
+ gpuMemoryBuffer->SetColorSpaceForScanout(m_colorSpace);
+ imageId = m_gl->CreateImageCHROMIUM(
+ gpuMemoryBuffer->AsClientBuffer(), size.width(), size.height(),
+ parameters.creationInternalColorFormat);
+ if (!imageId)
+ gpuMemoryBuffer.reset();
+ }
} else {
parameters = textureColorBufferParameters();
}
@@ -1191,7 +1214,8 @@ RefPtr<DrawingBuffer::ColorBuffer> DrawingBuffer::createColorBuffer(
m_gl->DeleteFramebuffers(1, &fbo);
}
- return adoptRef(new ColorBuffer(this, parameters, size, textureId, imageId));
+ return adoptRef(new ColorBuffer(this, parameters, size, textureId, imageId,
+ std::move(gpuMemoryBuffer)));
}
void DrawingBuffer::attachColorBufferToReadFramebuffer() {

Powered by Google App Engine
This is Rietveld 408576698