OLD | NEW |
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 336 |
337 /////////////////////////////////////////////////////////////////////////////// | 337 /////////////////////////////////////////////////////////////////////////////// |
338 | 338 |
339 void SkGpuDevice::makeRenderTargetCurrent() { | 339 void SkGpuDevice::makeRenderTargetCurrent() { |
340 DO_DEFERRED_CLEAR(); | 340 DO_DEFERRED_CLEAR(); |
341 fContext->setRenderTarget(fRenderTarget); | 341 fContext->setRenderTarget(fRenderTarget); |
342 } | 342 } |
343 | 343 |
344 /////////////////////////////////////////////////////////////////////////////// | 344 /////////////////////////////////////////////////////////////////////////////// |
345 | 345 |
| 346 #ifdef SK_SUPPORT_LEGACY_READPIXELSCONFIG |
346 namespace { | 347 namespace { |
347 GrPixelConfig config8888_to_grconfig_and_flags(SkCanvas::Config8888 config8888,
uint32_t* flags) { | 348 GrPixelConfig config8888_to_grconfig_and_flags(SkCanvas::Config8888 config8888,
uint32_t* flags) { |
348 switch (config8888) { | 349 switch (config8888) { |
349 case SkCanvas::kNative_Premul_Config8888: | 350 case SkCanvas::kNative_Premul_Config8888: |
350 *flags = 0; | 351 *flags = 0; |
351 return kSkia8888_GrPixelConfig; | 352 return kSkia8888_GrPixelConfig; |
352 case SkCanvas::kNative_Unpremul_Config8888: | 353 case SkCanvas::kNative_Unpremul_Config8888: |
353 *flags = GrContext::kUnpremul_PixelOpsFlag; | 354 *flags = GrContext::kUnpremul_PixelOpsFlag; |
354 return kSkia8888_GrPixelConfig; | 355 return kSkia8888_GrPixelConfig; |
355 case SkCanvas::kBGRA_Premul_Config8888: | 356 case SkCanvas::kBGRA_Premul_Config8888: |
(...skipping 16 matching lines...) Expand all Loading... |
372 } | 373 } |
373 } | 374 } |
374 | 375 |
375 bool SkGpuDevice::onReadPixels(const SkBitmap& bitmap, | 376 bool SkGpuDevice::onReadPixels(const SkBitmap& bitmap, |
376 int x, int y, | 377 int x, int y, |
377 SkCanvas::Config8888 config8888) { | 378 SkCanvas::Config8888 config8888) { |
378 DO_DEFERRED_CLEAR(); | 379 DO_DEFERRED_CLEAR(); |
379 SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config()); | 380 SkASSERT(SkBitmap::kARGB_8888_Config == bitmap.config()); |
380 SkASSERT(!bitmap.isNull()); | 381 SkASSERT(!bitmap.isNull()); |
381 SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::Ma
keXYWH(x, y, bitmap.width(), bitmap.height()))); | 382 SkASSERT(SkIRect::MakeWH(this->width(), this->height()).contains(SkIRect::Ma
keXYWH(x, y, bitmap.width(), bitmap.height()))); |
382 | 383 |
383 SkAutoLockPixels alp(bitmap); | 384 SkAutoLockPixels alp(bitmap); |
384 GrPixelConfig config; | 385 GrPixelConfig config; |
385 uint32_t flags; | 386 uint32_t flags; |
386 config = config8888_to_grconfig_and_flags(config8888, &flags); | 387 config = config8888_to_grconfig_and_flags(config8888, &flags); |
387 return fContext->readRenderTargetPixels(fRenderTarget, | 388 return fContext->readRenderTargetPixels(fRenderTarget, |
388 x, y, | 389 x, y, |
389 bitmap.width(), | 390 bitmap.width(), |
390 bitmap.height(), | 391 bitmap.height(), |
391 config, | 392 config, |
392 bitmap.getPixels(), | 393 bitmap.getPixels(), |
393 bitmap.rowBytes(), | 394 bitmap.rowBytes(), |
394 flags); | 395 flags); |
395 } | 396 } |
| 397 #endif |
| 398 |
| 399 bool SkGpuDevice::onReadPixels(const SkImageInfo& dstInfo, void* dstPixels, size
_t dstRowBytes, |
| 400 int x, int y) { |
| 401 DO_DEFERRED_CLEAR(); |
| 402 |
| 403 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels |
| 404 GrPixelConfig config = SkImageInfo2GrPixelConfig(dstInfo.colorType(), dstInf
o.alphaType()); |
| 405 if (kUnknown_GrPixelConfig == config) { |
| 406 return false; |
| 407 } |
| 408 |
| 409 uint32_t flags = 0; |
| 410 if (kUnpremul_SkAlphaType == dstInfo.alphaType()) { |
| 411 flags = GrContext::kUnpremul_PixelOpsFlag; |
| 412 } |
| 413 return fContext->readRenderTargetPixels(fRenderTarget, x, y, dstInfo.width()
, dstInfo.height(), |
| 414 config, dstPixels, dstRowBytes, flag
s); |
| 415 } |
396 | 416 |
397 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz
e_t rowBytes, | 417 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz
e_t rowBytes, |
398 int x, int y) { | 418 int x, int y) { |
399 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels | 419 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels |
400 GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alph
aType()); | 420 GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alph
aType()); |
401 if (kUnknown_GrPixelConfig == config) { | 421 if (kUnknown_GrPixelConfig == config) { |
402 return false; | 422 return false; |
403 } | 423 } |
404 uint32_t flags = 0; | 424 uint32_t flags = 0; |
405 if (kUnpremul_SkAlphaType == info.alphaType()) { | 425 if (kUnpremul_SkAlphaType == info.alphaType()) { |
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2016 if (NULL == data) { | 2036 if (NULL == data) { |
2017 return false; | 2037 return false; |
2018 } | 2038 } |
2019 | 2039 |
2020 #if 0 | 2040 #if 0 |
2021 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); | 2041 const GPUAccelData *gpuData = static_cast<const GPUAccelData*>(data); |
2022 #endif | 2042 #endif |
2023 | 2043 |
2024 return false; | 2044 return false; |
2025 } | 2045 } |
OLD | NEW |