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

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

Issue 2727133002: Remove ColorBehavior argument to Image::imageForCurrentFrame (Closed)
Patch Set: Rebase Created 3 years, 9 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 // 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (!bitmap) 68 if (!bitmap)
69 return; 69 return;
70 unsigned char* pixels = bitmap->pixels(); 70 unsigned char* pixels = bitmap->pixels();
71 DCHECK(pixels); 71 DCHECK(pixels);
72 SkImageInfo imageInfo = SkImageInfo::Make( 72 SkImageInfo imageInfo = SkImageInfo::Make(
73 m_width, m_height, kN32_SkColorType, 73 m_width, m_height, kN32_SkColorType,
74 image->isPremultiplied() ? kPremul_SkAlphaType : kUnpremul_SkAlphaType); 74 image->isPremultiplied() ? kPremul_SkAlphaType : kUnpremul_SkAlphaType);
75 // TODO(xlai): Optimize to avoid copying pixels. See crbug.com/651456. 75 // TODO(xlai): Optimize to avoid copying pixels. See crbug.com/651456.
76 // However, in the case when |image| is texture backed, this function call 76 // However, in the case when |image| is texture backed, this function call
77 // does a GPU readback which is required. 77 // does a GPU readback which is required.
78 // TODO(ccameron): Canvas should produce sRGB images. 78 image->imageForCurrentFrame()->readPixels(imageInfo, pixels,
79 // https://crbug.com/672299 79 imageInfo.minRowBytes(), 0, 0);
80 image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget())
81 ->readPixels(imageInfo, pixels, imageInfo.minRowBytes(), 0, 0);
82 resource.mailbox_holder.mailbox = bitmap->id(); 80 resource.mailbox_holder.mailbox = bitmap->id();
83 resource.mailbox_holder.texture_target = 0; 81 resource.mailbox_holder.texture_target = 0;
84 resource.is_software = true; 82 resource.is_software = true;
85 83
86 // Hold ref to |bitmap|, to keep it alive until the browser ReclaimResources. 84 // Hold ref to |bitmap|, to keep it alive until the browser ReclaimResources.
87 // It guarantees that the shared bitmap is not re-used or deleted. 85 // It guarantees that the shared bitmap is not re-used or deleted.
88 m_sharedBitmaps.insert(m_nextResourceId, std::move(bitmap)); 86 m_sharedBitmaps.insert(m_nextResourceId, std::move(bitmap));
89 } 87 }
90 88
91 void OffscreenCanvasFrameDispatcherImpl:: 89 void OffscreenCanvasFrameDispatcherImpl::
(...skipping 13 matching lines...) Expand all
105 SkImageInfo info = SkImageInfo::Make( 103 SkImageInfo info = SkImageInfo::Make(
106 m_width, m_height, kN32_SkColorType, 104 m_width, m_height, kN32_SkColorType,
107 image->isPremultiplied() ? kPremul_SkAlphaType : kUnpremul_SkAlphaType); 105 image->isPremultiplied() ? kPremul_SkAlphaType : kUnpremul_SkAlphaType);
108 RefPtr<ArrayBuffer> dstBuffer = 106 RefPtr<ArrayBuffer> dstBuffer =
109 ArrayBuffer::createOrNull(m_width * m_height, info.bytesPerPixel()); 107 ArrayBuffer::createOrNull(m_width * m_height, info.bytesPerPixel());
110 // If it fails to create a buffer for copying the pixel data, then exit early. 108 // If it fails to create a buffer for copying the pixel data, then exit early.
111 if (!dstBuffer) 109 if (!dstBuffer)
112 return; 110 return;
113 RefPtr<Uint8Array> dstPixels = 111 RefPtr<Uint8Array> dstPixels =
114 Uint8Array::create(dstBuffer, 0, dstBuffer->byteLength()); 112 Uint8Array::create(dstBuffer, 0, dstBuffer->byteLength());
115 // TODO(ccameron): Canvas should produce sRGB images. 113 image->imageForCurrentFrame()->readPixels(info, dstPixels->data(),
116 // https://crbug.com/672299 114 info.minRowBytes(), 0, 0);
117 image->imageForCurrentFrame(ColorBehavior::transformToGlobalTarget())
118 ->readPixels(info, dstPixels->data(), info.minRowBytes(), 0, 0);
119 115
120 GLuint textureId = 0u; 116 GLuint textureId = 0u;
121 gl->GenTextures(1, &textureId); 117 gl->GenTextures(1, &textureId);
122 gl->BindTexture(GL_TEXTURE_2D, textureId); 118 gl->BindTexture(GL_TEXTURE_2D, textureId);
123 GLenum format = 119 GLenum format =
124 (kN32_SkColorType == kRGBA_8888_SkColorType) ? GL_RGBA : GL_BGRA_EXT; 120 (kN32_SkColorType == kRGBA_8888_SkColorType) ? GL_RGBA : GL_BGRA_EXT;
125 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,
126 GL_UNSIGNED_BYTE, 0); 122 GL_UNSIGNED_BYTE, 0);
127 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 123 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
128 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 124 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 437
442 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) { 438 void OffscreenCanvasFrameDispatcherImpl::reshape(int width, int height) {
443 if (m_width != width || m_height != height) { 439 if (m_width != width || m_height != height) {
444 m_width = width; 440 m_width = width;
445 m_height = height; 441 m_height = height;
446 m_changeSizeForNextCommit = true; 442 m_changeSizeForNextCommit = true;
447 } 443 }
448 } 444 }
449 445
450 } // namespace blink 446 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698