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

Side by Side Diff: src/gpu/SkGpuDevice.cpp

Issue 2298253002: Add read/write-Pixels to GrDrawContext (Closed)
Patch Set: Created 4 years, 3 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 | « src/gpu/GrDrawContext.cpp ('k') | 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 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkGpuDevice.h" 8 #include "SkGpuDevice.h"
9 9
10 #include "GrBlurUtils.h" 10 #include "GrBlurUtils.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 return filter->filterImage(srcImg, ctx, offset); 199 return filter->filterImage(srcImg, ctx, offset);
200 } 200 }
201 201
202 /////////////////////////////////////////////////////////////////////////////// 202 ///////////////////////////////////////////////////////////////////////////////
203 203
204 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes, 204 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes,
205 int x, int y) { 205 int x, int y) {
206 ASSERT_SINGLE_OWNER 206 ASSERT_SINGLE_OWNER
207 207
208 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels 208 return fDrawContext->readPixels(dstInfo, dstPixels, dstRowBytes, x, y);
209 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo, *fContext->caps()) ;
210 if (kUnknown_GrPixelConfig == config) {
211 return false;
212 }
213
214 uint32_t flags = 0;
215 if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
216 flags = GrContext::kUnpremul_PixelOpsFlag;
217 }
218 return fDrawContext->accessRenderTarget()->readPixels(x, y,
219 dstInfo.width(), dstIn fo.height(),
220 config, dstPixels,
221 dstRowBytes, flags);
222 } 209 }
223 210
224 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz e_t rowBytes, 211 bool SkGpuDevice::onWritePixels(const SkImageInfo& srcInfo, const void* srcPixel s,
225 int x, int y) { 212 size_t srcRowBytes, int x, int y) {
226 ASSERT_SINGLE_OWNER 213 ASSERT_SINGLE_OWNER
227 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels 214
228 GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fContext->caps()); 215 return fDrawContext->writePixels(srcInfo, srcPixels, srcRowBytes, x, y);
229 if (kUnknown_GrPixelConfig == config) {
230 return false;
231 }
232 uint32_t flags = 0;
233 if (kUnpremul_SkAlphaType == info.alphaType()) {
234 flags = GrContext::kUnpremul_PixelOpsFlag;
235 }
236 return fDrawContext->accessRenderTarget()->writePixels(x, y, info.width(), i nfo.height(),
237 config, pixels, rowBy tes, flags);
238 } 216 }
239 217
240 bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) { 218 bool SkGpuDevice::onAccessPixels(SkPixmap* pmap) {
241 ASSERT_SINGLE_OWNER 219 ASSERT_SINGLE_OWNER
242 return false; 220 return false;
243 } 221 }
244 222
245 // call this every draw call, to ensure that the context reflects our state, 223 // call this every draw call, to ensure that the context reflects our state,
246 // and not the state from some other canvas/device 224 // and not the state from some other canvas/device
247 void SkGpuDevice::prepareDraw(const SkDraw& draw) { 225 void SkGpuDevice::prepareDraw(const SkDraw& draw) {
(...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 } 1797 }
1820 1798
1821 SkImageFilterCache* SkGpuDevice::getImageFilterCache() { 1799 SkImageFilterCache* SkGpuDevice::getImageFilterCache() {
1822 ASSERT_SINGLE_OWNER 1800 ASSERT_SINGLE_OWNER
1823 // We always return a transient cache, so it is freed after each 1801 // We always return a transient cache, so it is freed after each
1824 // filter traversal. 1802 // filter traversal.
1825 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize); 1803 return SkImageFilterCache::Create(kDefaultImageFilterCacheSize);
1826 } 1804 }
1827 1805
1828 #endif 1806 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698