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

Side by Side Diff: ui/gfx/compositor/compositor_cc.cc

Issue 8890050: Attempt 3 at: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Da fix Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/compositor/compositor_cc.h ('k') | ui/gfx/compositor/compositor_setup.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/gfx/compositor/compositor_cc.h" 5 #include "ui/gfx/compositor/compositor_cc.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "third_party/skia/include/images/SkImageEncoder.h" 8 #include "third_party/skia/include/images/SkImageEncoder.h"
9 #include "third_party/skia/include/core/SkBitmap.h" 9 #include "third_party/skia/include/core/SkBitmap.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositor.h"
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin t.h" 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFloatPoin t.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
14 #include "ui/gfx/compositor/compositor_switches.h" 14 #include "ui/gfx/compositor/compositor_switches.h"
15 #include "ui/gfx/compositor/test_web_graphics_context_3d.h" 15 #include "ui/gfx/compositor/test_web_graphics_context_3d.h"
16 #include "ui/gfx/compositor/layer.h" 16 #include "ui/gfx/compositor/layer.h"
17 #include "ui/gfx/gl/gl_context.h" 17 #include "ui/gfx/gl/gl_context.h"
18 #include "ui/gfx/gl/gl_surface.h" 18 #include "ui/gfx/gl/gl_surface.h"
19 #include "ui/gfx/gl/gl_implementation.h" 19 #include "ui/gfx/gl/gl_implementation.h"
20 #include "ui/gfx/gl/scoped_make_current.h" 20 #include "ui/gfx/gl/scoped_make_current.h"
21 #include "webkit/glue/webthread_impl.h" 21 #include "webkit/glue/webthread_impl.h"
22 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 22 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
23 23
24 namespace { 24 namespace {
25
25 webkit_glue::WebThreadImpl* g_compositor_thread = NULL; 26 webkit_glue::WebThreadImpl* g_compositor_thread = NULL;
27
28 // If true a context is used that results in no rendering to the screen.
29 bool test_context_enabled = false;
30
26 } // anonymous namespace 31 } // anonymous namespace
27 32
28 namespace ui { 33 namespace ui {
29 34
30 SharedResourcesCC::SharedResourcesCC() : initialized_(false) { 35 SharedResourcesCC::SharedResourcesCC() : initialized_(false) {
31 } 36 }
32 37
33 38
34 SharedResourcesCC::~SharedResourcesCC() { 39 SharedResourcesCC::~SharedResourcesCC() {
35 } 40 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 const gfx::Point& origin, 119 const gfx::Point& origin,
115 const gfx::Size& overall_size) { 120 const gfx::Size& overall_size) {
116 NOTREACHED(); 121 NOTREACHED();
117 } 122 }
118 123
119 void TextureCC::Draw(const ui::TextureDrawParams& params, 124 void TextureCC::Draw(const ui::TextureDrawParams& params,
120 const gfx::Rect& clip_bounds_in_texture) { 125 const gfx::Rect& clip_bounds_in_texture) {
121 NOTREACHED(); 126 NOTREACHED();
122 } 127 }
123 128
124 // static
125 bool CompositorCC::test_context_enabled_ = false;
126
127 CompositorCC::CompositorCC(CompositorDelegate* delegate, 129 CompositorCC::CompositorCC(CompositorDelegate* delegate,
128 gfx::AcceleratedWidget widget, 130 gfx::AcceleratedWidget widget,
129 const gfx::Size& size) 131 const gfx::Size& size)
130 : Compositor(delegate, size), 132 : Compositor(delegate, size),
131 widget_(widget), 133 widget_(widget),
132 root_web_layer_(WebKit::WebLayer::create(this)) { 134 root_web_layer_(WebKit::WebLayer::create(this)) {
133 WebKit::WebLayerTreeView::Settings settings; 135 WebKit::WebLayerTreeView::Settings settings;
134 CommandLine* command_line = CommandLine::ForCurrentProcess(); 136 CommandLine* command_line = CommandLine::ForCurrentProcess();
135 settings.showFPSCounter = 137 settings.showFPSCounter =
136 command_line->HasSwitch(switches::kUIShowFPSCounter); 138 command_line->HasSwitch(switches::kUIShowFPSCounter);
(...skipping 28 matching lines...) Expand all
165 void CompositorCC::Terminate() { 167 void CompositorCC::Terminate() {
166 #ifdef WEBCOMPOSITOR_HAS_INITIALIZE 168 #ifdef WEBCOMPOSITOR_HAS_INITIALIZE
167 WebKit::WebCompositor::shutdown(); 169 WebKit::WebCompositor::shutdown();
168 #endif 170 #endif
169 if (g_compositor_thread) { 171 if (g_compositor_thread) {
170 delete g_compositor_thread; 172 delete g_compositor_thread;
171 g_compositor_thread = NULL; 173 g_compositor_thread = NULL;
172 } 174 }
173 } 175 }
174 176
175 // static
176 void CompositorCC::EnableTestContextIfNecessary() {
177 // TODO: only do this if command line param not set.
178 test_context_enabled_ = true;
179 }
180
181 Texture* CompositorCC::CreateTexture() { 177 Texture* CompositorCC::CreateTexture() {
182 NOTREACHED(); 178 NOTREACHED();
183 return NULL; 179 return NULL;
184 } 180 }
185 181
186 void CompositorCC::Blur(const gfx::Rect& bounds) { 182 void CompositorCC::Blur(const gfx::Rect& bounds) {
187 NOTIMPLEMENTED(); 183 NOTIMPLEMENTED();
188 } 184 }
189 185
190 void CompositorCC::ScheduleDraw() { 186 void CompositorCC::ScheduleDraw() {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 236
241 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta, 237 void CompositorCC::applyScrollAndScale(const WebKit::WebSize& scrollDelta,
242 float scaleFactor) { 238 float scaleFactor) {
243 } 239 }
244 240
245 void CompositorCC::applyScrollDelta(const WebKit::WebSize&) { 241 void CompositorCC::applyScrollDelta(const WebKit::WebSize&) {
246 } 242 }
247 243
248 WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() { 244 WebKit::WebGraphicsContext3D* CompositorCC::createContext3D() {
249 WebKit::WebGraphicsContext3D* context; 245 WebKit::WebGraphicsContext3D* context;
250 if (test_context_enabled_) { 246 if (test_context_enabled) {
251 context = new TestWebGraphicsContext3D(); 247 context = new TestWebGraphicsContext3D();
252 } else { 248 } else {
253 gfx::GLShareGroup* share_group = 249 gfx::GLShareGroup* share_group =
254 SharedResourcesCC::GetInstance()->GetShareGroup(); 250 SharedResourcesCC::GetInstance()->GetShareGroup();
255 context = new webkit::gpu::WebGraphicsContext3DInProcessImpl( 251 context = new webkit::gpu::WebGraphicsContext3DInProcessImpl(
256 widget_, share_group); 252 widget_, share_group);
257 } 253 }
258 WebKit::WebGraphicsContext3D::Attributes attrs; 254 WebKit::WebGraphicsContext3D::Attributes attrs;
259 context->initialize(attrs, 0, true); 255 context->initialize(attrs, 0, true);
260 256
(...skipping 18 matching lines...) Expand all
279 void CompositorCC::notifyNeedsComposite() { 275 void CompositorCC::notifyNeedsComposite() {
280 ScheduleDraw(); 276 ScheduleDraw();
281 } 277 }
282 278
283 Compositor* Compositor::Create(CompositorDelegate* owner, 279 Compositor* Compositor::Create(CompositorDelegate* owner,
284 gfx::AcceleratedWidget widget, 280 gfx::AcceleratedWidget widget,
285 const gfx::Size& size) { 281 const gfx::Size& size) {
286 return new CompositorCC(owner, widget, size); 282 return new CompositorCC(owner, widget, size);
287 } 283 }
288 284
285 COMPOSITOR_EXPORT void SetupTestCompositor() {
286 if (!CommandLine::ForCurrentProcess()->HasSwitch(
287 switches::kDisableTestCompositor)) {
288 test_context_enabled = true;
289 }
290 }
291
292 COMPOSITOR_EXPORT void DisableTestCompositor() {
293 test_context_enabled = false;
294 }
295
289 } // namespace ui 296 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/compositor_cc.h ('k') | ui/gfx/compositor/compositor_setup.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698