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

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

Issue 2825183002: Plumb CanvasColorParams to canvas image classes (Closed)
Patch Set: Require both runtime flags Created 3 years, 8 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 std::unique_ptr<WebGraphicsContext3DProvider> context_provider, 70 std::unique_ptr<WebGraphicsContext3DProvider> context_provider,
71 Client* client, 71 Client* client,
72 const IntSize& size, 72 const IntSize& size,
73 bool premultiplied_alpha, 73 bool premultiplied_alpha,
74 bool want_alpha_channel, 74 bool want_alpha_channel,
75 bool want_depth_buffer, 75 bool want_depth_buffer,
76 bool want_stencil_buffer, 76 bool want_stencil_buffer,
77 bool want_antialiasing, 77 bool want_antialiasing,
78 PreserveDrawingBuffer preserve, 78 PreserveDrawingBuffer preserve,
79 WebGLVersion web_gl_version, 79 WebGLVersion web_gl_version,
80 ChromiumImageUsage chromium_image_usage) { 80 ChromiumImageUsage chromium_image_usage,
81 const CanvasColorParams& color_params) {
81 DCHECK(context_provider); 82 DCHECK(context_provider);
82 83
83 if (g_should_fail_drawing_buffer_creation_for_testing) { 84 if (g_should_fail_drawing_buffer_creation_for_testing) {
84 g_should_fail_drawing_buffer_creation_for_testing = false; 85 g_should_fail_drawing_buffer_creation_for_testing = false;
85 return nullptr; 86 return nullptr;
86 } 87 }
87 88
88 std::unique_ptr<Extensions3DUtil> extensions_util = 89 std::unique_ptr<Extensions3DUtil> extensions_util =
89 Extensions3DUtil::Create(context_provider->ContextGL()); 90 Extensions3DUtil::Create(context_provider->ContextGL());
90 if (!extensions_util->IsValid()) { 91 if (!extensions_util->IsValid()) {
(...skipping 21 matching lines...) Expand all
112 } 113 }
113 bool discard_framebuffer_supported = 114 bool discard_framebuffer_supported =
114 extensions_util->SupportsExtension("GL_EXT_discard_framebuffer"); 115 extensions_util->SupportsExtension("GL_EXT_discard_framebuffer");
115 if (discard_framebuffer_supported) 116 if (discard_framebuffer_supported)
116 extensions_util->EnsureExtensionEnabled("GL_EXT_discard_framebuffer"); 117 extensions_util->EnsureExtensionEnabled("GL_EXT_discard_framebuffer");
117 118
118 RefPtr<DrawingBuffer> drawing_buffer = AdoptRef(new DrawingBuffer( 119 RefPtr<DrawingBuffer> drawing_buffer = AdoptRef(new DrawingBuffer(
119 std::move(context_provider), std::move(extensions_util), client, 120 std::move(context_provider), std::move(extensions_util), client,
120 discard_framebuffer_supported, want_alpha_channel, premultiplied_alpha, 121 discard_framebuffer_supported, want_alpha_channel, premultiplied_alpha,
121 preserve, web_gl_version, want_depth_buffer, want_stencil_buffer, 122 preserve, web_gl_version, want_depth_buffer, want_stencil_buffer,
122 chromium_image_usage)); 123 chromium_image_usage, color_params));
123 if (!drawing_buffer->Initialize(size, multisample_supported)) { 124 if (!drawing_buffer->Initialize(size, multisample_supported)) {
124 drawing_buffer->BeginDestruction(); 125 drawing_buffer->BeginDestruction();
125 return PassRefPtr<DrawingBuffer>(); 126 return PassRefPtr<DrawingBuffer>();
126 } 127 }
127 return drawing_buffer.Release(); 128 return drawing_buffer.Release();
128 } 129 }
129 130
130 void DrawingBuffer::ForceNextDrawingBufferCreationToFail() { 131 void DrawingBuffer::ForceNextDrawingBufferCreationToFail() {
131 g_should_fail_drawing_buffer_creation_for_testing = true; 132 g_should_fail_drawing_buffer_creation_for_testing = true;
132 } 133 }
133 134
134 DrawingBuffer::DrawingBuffer( 135 DrawingBuffer::DrawingBuffer(
135 std::unique_ptr<WebGraphicsContext3DProvider> context_provider, 136 std::unique_ptr<WebGraphicsContext3DProvider> context_provider,
136 std::unique_ptr<Extensions3DUtil> extensions_util, 137 std::unique_ptr<Extensions3DUtil> extensions_util,
137 Client* client, 138 Client* client,
138 bool discard_framebuffer_supported, 139 bool discard_framebuffer_supported,
139 bool want_alpha_channel, 140 bool want_alpha_channel,
140 bool premultiplied_alpha, 141 bool premultiplied_alpha,
141 PreserveDrawingBuffer preserve, 142 PreserveDrawingBuffer preserve,
142 WebGLVersion web_gl_version, 143 WebGLVersion web_gl_version,
143 bool want_depth, 144 bool want_depth,
144 bool want_stencil, 145 bool want_stencil,
145 ChromiumImageUsage chromium_image_usage) 146 ChromiumImageUsage chromium_image_usage,
147 const CanvasColorParams& color_params)
146 : client_(client), 148 : client_(client),
147 preserve_drawing_buffer_(preserve), 149 preserve_drawing_buffer_(preserve),
148 web_gl_version_(web_gl_version), 150 web_gl_version_(web_gl_version),
149 context_provider_(WTF::WrapUnique(new WebGraphicsContext3DProviderWrapper( 151 context_provider_(WTF::WrapUnique(new WebGraphicsContext3DProviderWrapper(
150 std::move(context_provider)))), 152 std::move(context_provider)))),
151 gl_(this->ContextProvider()->ContextGL()), 153 gl_(this->ContextProvider()->ContextGL()),
152 extensions_util_(std::move(extensions_util)), 154 extensions_util_(std::move(extensions_util)),
153 discard_framebuffer_supported_(discard_framebuffer_supported), 155 discard_framebuffer_supported_(discard_framebuffer_supported),
154 want_alpha_channel_(want_alpha_channel), 156 want_alpha_channel_(want_alpha_channel),
155 premultiplied_alpha_(premultiplied_alpha), 157 premultiplied_alpha_(premultiplied_alpha),
156 software_rendering_(this->ContextProvider()->IsSoftwareRendering()), 158 software_rendering_(this->ContextProvider()->IsSoftwareRendering()),
157 want_depth_(want_depth), 159 want_depth_(want_depth),
158 want_stencil_(want_stencil), 160 want_stencil_(want_stencil),
159 color_space_(gfx::ColorSpace::CreateSRGB()), 161 color_space_(color_params.GetGfxColorSpace()),
160 chromium_image_usage_(chromium_image_usage) { 162 chromium_image_usage_(chromium_image_usage) {
161 // Used by browser tests to detect the use of a DrawingBuffer. 163 // Used by browser tests to detect the use of a DrawingBuffer.
162 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation", 164 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation",
163 TRACE_EVENT_SCOPE_GLOBAL); 165 TRACE_EVENT_SCOPE_GLOBAL);
164 } 166 }
165 167
166 DrawingBuffer::~DrawingBuffer() { 168 DrawingBuffer::~DrawingBuffer() {
167 DCHECK(destruction_in_progress_); 169 DCHECK(destruction_in_progress_);
168 layer_.reset(); 170 layer_.reset();
169 context_provider_.reset(); 171 context_provider_.reset();
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 if (pixel_unpack_buffer_binding_dirty_) 1303 if (pixel_unpack_buffer_binding_dirty_)
1302 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); 1304 client->DrawingBufferClientRestorePixelUnpackBufferBinding();
1303 } 1305 }
1304 1306
1305 bool DrawingBuffer::ShouldUseChromiumImage() { 1307 bool DrawingBuffer::ShouldUseChromiumImage() {
1306 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && 1308 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() &&
1307 chromium_image_usage_ == kAllowChromiumImage; 1309 chromium_image_usage_ == kAllowChromiumImage;
1308 } 1310 }
1309 1311
1310 } // namespace blink 1312 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698