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

Side by Side Diff: content/browser/renderer_host/compositor_impl_android.cc

Issue 23247002: Remove base::Callback from ContextProvider creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/compositor_impl_android.h" 5 #include "content/browser/renderer_host/compositor_impl_android.h"
6 6
7 #include <android/bitmap.h> 7 #include <android/bitmap.h>
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 #include <map> 9 #include <map>
10 10
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 DCHECK(bitmap.size() == sub_rect.size()); 358 DCHECK(bitmap.size() == sub_rect.size());
359 if (bitmap.size() != sub_rect.size() || texture_id == 0) return false; 359 if (bitmap.size() != sub_rect.size() || texture_id == 0) return false;
360 360
361 GLHelper* helper = ImageTransportFactoryAndroid::GetInstance()->GetGLHelper(); 361 GLHelper* helper = ImageTransportFactoryAndroid::GetInstance()->GetGLHelper();
362 helper->ReadbackTextureSync(texture_id, 362 helper->ReadbackTextureSync(texture_id,
363 sub_rect, 363 sub_rect,
364 static_cast<unsigned char*> (bitmap.pixels())); 364 static_cast<unsigned char*> (bitmap.pixels()));
365 return true; 365 return true;
366 } 366 }
367 367
368 static scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl>
369 CreateInProcessViewContext(
370 const WebKit::WebGraphicsContext3D::Attributes attributes,
371 ANativeWindow* window) {
372 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
373 return WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
374 attributes, window).Pass();
375 }
376
377 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl> 368 static scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
378 CreateGpuProcessViewContext( 369 CreateGpuProcessViewContext(
379 const WebKit::WebGraphicsContext3D::Attributes attributes, 370 const WebKit::WebGraphicsContext3D::Attributes attributes,
380 int surface_id, 371 int surface_id,
381 base::WeakPtr<CompositorImpl> compositor_impl) { 372 base::WeakPtr<CompositorImpl> compositor_impl) {
382 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance(); 373 GpuChannelHostFactory* factory = BrowserGpuChannelHostFactory::instance();
383 GURL url("chrome://gpu/Compositor::createContext3D"); 374 GURL url("chrome://gpu/Compositor::createContext3D");
384 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( 375 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context(
385 new WebGraphicsContext3DCommandBufferImpl(surface_id, 376 new WebGraphicsContext3DCommandBufferImpl(surface_id,
386 url, 377 url,
(...skipping 21 matching lines...) Expand all
408 return context.Pass(); 399 return context.Pass();
409 } 400 }
410 401
411 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface( 402 scoped_ptr<cc::OutputSurface> CompositorImpl::CreateOutputSurface(
412 bool fallback) { 403 bool fallback) {
413 WebKit::WebGraphicsContext3D::Attributes attrs; 404 WebKit::WebGraphicsContext3D::Attributes attrs;
414 attrs.shareResources = true; 405 attrs.shareResources = true;
415 attrs.noAutomaticFlushes = true; 406 attrs.noAutomaticFlushes = true;
416 407
417 if (g_use_direct_gl) { 408 if (g_use_direct_gl) {
409 using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl;
410 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d =
411 WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext(
412 attrs, window_);
418 scoped_refptr<webkit::gpu::ContextProviderInProcess> context_provider = 413 scoped_refptr<webkit::gpu::ContextProviderInProcess> context_provider =
419 webkit::gpu::ContextProviderInProcess::Create( 414 webkit::gpu::ContextProviderInProcess::Create(context3d.Pass());
420 base::Bind(&CreateInProcessViewContext, attrs, window_));
421 415
422 scoped_ptr<cc::OutputSurface> output_surface; 416 scoped_ptr<cc::OutputSurface> output_surface;
423 if (!window_) 417 if (!window_)
424 output_surface.reset(new DirectOutputSurface(context_provider)); 418 output_surface.reset(new DirectOutputSurface(context_provider));
425 else 419 else
426 output_surface.reset(new cc::OutputSurface(context_provider)); 420 output_surface.reset(new cc::OutputSurface(context_provider));
427 return output_surface.Pass(); 421 return output_surface.Pass();
428 } 422 }
429 423
430 DCHECK(window_); 424 DCHECK(window_);
431 DCHECK(surface_id_); 425 DCHECK(surface_id_);
432 426
433 scoped_refptr<ContextProviderCommandBuffer> context_provider = 427 scoped_refptr<ContextProviderCommandBuffer> context_provider =
434 ContextProviderCommandBuffer::Create( 428 ContextProviderCommandBuffer::Create(CreateGpuProcessViewContext(
435 base::Bind(&CreateGpuProcessViewContext, 429 attrs, surface_id_, weak_factory_.GetWeakPtr()));
436 attrs,
437 surface_id_,
438 weak_factory_.GetWeakPtr()));
439 if (!context_provider.get()) { 430 if (!context_provider.get()) {
440 LOG(ERROR) << "Failed to create 3D context for compositor."; 431 LOG(ERROR) << "Failed to create 3D context for compositor.";
441 return scoped_ptr<cc::OutputSurface>(); 432 return scoped_ptr<cc::OutputSurface>();
442 } 433 }
443 return scoped_ptr<cc::OutputSurface>( 434 return scoped_ptr<cc::OutputSurface>(
444 new OutputSurfaceWithoutParent(context_provider)); 435 new OutputSurfaceWithoutParent(context_provider));
445 } 436 }
446 437
447 void CompositorImpl::OnLostResources() { 438 void CompositorImpl::OnLostResources() {
448 client_->DidLoseResources(); 439 client_->DidLoseResources();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 case ANDROID_BITMAP_FORMAT_RGBA_8888: 524 case ANDROID_BITMAP_FORMAT_RGBA_8888:
534 return GL_UNSIGNED_BYTE; 525 return GL_UNSIGNED_BYTE;
535 break; 526 break;
536 case ANDROID_BITMAP_FORMAT_RGB_565: 527 case ANDROID_BITMAP_FORMAT_RGB_565:
537 default: 528 default:
538 return GL_UNSIGNED_SHORT_5_6_5; 529 return GL_UNSIGNED_SHORT_5_6_5;
539 } 530 }
540 } 531 }
541 532
542 } // namespace content 533 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/aura/gpu_process_transport_factory.cc ('k') | content/common/gpu/client/context_provider_command_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698