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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2846843002: [blink] Unique pointers in Platform.h (Closed)
Patch Set: fix compilation (and again) Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 Platform::GraphicsInfo* gl_info; 585 Platform::GraphicsInfo* gl_info;
586 KURL url; 586 KURL url;
587 // Outputs. 587 // Outputs.
588 std::unique_ptr<WebGraphicsContext3DProvider> created_context_provider; 588 std::unique_ptr<WebGraphicsContext3DProvider> created_context_provider;
589 }; 589 };
590 590
591 static void CreateContextProviderOnMainThread( 591 static void CreateContextProviderOnMainThread(
592 ContextProviderCreationInfo* creation_info, 592 ContextProviderCreationInfo* creation_info,
593 WaitableEvent* waitable_event) { 593 WaitableEvent* waitable_event) {
594 ASSERT(IsMainThread()); 594 ASSERT(IsMainThread());
595 creation_info->created_context_provider = WTF::WrapUnique( 595 creation_info->created_context_provider =
596 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( 596 Platform::Current()->CreateOffscreenGraphicsContext3DProvider(
597 creation_info->context_attributes, creation_info->url, 0, 597 creation_info->context_attributes, creation_info->url, 0,
598 creation_info->gl_info)); 598 creation_info->gl_info);
599 waitable_event->Signal(); 599 waitable_event->Signal();
600 } 600 }
601 601
602 static std::unique_ptr<WebGraphicsContext3DProvider> 602 static std::unique_ptr<WebGraphicsContext3DProvider>
603 CreateContextProviderOnWorkerThread( 603 CreateContextProviderOnWorkerThread(
604 Platform::ContextAttributes context_attributes, 604 Platform::ContextAttributes context_attributes,
605 Platform::GraphicsInfo* gl_info, 605 Platform::GraphicsInfo* gl_info,
606 const KURL& url) { 606 const KURL& url) {
607 WaitableEvent waitable_event; 607 WaitableEvent waitable_event;
608 ContextProviderCreationInfo creation_info; 608 ContextProviderCreationInfo creation_info;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 : ExecutionContext::From(script_state); 652 : ExecutionContext::From(script_state);
653 Platform::ContextAttributes context_attributes = ToPlatformContextAttributes( 653 Platform::ContextAttributes context_attributes = ToPlatformContextAttributes(
654 attributes, web_gl_version, 654 attributes, web_gl_version,
655 SupportOwnOffscreenSurface(execution_context)); 655 SupportOwnOffscreenSurface(execution_context));
656 656
657 Platform::GraphicsInfo gl_info; 657 Platform::GraphicsInfo gl_info;
658 std::unique_ptr<WebGraphicsContext3DProvider> context_provider; 658 std::unique_ptr<WebGraphicsContext3DProvider> context_provider;
659 const auto& url = canvas ? canvas->GetDocument().TopDocument().Url() 659 const auto& url = canvas ? canvas->GetDocument().TopDocument().Url()
660 : ExecutionContext::From(script_state)->Url(); 660 : ExecutionContext::From(script_state)->Url();
661 if (IsMainThread()) { 661 if (IsMainThread()) {
662 context_provider = WTF::WrapUnique( 662 context_provider =
663 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( 663 Platform::Current()->CreateOffscreenGraphicsContext3DProvider(
664 context_attributes, url, 0, &gl_info)); 664 context_attributes, url, 0, &gl_info);
665 } else { 665 } else {
666 context_provider = 666 context_provider =
667 CreateContextProviderOnWorkerThread(context_attributes, &gl_info, url); 667 CreateContextProviderOnWorkerThread(context_attributes, &gl_info, url);
668 } 668 }
669 if (context_provider && !context_provider->BindToCurrentThread()) { 669 if (context_provider && !context_provider->BindToCurrentThread()) {
670 context_provider = nullptr; 670 context_provider = nullptr;
671 gl_info.error_message = 671 gl_info.error_message =
672 String("bindToCurrentThread failed: " + String(gl_info.error_message)); 672 String("bindToCurrentThread failed: " + String(gl_info.error_message));
673 } 673 }
674 if (!context_provider || g_should_fail_context_creation_for_testing) { 674 if (!context_provider || g_should_fail_context_creation_for_testing) {
(...skipping 6820 matching lines...) Expand 10 before | Expand all | Expand 10 after
7495 7495
7496 auto execution_context = host()->GetTopExecutionContext(); 7496 auto execution_context = host()->GetTopExecutionContext();
7497 Platform::ContextAttributes attributes = ToPlatformContextAttributes( 7497 Platform::ContextAttributes attributes = ToPlatformContextAttributes(
7498 CreationAttributes(), Version(), 7498 CreationAttributes(), Version(),
7499 SupportOwnOffscreenSurface(execution_context)); 7499 SupportOwnOffscreenSurface(execution_context));
7500 Platform::GraphicsInfo gl_info; 7500 Platform::GraphicsInfo gl_info;
7501 std::unique_ptr<WebGraphicsContext3DProvider> context_provider; 7501 std::unique_ptr<WebGraphicsContext3DProvider> context_provider;
7502 const auto& url = host()->GetExecutionContextUrl(); 7502 const auto& url = host()->GetExecutionContextUrl();
7503 7503
7504 if (IsMainThread()) { 7504 if (IsMainThread()) {
7505 context_provider = WTF::WrapUnique( 7505 context_provider =
7506 Platform::Current()->CreateOffscreenGraphicsContext3DProvider( 7506 Platform::Current()->CreateOffscreenGraphicsContext3DProvider(
7507 attributes, url, 0, &gl_info)); 7507 attributes, url, 0, &gl_info);
7508 } else { 7508 } else {
7509 context_provider = 7509 context_provider =
7510 CreateContextProviderOnWorkerThread(attributes, &gl_info, url); 7510 CreateContextProviderOnWorkerThread(attributes, &gl_info, url);
7511 } 7511 }
7512 RefPtr<DrawingBuffer> buffer; 7512 RefPtr<DrawingBuffer> buffer;
7513 if (context_provider && context_provider->BindToCurrentThread()) { 7513 if (context_provider && context_provider->BindToCurrentThread()) {
7514 // Construct a new drawing buffer with the new GL context. 7514 // Construct a new drawing buffer with the new GL context.
7515 buffer = CreateDrawingBuffer(std::move(context_provider)); 7515 buffer = CreateDrawingBuffer(std::move(context_provider));
7516 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| is 7516 // If DrawingBuffer::create() fails to allocate a fbo, |drawingBuffer| is
7517 // set to null. 7517 // set to null.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
7826 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7826 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7827 HTMLCanvasElementOrOffscreenCanvas& result) const { 7827 HTMLCanvasElementOrOffscreenCanvas& result) const {
7828 if (canvas()) { 7828 if (canvas()) {
7829 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host())); 7829 result.setHTMLCanvasElement(static_cast<HTMLCanvasElement*>(host()));
7830 } else { 7830 } else {
7831 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host())); 7831 result.setOffscreenCanvas(static_cast<OffscreenCanvas*>(host()));
7832 } 7832 }
7833 } 7833 }
7834 7834
7835 } // namespace blink 7835 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698