OLD | NEW |
---|---|
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()) | 107 image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()) |
108 ->readPixels(info, dstPixels->data(), info.minRowBytes(), 0, 0); | 108 ->readPixels(info, dstPixels->data(), info.minRowBytes(), 0, 0); |
109 | 109 |
110 GLuint textureId = 0u; | 110 GLuint textureId = 0u; |
111 gl->GenTextures(1, &textureId); | 111 gl->GenTextures(1, &textureId); |
112 gl->BindTexture(GL_TEXTURE_2D, textureId); | 112 gl->BindTexture(GL_TEXTURE_2D, textureId); |
113 GLenum format = | 113 GLenum format = |
114 (kN32_SkColorType == kRGBA_8888_SkColorType) ? GL_RGBA : GL_BGRA_EXT; | 114 (kN32_SkColorType == kRGBA_8888_SkColorType) ? GL_RGBA : GL_BGRA_EXT; |
115 gl->TexImage2D(GL_TEXTURE_2D, 0, format, m_width, m_height, 0, format, | 115 gl->TexImage2D(GL_TEXTURE_2D, 0, format, m_width, m_height, 0, format, |
116 GL_UNSIGNED_BYTE, 0); | 116 GL_UNSIGNED_BYTE, 0); |
117 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 117 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
118 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 118 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
119 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 119 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
120 gl->TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, format, | 120 gl->TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_width, m_height, format, |
121 GL_UNSIGNED_BYTE, dstPixels->data()); | 121 GL_UNSIGNED_BYTE, dstPixels->data()); |
122 | 122 |
123 gpu::Mailbox mailbox; | 123 gpu::Mailbox mailbox; |
124 gl->GenMailboxCHROMIUM(mailbox.name); | 124 gl->GenMailboxCHROMIUM(mailbox.name); |
125 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); | 125 gl->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name); |
126 | 126 |
127 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); | 127 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 | 194 |
195 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 195 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
196 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, | 196 sqs->SetAll(gfx::Transform(), bounds.size(), bounds, bounds, false, 1.f, |
197 SkBlendMode::kSrcOver, 0); | 197 SkBlendMode::kSrcOver, 0); |
198 | 198 |
199 cc::TransferableResource resource; | 199 cc::TransferableResource resource; |
200 resource.id = m_nextResourceId; | 200 resource.id = m_nextResourceId; |
201 resource.format = cc::ResourceFormat::RGBA_8888; | 201 resource.format = cc::ResourceFormat::RGBA_8888; |
202 // TODO(crbug.com/645590): filter should respect the image-rendering CSS | 202 // TODO(crbug.com/645590): filter should respect the image-rendering CSS |
203 // property of associated canvas element. | 203 // property of associated canvas element. |
204 resource.filter = GL_LINEAR; | 204 resource.filter = GL_NEAREST; |
Justin Novosad
2017/01/04 20:38:01
I don't understand how this fixes the problem. Wh
| |
205 resource.size = gfx::Size(m_width, m_height); | 205 resource.size = gfx::Size(m_width, m_height); |
206 // TODO(crbug.com/646022): making this overlay-able. | 206 // TODO(crbug.com/646022): making this overlay-able. |
207 resource.is_overlay_candidate = false; | 207 resource.is_overlay_candidate = false; |
208 | 208 |
209 bool yflipped = false; | 209 bool yflipped = false; |
210 OffscreenCanvasCommitType commitType; | 210 OffscreenCanvasCommitType commitType; |
211 DEFINE_THREAD_SAFE_STATIC_LOCAL( | 211 DEFINE_THREAD_SAFE_STATIC_LOCAL( |
212 EnumerationHistogram, commitTypeHistogram, | 212 EnumerationHistogram, commitTypeHistogram, |
213 new EnumerationHistogram("OffscreenCanvas.CommitType", | 213 new EnumerationHistogram("OffscreenCanvas.CommitType", |
214 OffscreenCanvasCommitTypeCount)); | 214 OffscreenCanvasCommitTypeCount)); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 | 412 |
413 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { | 413 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { |
414 if (m_width != width || m_height != height) { | 414 if (m_width != width || m_height != height) { |
415 m_width = width; | 415 m_width = width; |
416 m_height = height; | 416 m_height = height; |
417 m_changeSizeForNextCommit = true; | 417 m_changeSizeForNextCommit = true; |
418 } | 418 } |
419 } | 419 } |
420 | 420 |
421 } // namespace blink | 421 } // namespace blink |
OLD | NEW |