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

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

Issue 2758863003: Fix error msg of OffscreenCanvas.commit() on gpu compositing (Closed)
Patch Set: m 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" 5 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h"
6 6
7 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/quads/texture_draw_quad.h" 8 #include "cc/quads/texture_draw_quad.h"
9 #include "gpu/command_buffer/client/gles2_interface.h" 9 #include "gpu/command_buffer/client/gles2_interface.h"
10 #include "platform/CrossThreadFunctional.h" 10 #include "platform/CrossThreadFunctional.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 info.minRowBytes(), 0, 0); 114 info.minRowBytes(), 0, 0);
115 115
116 GLuint textureId = 0u; 116 GLuint textureId = 0u;
117 gl->GenTextures(1, &textureId); 117 gl->GenTextures(1, &textureId);
118 gl->BindTexture(GL_TEXTURE_2D, textureId); 118 gl->BindTexture(GL_TEXTURE_2D, textureId);
119 GLenum format = 119 GLenum format =
120 (kN32_SkColorType == kRGBA_8888_SkColorType) ? GL_RGBA : GL_BGRA_EXT; 120 (kN32_SkColorType == kRGBA_8888_SkColorType) ? GL_RGBA : GL_BGRA_EXT;
121 gl->TexImage2D(GL_TEXTURE_2D, 0, format, m_width, m_height, 0, format, 121 gl->TexImage2D(GL_TEXTURE_2D, 0, format, m_width, m_height, 0, format,
122 GL_UNSIGNED_BYTE, 0); 122 GL_UNSIGNED_BYTE, 0);
123 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 123 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
124 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
124 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 125 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
125 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 126 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
126 gl->TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, format, 127 gl->TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, format,
127 GL_UNSIGNED_BYTE, dstPixels->data()); 128 GL_UNSIGNED_BYTE, dstPixels->data());
128 129
129 gpu::Mailbox mailbox; 130 gpu::Mailbox mailbox;
130 gl->GenMailboxCHROMIUM(mailbox.name); 131 gl->GenMailboxCHROMIUM(mailbox.name);
131 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); 132 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
132 133
133 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); 134 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 pass->SetNew(renderPassId, bounds, bounds, gfx::Transform()); 227 pass->SetNew(renderPassId, bounds, bounds, gfx::Transform());
227 228
228 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 229 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
229 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, 230 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f,
230 SkBlendMode::kSrcOver, 0); 231 SkBlendMode::kSrcOver, 0);
231 232
232 cc::TransferableResource resource; 233 cc::TransferableResource resource;
233 resource.id = m_nextResourceId; 234 resource.id = m_nextResourceId;
234 resource.format = cc::ResourceFormat::RGBA_8888; 235 resource.format = cc::ResourceFormat::RGBA_8888;
235 resource.size = gfx::Size(m_width, m_height); 236 resource.size = gfx::Size(m_width, m_height);
237 // This indicates the filtering on the resource inherently, not the desired
238 // filtering effect on the quad.
239 resource.filter = GL_NEAREST;
236 // TODO(crbug.com/646022): making this overlay-able. 240 // TODO(crbug.com/646022): making this overlay-able.
237 resource.is_overlay_candidate = false; 241 resource.is_overlay_candidate = false;
238 242
239 bool yflipped = false; 243 bool yflipped = false;
240 OffscreenCanvasCommitType commitType; 244 OffscreenCanvasCommitType commitType;
241 DEFINE_THREAD_SAFE_STATIC_LOCAL( 245 DEFINE_THREAD_SAFE_STATIC_LOCAL(
242 EnumerationHistogram, commitTypeHistogram, 246 EnumerationHistogram, commitTypeHistogram,
243 new EnumerationHistogram("OffscreenCanvas.CommitType", 247 new EnumerationHistogram("OffscreenCanvas.CommitType",
244 OffscreenCanvasCommitTypeCount)); 248 OffscreenCanvasCommitTypeCount));
245 if (image->isTextureBacked()) { 249 if (image->isTextureBacked()) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 client()->beginFrame(); 415 client()->beginFrame();
412 // TODO(eseckler): Tell |m_sink| if we did not draw during the BeginFrame. 416 // TODO(eseckler): Tell |m_sink| if we did not draw during the BeginFrame.
413 m_currentBeginFrameAck.sequence_number = 417 m_currentBeginFrameAck.sequence_number =
414 cc::BeginFrameArgs::kInvalidFrameNumber; 418 cc::BeginFrameArgs::kInvalidFrameNumber;
415 } 419 }
416 420
417 void OffscreenCanvasFrameDispatcherImpl::ReclaimResources( 421 void OffscreenCanvasFrameDispatcherImpl::ReclaimResources(
418 const cc::ReturnedResourceArray& resources) { 422 const cc::ReturnedResourceArray& resources) {
419 for (const auto& resource : resources) { 423 for (const auto& resource : resources) {
420 RefPtr<StaticBitmapImage> image = m_cachedImages.at(resource.id); 424 RefPtr<StaticBitmapImage> image = m_cachedImages.at(resource.id);
421
422 if (image) { 425 if (image) {
423 if (image->hasMailbox()) { 426 if (image->hasMailbox()) {
424 image->updateSyncToken(resource.sync_token); 427 image->updateSyncToken(resource.sync_token);
425 } else if (SharedGpuContext::isValid() && resource.sync_token.HasData()) { 428 } else if (SharedGpuContext::isValid() && resource.sync_token.HasData()) {
426 // Although image has MailboxTextureHolder at the time when it is 429 // Although image has MailboxTextureHolder at the time when it is
427 // inserted to m_cachedImages, the 430 // inserted to m_cachedImages, the
428 // OffscreenCanvasPlaceHolder::placeholderFrame() exposes this image to 431 // OffscreenCanvasPlaceHolder::placeholderFrame() exposes this image to
429 // everyone accessing the placeholder canvas as an image source, some of 432 // everyone accessing the placeholder canvas as an image source, some of
430 // which may want to consume the image as a SkImage, thereby converting 433 // which may want to consume the image as a SkImage, thereby converting
431 // the MailTextureHolder to a SkiaTextureHolder. In this case, we 434 // the MailTextureHolder to a SkiaTextureHolder. In this case, we
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 472
470 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { 473 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) {
471 if (m_width != width || m_height != height) { 474 if (m_width != width || m_height != height) {
472 m_width = width; 475 m_width = width;
473 m_height = height; 476 m_height = height;
474 m_changeSizeForNextCommit = true; 477 m_changeSizeForNextCommit = true;
475 } 478 }
476 } 479 }
477 480
478 } // namespace blink 481 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698