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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 25 matching lines...) Expand all
36 #include "platform/TraceEvent.h" 36 #include "platform/TraceEvent.h"
37 #include "platform/graphics/GraphicsLayer.h" 37 #include "platform/graphics/GraphicsLayer.h"
38 #include "platform/graphics/ImageBuffer.h" 38 #include "platform/graphics/ImageBuffer.h"
39 #include "platform/graphics/gpu/Extensions3DUtil.h" 39 #include "platform/graphics/gpu/Extensions3DUtil.h"
40 #include "public/platform/Platform.h" 40 #include "public/platform/Platform.h"
41 #include "public/platform/WebCompositorSupport.h" 41 #include "public/platform/WebCompositorSupport.h"
42 #include "public/platform/WebExternalBitmap.h" 42 #include "public/platform/WebExternalBitmap.h"
43 #include "public/platform/WebExternalTextureLayer.h" 43 #include "public/platform/WebExternalTextureLayer.h"
44 #include "public/platform/WebGraphicsContext3DProvider.h" 44 #include "public/platform/WebGraphicsContext3DProvider.h"
45 #include "wtf/CheckedNumeric.h" 45 #include "wtf/CheckedNumeric.h"
46 #include "wtf/PtrUtil.h"
46 #include "wtf/typed_arrays/ArrayBufferContents.h" 47 #include "wtf/typed_arrays/ArrayBufferContents.h"
47 #include <algorithm> 48 #include <algorithm>
49 #include <memory>
48 50
49 namespace blink { 51 namespace blink {
50 52
51 namespace { 53 namespace {
52 54
53 const float s_resourceAdjustedRatio = 0.5; 55 const float s_resourceAdjustedRatio = 0.5;
54 56
55 class ScopedTextureUnit0BindingRestorer { 57 class ScopedTextureUnit0BindingRestorer {
56 STACK_ALLOCATED(); 58 STACK_ALLOCATED();
57 WTF_MAKE_NONCOPYABLE(ScopedTextureUnit0BindingRestorer); 59 WTF_MAKE_NONCOPYABLE(ScopedTextureUnit0BindingRestorer);
(...skipping 14 matching lines...) Expand all
72 private: 74 private:
73 gpu::gles2::GLES2Interface* m_gl; 75 gpu::gles2::GLES2Interface* m_gl;
74 GLenum m_oldActiveTextureUnit; 76 GLenum m_oldActiveTextureUnit;
75 GLuint m_oldTextureUnitZeroId; 77 GLuint m_oldTextureUnitZeroId;
76 }; 78 };
77 79
78 static bool shouldFailDrawingBufferCreationForTesting = false; 80 static bool shouldFailDrawingBufferCreationForTesting = false;
79 81
80 } // namespace 82 } // namespace
81 83
82 PassRefPtr<DrawingBuffer> DrawingBuffer::create(PassOwnPtr<WebGraphicsContext3DP rovider> contextProvider, const IntSize& size, bool premultipliedAlpha, bool wan tAlphaChannel, bool wantDepthBuffer, bool wantStencilBuffer, bool wantAntialiasi ng, PreserveDrawingBuffer preserve) 84 PassRefPtr<DrawingBuffer> DrawingBuffer::create(std::unique_ptr<WebGraphicsConte xt3DProvider> contextProvider, const IntSize& size, bool premultipliedAlpha, boo l wantAlphaChannel, bool wantDepthBuffer, bool wantStencilBuffer, bool wantAntia liasing, PreserveDrawingBuffer preserve)
83 { 85 {
84 ASSERT(contextProvider); 86 ASSERT(contextProvider);
85 87
86 if (shouldFailDrawingBufferCreationForTesting) { 88 if (shouldFailDrawingBufferCreationForTesting) {
87 shouldFailDrawingBufferCreationForTesting = false; 89 shouldFailDrawingBufferCreationForTesting = false;
88 return nullptr; 90 return nullptr;
89 } 91 }
90 92
91 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(contextPr ovider->contextGL()); 93 std::unique_ptr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create( contextProvider->contextGL());
92 if (!extensionsUtil->isValid()) { 94 if (!extensionsUtil->isValid()) {
93 // This might be the first time we notice that the GL context is lost. 95 // This might be the first time we notice that the GL context is lost.
94 return nullptr; 96 return nullptr;
95 } 97 }
96 ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); 98 ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil"));
97 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); 99 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil");
98 bool multisampleSupported = wantAntialiasing 100 bool multisampleSupported = wantAntialiasing
99 && (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp le") 101 && (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp le")
100 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_ texture")) 102 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_ texture"))
101 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); 103 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8");
(...skipping 15 matching lines...) Expand all
117 } 119 }
118 return drawingBuffer.release(); 120 return drawingBuffer.release();
119 } 121 }
120 122
121 void DrawingBuffer::forceNextDrawingBufferCreationToFail() 123 void DrawingBuffer::forceNextDrawingBufferCreationToFail()
122 { 124 {
123 shouldFailDrawingBufferCreationForTesting = true; 125 shouldFailDrawingBufferCreationForTesting = true;
124 } 126 }
125 127
126 DrawingBuffer::DrawingBuffer( 128 DrawingBuffer::DrawingBuffer(
127 PassOwnPtr<WebGraphicsContext3DProvider> contextProvider, 129 std::unique_ptr<WebGraphicsContext3DProvider> contextProvider,
128 PassOwnPtr<Extensions3DUtil> extensionsUtil, 130 std::unique_ptr<Extensions3DUtil> extensionsUtil,
129 bool discardFramebufferSupported, 131 bool discardFramebufferSupported,
130 bool wantAlphaChannel, 132 bool wantAlphaChannel,
131 bool premultipliedAlpha, 133 bool premultipliedAlpha,
132 PreserveDrawingBuffer preserve, 134 PreserveDrawingBuffer preserve,
133 bool wantDepth, 135 bool wantDepth,
134 bool wantStencil) 136 bool wantStencil)
135 : m_preserveDrawingBuffer(preserve) 137 : m_preserveDrawingBuffer(preserve)
136 , m_contextProvider(std::move(contextProvider)) 138 , m_contextProvider(std::move(contextProvider))
137 , m_gl(m_contextProvider->contextGL()) 139 , m_gl(m_contextProvider->contextGL())
138 , m_extensionsUtil(std::move(extensionsUtil)) 140 , m_extensionsUtil(std::move(extensionsUtil))
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 } 553 }
552 554
553 GLuint DrawingBuffer::framebuffer() const 555 GLuint DrawingBuffer::framebuffer() const
554 { 556 {
555 return m_fbo; 557 return m_fbo;
556 } 558 }
557 559
558 WebLayer* DrawingBuffer::platformLayer() 560 WebLayer* DrawingBuffer::platformLayer()
559 { 561 {
560 if (!m_layer) { 562 if (!m_layer) {
561 m_layer = adoptPtr(Platform::current()->compositorSupport()->createExter nalTextureLayer(this)); 563 m_layer = wrapUnique(Platform::current()->compositorSupport()->createExt ernalTextureLayer(this));
562 564
563 m_layer->setOpaque(!m_wantAlphaChannel); 565 m_layer->setOpaque(!m_wantAlphaChannel);
564 m_layer->setBlendBackgroundColor(m_wantAlphaChannel); 566 m_layer->setBlendBackgroundColor(m_wantAlphaChannel);
565 m_layer->setPremultipliedAlpha(m_premultipliedAlpha); 567 m_layer->setPremultipliedAlpha(m_premultipliedAlpha);
566 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality); 568 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality);
567 GraphicsLayer::registerContentsLayer(m_layer->layer()); 569 GraphicsLayer::registerContentsLayer(m_layer->layer());
568 } 570 }
569 571
570 return m_layer->layer(); 572 return m_layer->layer();
571 } 573 }
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1079
1078 void DrawingBuffer::restoreTextureBindings() 1080 void DrawingBuffer::restoreTextureBindings()
1079 { 1081 {
1080 // This class potentially modifies the bindings for GL_TEXTURE_2D and 1082 // This class potentially modifies the bindings for GL_TEXTURE_2D and
1081 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since 1083 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since
1082 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1084 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1083 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1085 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1084 } 1086 }
1085 1087
1086 } // namespace blink 1088 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698