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

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

Issue 199413013: add new readPixels with direct memory parameters (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
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 "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 *flags = GrContext::kUnpremul_PixelOpsFlag; 365 *flags = GrContext::kUnpremul_PixelOpsFlag;
366 return kRGBA_8888_GrPixelConfig; 366 return kRGBA_8888_GrPixelConfig;
367 default: 367 default:
368 GrCrash("Unexpected Config8888."); 368 GrCrash("Unexpected Config8888.");
369 *flags = 0; // suppress warning 369 *flags = 0; // suppress warning
370 return kSkia8888_GrPixelConfig; 370 return kSkia8888_GrPixelConfig;
371 } 371 }
372 } 372 }
373 } 373 }
374 374
375 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
376 void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y,
377 SkCanvas::Config8888 config8888) {
378 SkAutoLockPixels alp(bitmap);
379 if (!bitmap.readyToDraw()) {
380 return;
381 }
382
383 GrPixelConfig config;
384 uint32_t flags;
385 if (SkBitmap::kARGB_8888_Config == bitmap.config()) {
386 config = config8888_to_grconfig_and_flags(config8888, &flags);
387 } else {
388 flags = 0;
389 config= SkBitmapConfig2GrPixelConfig(bitmap.config());
390 }
391
392 fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(),
393 config, bitmap.getPixels(), bitmap.rowBytes(), fl ags);
394 }
395 #endif
396
397 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG
375 bool SkGpuDevice::onReadPixels(const SkBitmap& bitmap, 398 bool SkGpuDevice::onReadPixels(const SkBitmap& bitmap,
376 int x, int y, 399 int x, int y,
377 SkCanvas::Config8888 config8888) { 400 SkCanvas::Config8888 config8888) {
378 DO_DEFERRED_CLEAR(); 401 DO_DEFERRED_CLEAR();
379 SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config()); 402 SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config());
380 SkASSERT(!bitmap.isNull()); 403 SkASSERT(!bitmap.isNull());
381 SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::Ma keXYWH(x, y, bitmap.width(), bitmap.height()))); 404 SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::Ma keXYWH(x, y, bitmap.width(), bitmap.height())));
382 405
383 SkAutoLockPixels alp(bitmap); 406 SkAutoLockPixels alp(bitmap);
384 GrPixelConfig config; 407 GrPixelConfig config;
385 uint32_t flags; 408 uint32_t flags;
386 config = config8888_to_grconfig_and_flags(config8888, &flags); 409 config = config8888_to_grconfig_and_flags(config8888, &flags);
387 return fContext->readRenderTargetPixels(fRenderTarget, 410 return fContext->readRenderTargetPixels(fRenderTarget,
388 x, y, 411 x, y,
389 bitmap.width(), 412 bitmap.width(),
390 bitmap.height(), 413 bitmap.height(),
391 config, 414 config,
392 bitmap.getPixels(), 415 bitmap.getPixels(),
393 bitmap.rowBytes(), 416 bitmap.rowBytes(),
394 flags); 417 flags);
395 } 418 }
419 #endif
396 420
397 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG 421 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size _t dstRowBytes,
398 void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y, 422 int x, int y) {
399 SkCanvas::Config8888 config8888) { 423 DO_DEFERRED_CLEAR();
400 SkAutoLockPixels alp(bitmap); 424
401 if (!bitmap.readyToDraw()) { 425 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels
402 return; 426 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo.colorType(), dstInf o.alphaType());
427 if (kUnknown_GrPixelConfig == config) {
428 return false;
403 } 429 }
404 430
405 GrPixelConfig config; 431 uint32_t flags = 0;
406 uint32_t flags; 432 if (kUnpremul_SkAlphaType == dstInfo.alphaType()) {
407 if (SkBitmap::kARGB_8888_Config == bitmap.config()) { 433 flags = GrContext::kUnpremul_PixelOpsFlag;
408 config = config8888_to_grconfig_and_flags(config8888, &flags);
409 } else {
410 flags = 0;
411 config= SkBitmapConfig2GrPixelConfig(bitmap.config());
412 } 434 }
413 435 return fContext->readRenderTargetPixels(fRenderTarget, x, y, dstInfo.width() , dstInfo.height(),
414 fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(), 436 config, dstPixels, dstRowBytes, flag s);
415 config, bitmap.getPixels(), bitmap.rowBytes(), fl ags);
416 } 437 }
417 #endif
418 438
419 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz e_t rowBytes, 439 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz e_t rowBytes,
420 int x, int y) { 440 int x, int y) {
421 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels 441 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels
422 GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alph aType()); 442 GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alph aType());
423 if (kUnknown_GrPixelConfig == config) { 443 if (kUnknown_GrPixelConfig == config) {
424 return false; 444 return false;
425 } 445 }
426 uint32_t flags = 0; 446 uint32_t flags = 0;
427 if (kUnpremul_SkAlphaType == info.alphaType()) { 447 if (kUnpremul_SkAlphaType == info.alphaType()) {
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after
2038 if (NULL == data) { 2058 if (NULL == data) {
2039 return false; 2059 return false;
2040 } 2060 }
2041 2061
2042 #if 0 2062 #if 0
2043 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); 2063 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data);
2044 #endif 2064 #endif
2045 2065
2046 return false; 2066 return false;
2047 } 2067 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698