| Index: cc/output_surface.cc
|
| diff --git a/cc/output_surface.cc b/cc/output_surface.cc
|
| index b48923226a8593d28b1c2adfb3c29d35f9f8b6db..1f6d61270b9f1c3204be8d9354c7d89ecd89dc17 100644
|
| --- a/cc/output_surface.cc
|
| +++ b/cc/output_surface.cc
|
| @@ -4,20 +4,37 @@
|
|
|
| #include "cc/output_surface.h"
|
|
|
| +#include <set>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| #include "base/logging.h"
|
| +#include "base/string_split.h"
|
| +#include "base/string_util.h"
|
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
|
| +#include "third_party/khronos/GLES2/gl2.h"
|
| +#include "third_party/khronos/GLES2/gl2ext.h"
|
| +#include "ui/gfx/rect.h"
|
| +#include "ui/gfx/size.h"
|
| +
|
| +using std::set;
|
| +using std::string;
|
| +using std::vector;
|
|
|
| namespace cc {
|
|
|
| OutputSurface::OutputSurface(
|
| scoped_ptr<WebKit::WebGraphicsContext3D> context3d)
|
| : client_(NULL),
|
| - context3d_(context3d.Pass()) {
|
| + context3d_(context3d.Pass()),
|
| + has_gl_discard_backbuffer_(false) {
|
| }
|
|
|
| OutputSurface::OutputSurface(
|
| scoped_ptr<cc::SoftwareOutputDevice> software_device)
|
| : client_(NULL),
|
| - software_device_(software_device.Pass()) {
|
| + software_device_(software_device.Pass()),
|
| + has_gl_discard_backbuffer_(false) {
|
| }
|
|
|
| OutputSurface::OutputSurface(
|
| @@ -25,7 +42,8 @@ OutputSurface::OutputSurface(
|
| scoped_ptr<cc::SoftwareOutputDevice> software_device)
|
| : client_(NULL),
|
| context3d_(context3d.Pass()),
|
| - software_device_(software_device.Pass()) {
|
| + software_device_(software_device.Pass()),
|
| + has_gl_discard_backbuffer_(false) {
|
| }
|
|
|
| OutputSurface::~OutputSurface() {
|
| @@ -37,11 +55,57 @@ bool OutputSurface::BindToClient(
|
| client_ = client;
|
| if (!context3d_)
|
| return true;
|
| - return context3d_->makeContextCurrent();
|
| + if (!context3d_->makeContextCurrent())
|
| + return false;
|
| +
|
| + string extensionsString = UTF16ToASCII(context3d_->getString(GL_EXTENSIONS));
|
| + vector<string> extensionsList;
|
| + base::SplitString(extensionsString, ' ', &extensionsList);
|
| + set<string> extensions(extensionsList.begin(), extensionsList.end());
|
| +
|
| + has_gl_discard_backbuffer_ =
|
| + extensions.count("GL_CHROMIUM_discard_backbuffer");
|
| +
|
| + return true;
|
| }
|
|
|
| void OutputSurface::SendFrameToParentCompositor(CompositorFrame*) {
|
| NOTIMPLEMENTED();
|
| }
|
|
|
| +void OutputSurface::EnsureBackbuffer() {
|
| + DCHECK(context3d_);
|
| + if (has_gl_discard_backbuffer_)
|
| + context3d_->ensureBackbufferCHROMIUM();
|
| +}
|
| +
|
| +void OutputSurface::DiscardBackbuffer() {
|
| + DCHECK(context3d_);
|
| + if (has_gl_discard_backbuffer_)
|
| + context3d_->discardBackbufferCHROMIUM();
|
| +}
|
| +
|
| +void OutputSurface::Reshape(const gfx::Size& size) {
|
| + DCHECK(context3d_);
|
| + context3d_->reshape(size.width(), size.height());
|
| +}
|
| +
|
| +void OutputSurface::BindFramebuffer() {
|
| + DCHECK(context3d_);
|
| + context3d_->bindFramebuffer(GL_FRAMEBUFFER, 0);
|
| +}
|
| +
|
| +void OutputSurface::SwapBuffers() {
|
| + DCHECK(context3d_);
|
| + // Note that currently this has the same effect as swapBuffers; we should
|
| + // consider exposing a different entry point on WebGraphicsContext3D.
|
| + context3d_->prepareTexture();
|
| +}
|
| +
|
| +void OutputSurface::PostSubBuffer(const gfx::Rect& rect) {
|
| + DCHECK(context3d_);
|
| + context3d_->postSubBufferCHROMIUM(
|
| + rect.x(), rect.y(), rect.width(), rect.height());
|
| +}
|
| +
|
| } // namespace cc
|
|
|