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

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: Merge. 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 } 555 }
554 556
555 GLuint DrawingBuffer::framebuffer() const 557 GLuint DrawingBuffer::framebuffer() const
556 { 558 {
557 return m_fbo; 559 return m_fbo;
558 } 560 }
559 561
560 WebLayer* DrawingBuffer::platformLayer() 562 WebLayer* DrawingBuffer::platformLayer()
561 { 563 {
562 if (!m_layer) { 564 if (!m_layer) {
563 m_layer = adoptPtr(Platform::current()->compositorSupport()->createExter nalTextureLayer(this)); 565 m_layer = wrapUnique(Platform::current()->compositorSupport()->createExt ernalTextureLayer(this));
564 566
565 m_layer->setOpaque(!m_wantAlphaChannel); 567 m_layer->setOpaque(!m_wantAlphaChannel);
566 m_layer->setBlendBackgroundColor(m_wantAlphaChannel); 568 m_layer->setBlendBackgroundColor(m_wantAlphaChannel);
567 m_layer->setPremultipliedAlpha(m_premultipliedAlpha); 569 m_layer->setPremultipliedAlpha(m_premultipliedAlpha);
568 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality); 570 m_layer->setNearestNeighbor(m_filterQuality == kNone_SkFilterQuality);
569 GraphicsLayer::registerContentsLayer(m_layer->layer()); 571 GraphicsLayer::registerContentsLayer(m_layer->layer());
570 } 572 }
571 573
572 return m_layer->layer(); 574 return m_layer->layer();
573 } 575 }
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 1081
1080 void DrawingBuffer::restoreTextureBindings() 1082 void DrawingBuffer::restoreTextureBindings()
1081 { 1083 {
1082 // This class potentially modifies the bindings for GL_TEXTURE_2D and 1084 // This class potentially modifies the bindings for GL_TEXTURE_2D and
1083 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since 1085 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since
1084 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. 1086 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE.
1085 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1087 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1086 } 1088 }
1087 1089
1088 } // namespace blink 1090 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698