Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/output/output_surface.h" | 5 #include "cc/output/output_surface.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 using std::vector; | 23 using std::vector; |
| 24 | 24 |
| 25 namespace cc { | 25 namespace cc { |
| 26 | 26 |
| 27 class OutputSurfaceCallbacks | 27 class OutputSurfaceCallbacks |
| 28 : public WebKit::WebGraphicsContext3D:: | 28 : public WebKit::WebGraphicsContext3D:: |
| 29 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM, | 29 WebGraphicsSwapBuffersCompleteCallbackCHROMIUM, |
| 30 public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 30 public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
| 31 public: | 31 public: |
| 32 explicit OutputSurfaceCallbacks(OutputSurfaceClient* client) | 32 explicit OutputSurfaceCallbacks(OutputSurfaceClient* client) |
| 33 : client_(client) {} | 33 : client_(client) { |
| 34 DCHECK(client_); | |
| 35 } | |
| 34 | 36 |
| 35 // WK:WGC3D::WGSwapBuffersCompleteCallbackCHROMIUM implementation. | 37 // WK:WGC3D::WGSwapBuffersCompleteCallbackCHROMIUM implementation. |
| 36 virtual void onSwapBuffersComplete() { client_->OnSwapBuffersComplete(); } | 38 virtual void onSwapBuffersComplete() { client_->OnSwapBuffersComplete(); } |
| 37 | 39 |
| 38 // WK:WGC3D::WGContextLostCallback implementation. | 40 // WK:WGC3D::WGContextLostCallback implementation. |
| 39 virtual void onContextLost() { client_->DidLoseOutputSurface(); } | 41 virtual void onContextLost() { client_->DidLoseOutputSurface(); } |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 OutputSurfaceClient* client_; | 44 OutputSurfaceClient* client_; |
| 43 }; | 45 }; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 68 OutputSurface::~OutputSurface() { | 70 OutputSurface::~OutputSurface() { |
| 69 } | 71 } |
| 70 | 72 |
| 71 bool OutputSurface::ForcedDrawToSoftwareDevice() const { | 73 bool OutputSurface::ForcedDrawToSoftwareDevice() const { |
| 72 return false; | 74 return false; |
| 73 } | 75 } |
| 74 | 76 |
| 75 bool OutputSurface::BindToClient( | 77 bool OutputSurface::BindToClient( |
| 76 cc::OutputSurfaceClient* client) { | 78 cc::OutputSurfaceClient* client) { |
| 77 DCHECK(client); | 79 DCHECK(client); |
| 78 if (context3d_ && !context3d_->makeContextCurrent()) | 80 client_ = client; |
| 81 bool success = true; | |
| 82 | |
| 83 if (context3d_) | |
| 84 success = InitializeAndSetContext3D(context3d_.Pass()); | |
| 85 | |
| 86 if (!success) | |
|
danakj
2013/06/05 18:50:22
if (success) client_ = client; and drop the above
boliu
2013/06/05 19:06:31
Won't work because client_ is used in InitializeAn
danakj
2013/06/05 19:10:12
Ah okay, I see. Well we have a test for exactly th
| |
| 87 client_ = NULL; | |
| 88 | |
| 89 return success; | |
| 90 } | |
| 91 | |
| 92 bool OutputSurface::InitializeAndSetContext3D( | |
| 93 scoped_ptr<WebKit::WebGraphicsContext3D> context3d) { | |
| 94 DCHECK(context3d); | |
| 95 DCHECK(client_); | |
| 96 | |
| 97 if (!context3d->makeContextCurrent()) | |
| 79 return false; | 98 return false; |
| 80 client_ = client; | 99 |
| 81 if (!context3d_) | 100 string extensions_string = UTF16ToASCII(context3d->getString(GL_EXTENSIONS)); |
| 82 return true; | |
| 83 string extensions_string = UTF16ToASCII(context3d_->getString(GL_EXTENSIONS)); | |
| 84 vector<string> extensions_list; | 101 vector<string> extensions_list; |
| 85 base::SplitString(extensions_string, ' ', &extensions_list); | 102 base::SplitString(extensions_string, ' ', &extensions_list); |
| 86 set<string> extensions(extensions_list.begin(), extensions_list.end()); | 103 set<string> extensions(extensions_list.begin(), extensions_list.end()); |
| 87 | |
| 88 has_gl_discard_backbuffer_ = | 104 has_gl_discard_backbuffer_ = |
| 89 extensions.count("GL_CHROMIUM_discard_backbuffer") > 0; | 105 extensions.count("GL_CHROMIUM_discard_backbuffer") > 0; |
| 90 | 106 |
| 107 context3d_ = context3d.Pass(); | |
| 91 callbacks_.reset(new OutputSurfaceCallbacks(client_)); | 108 callbacks_.reset(new OutputSurfaceCallbacks(client_)); |
| 92 context3d_->setSwapBuffersCompleteCallbackCHROMIUM(callbacks_.get()); | 109 context3d_->setSwapBuffersCompleteCallbackCHROMIUM(callbacks_.get()); |
| 93 context3d_->setContextLostCallback(callbacks_.get()); | 110 context3d_->setContextLostCallback(callbacks_.get()); |
| 94 | 111 |
| 95 return true; | 112 return true; |
| 96 } | 113 } |
| 97 | 114 |
| 98 void OutputSurface::SendFrameToParentCompositor(CompositorFrame* frame) { | 115 void OutputSurface::SendFrameToParentCompositor(CompositorFrame* frame) { |
| 99 NOTIMPLEMENTED(); | 116 NOTIMPLEMENTED(); |
| 100 } | 117 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 129 } | 146 } |
| 130 | 147 |
| 131 void OutputSurface::PostSubBuffer(gfx::Rect rect, | 148 void OutputSurface::PostSubBuffer(gfx::Rect rect, |
| 132 const ui::LatencyInfo& latency_info) { | 149 const ui::LatencyInfo& latency_info) { |
| 133 DCHECK(context3d_); | 150 DCHECK(context3d_); |
| 134 context3d_->postSubBufferCHROMIUM( | 151 context3d_->postSubBufferCHROMIUM( |
| 135 rect.x(), rect.y(), rect.width(), rect.height()); | 152 rect.x(), rect.y(), rect.width(), rect.height()); |
| 136 } | 153 } |
| 137 | 154 |
| 138 } // namespace cc | 155 } // namespace cc |
| OLD | NEW |