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

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

Issue 2807923002: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/graphics (Closed)
Patch Set: fix typo 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ASSERT(context_provider); 81 DCHECK(context_provider);
82 82
83 if (g_should_fail_drawing_buffer_creation_for_testing) { 83 if (g_should_fail_drawing_buffer_creation_for_testing) {
84 g_should_fail_drawing_buffer_creation_for_testing = false; 84 g_should_fail_drawing_buffer_creation_for_testing = false;
85 return nullptr; 85 return nullptr;
86 } 86 }
87 87
88 std::unique_ptr<Extensions3DUtil> extensions_util = 88 std::unique_ptr<Extensions3DUtil> extensions_util =
89 Extensions3DUtil::Create(context_provider->ContextGL()); 89 Extensions3DUtil::Create(context_provider->ContextGL());
90 if (!extensions_util->IsValid()) { 90 if (!extensions_util->IsValid()) {
91 // This might be the first time we notice that the GL context is lost. 91 // This might be the first time we notice that the GL context is lost.
92 return nullptr; 92 return nullptr;
93 } 93 }
94 ASSERT(extensions_util->SupportsExtension("GL_OES_packed_depth_stencil")); 94 DCHECK(extensions_util->SupportsExtension("GL_OES_packed_depth_stencil"));
95 extensions_util->EnsureExtensionEnabled("GL_OES_packed_depth_stencil"); 95 extensions_util->EnsureExtensionEnabled("GL_OES_packed_depth_stencil");
96 bool multisample_supported = 96 bool multisample_supported =
97 want_antialiasing && 97 want_antialiasing &&
98 (extensions_util->SupportsExtension( 98 (extensions_util->SupportsExtension(
99 "GL_CHROMIUM_framebuffer_multisample") || 99 "GL_CHROMIUM_framebuffer_multisample") ||
100 extensions_util->SupportsExtension( 100 extensions_util->SupportsExtension(
101 "GL_EXT_multisampled_render_to_texture")) && 101 "GL_EXT_multisampled_render_to_texture")) &&
102 extensions_util->SupportsExtension("GL_OES_rgb8_rgba8"); 102 extensions_util->SupportsExtension("GL_OES_rgb8_rgba8");
103 if (multisample_supported) { 103 if (multisample_supported) {
104 extensions_util->EnsureExtensionEnabled("GL_OES_rgb8_rgba8"); 104 extensions_util->EnsureExtensionEnabled("GL_OES_rgb8_rgba8");
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 179 }
180 180
181 bool DrawingBuffer::BufferClearNeeded() const { 181 bool DrawingBuffer::BufferClearNeeded() const {
182 return buffer_clear_needed_; 182 return buffer_clear_needed_;
183 } 183 }
184 184
185 void DrawingBuffer::SetBufferClearNeeded(bool flag) { 185 void DrawingBuffer::SetBufferClearNeeded(bool flag) {
186 if (preserve_drawing_buffer_ == kDiscard) { 186 if (preserve_drawing_buffer_ == kDiscard) {
187 buffer_clear_needed_ = flag; 187 buffer_clear_needed_ = flag;
188 } else { 188 } else {
189 ASSERT(!buffer_clear_needed_); 189 DCHECK(!buffer_clear_needed_);
190 } 190 }
191 } 191 }
192 192
193 gpu::gles2::GLES2Interface* DrawingBuffer::ContextGL() { 193 gpu::gles2::GLES2Interface* DrawingBuffer::ContextGL() {
194 return gl_; 194 return gl_;
195 } 195 }
196 196
197 WebGraphicsContext3DProvider* DrawingBuffer::ContextProvider() { 197 WebGraphicsContext3DProvider* DrawingBuffer::ContextProvider() {
198 return context_provider_->ContextProvider(); 198 return context_provider_->ContextProvider();
199 } 199 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 bool force_gpu_result) { 263 bool force_gpu_result) {
264 DCHECK(state_restorer_); 264 DCHECK(state_restorer_);
265 if (destruction_in_progress_) { 265 if (destruction_in_progress_) {
266 // It can be hit in the following sequence. 266 // It can be hit in the following sequence.
267 // 1. WebGL draws something. 267 // 1. WebGL draws something.
268 // 2. The compositor begins the frame. 268 // 2. The compositor begins the frame.
269 // 3. Javascript makes a context lost using WEBGL_lose_context extension. 269 // 3. Javascript makes a context lost using WEBGL_lose_context extension.
270 // 4. Here. 270 // 4. Here.
271 return false; 271 return false;
272 } 272 }
273 ASSERT(!is_hidden_); 273 DCHECK(!is_hidden_);
274 if (!contents_changed_) 274 if (!contents_changed_)
275 return false; 275 return false;
276 276
277 // If the context is lost, we don't know if we should be producing GPU or 277 // If the context is lost, we don't know if we should be producing GPU or
278 // software frames, until we get a new context, since the compositor will 278 // software frames, until we get a new context, since the compositor will
279 // be trying to get a new context and may change modes. 279 // be trying to get a new context and may change modes.
280 if (gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR) 280 if (gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR)
281 return false; 281 return false;
282 282
283 TRACE_EVENT0("blink,rail", "DrawingBuffer::prepareMailbox"); 283 TRACE_EVENT0("blink,rail", "DrawingBuffer::prepareMailbox");
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 } 781 }
782 782
783 void DrawingBuffer::ClearPlatformLayer() { 783 void DrawingBuffer::ClearPlatformLayer() {
784 if (layer_) 784 if (layer_)
785 layer_->ClearTexture(); 785 layer_->ClearTexture();
786 786
787 gl_->Flush(); 787 gl_->Flush();
788 } 788 }
789 789
790 void DrawingBuffer::BeginDestruction() { 790 void DrawingBuffer::BeginDestruction() {
791 ASSERT(!destruction_in_progress_); 791 DCHECK(!destruction_in_progress_);
792 destruction_in_progress_ = true; 792 destruction_in_progress_ = true;
793 793
794 ClearPlatformLayer(); 794 ClearPlatformLayer();
795 recycled_color_buffer_queue_.Clear(); 795 recycled_color_buffer_queue_.Clear();
796 796
797 if (multisample_fbo_) 797 if (multisample_fbo_)
798 gl_->DeleteFramebuffers(1, &multisample_fbo_); 798 gl_->DeleteFramebuffers(1, &multisample_fbo_);
799 799
800 if (fbo_) 800 if (fbo_)
801 gl_->DeleteFramebuffers(1, &fbo_); 801 gl_->DeleteFramebuffers(1, &fbo_);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 gl_->BindFramebuffer(target, WantExplicitResolve() ? multisample_fbo_ : fbo_); 1044 gl_->BindFramebuffer(target, WantExplicitResolve() ? multisample_fbo_ : fbo_);
1045 } 1045 }
1046 1046
1047 bool DrawingBuffer::PaintRenderingResultsToImageData( 1047 bool DrawingBuffer::PaintRenderingResultsToImageData(
1048 int& width, 1048 int& width,
1049 int& height, 1049 int& height,
1050 SourceDrawingBuffer source_buffer, 1050 SourceDrawingBuffer source_buffer,
1051 WTF::ArrayBufferContents& contents) { 1051 WTF::ArrayBufferContents& contents) {
1052 ScopedStateRestorer scoped_state_restorer(this); 1052 ScopedStateRestorer scoped_state_restorer(this);
1053 1053
1054 ASSERT(!premultiplied_alpha_); 1054 DCHECK(!premultiplied_alpha_);
1055 width = size().Width(); 1055 width = size().Width();
1056 height = size().Height(); 1056 height = size().Height();
1057 1057
1058 CheckedNumeric<int> data_size = 4; 1058 CheckedNumeric<int> data_size = 4;
1059 data_size *= width; 1059 data_size *= width;
1060 data_size *= height; 1060 data_size *= height;
1061 if (!data_size.IsValid()) 1061 if (!data_size.IsValid())
1062 return false; 1062 return false;
1063 1063
1064 WTF::ArrayBufferContents pixels(width * height, 4, 1064 WTF::ArrayBufferContents pixels(width * height, 4,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 #endif 1113 #endif
1114 } 1114 }
1115 1115
1116 if (op == WebGLImageConversion::kAlphaDoPremultiply) { 1116 if (op == WebGLImageConversion::kAlphaDoPremultiply) {
1117 for (size_t i = 0; i < buffer_size; i += 4) { 1117 for (size_t i = 0; i < buffer_size; i += 4) {
1118 pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255); 1118 pixels[i + 0] = std::min(255, pixels[i + 0] * pixels[i + 3] / 255);
1119 pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255); 1119 pixels[i + 1] = std::min(255, pixels[i + 1] * pixels[i + 3] / 255);
1120 pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255); 1120 pixels[i + 2] = std::min(255, pixels[i + 2] * pixels[i + 3] / 255);
1121 } 1121 }
1122 } else if (op != WebGLImageConversion::kAlphaDoNothing) { 1122 } else if (op != WebGLImageConversion::kAlphaDoNothing) {
1123 ASSERT_NOT_REACHED(); 1123 NOTREACHED();
1124 } 1124 }
1125 } 1125 }
1126 1126
1127 void DrawingBuffer::FlipVertically(uint8_t* framebuffer, 1127 void DrawingBuffer::FlipVertically(uint8_t* framebuffer,
1128 int width, 1128 int width,
1129 int height) { 1129 int height) {
1130 std::vector<uint8_t> scanline(width * 4); 1130 std::vector<uint8_t> scanline(width * 4);
1131 unsigned row_bytes = width * 4; 1131 unsigned row_bytes = width * 4;
1132 unsigned count = height / 2; 1132 unsigned count = height / 2;
1133 for (unsigned i = 0; i < count; i++) { 1133 for (unsigned i = 0; i < count; i++) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 if (pixel_unpack_buffer_binding_dirty_) 1301 if (pixel_unpack_buffer_binding_dirty_)
1302 client->DrawingBufferClientRestorePixelUnpackBufferBinding(); 1302 client->DrawingBufferClientRestorePixelUnpackBufferBinding();
1303 } 1303 }
1304 1304
1305 bool DrawingBuffer::ShouldUseChromiumImage() { 1305 bool DrawingBuffer::ShouldUseChromiumImage() {
1306 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() && 1306 return RuntimeEnabledFeatures::webGLImageChromiumEnabled() &&
1307 chromium_image_usage_ == kAllowChromiumImage; 1307 chromium_image_usage_ == kAllowChromiumImage;
1308 } 1308 }
1309 1309
1310 } // namespace blink 1310 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698