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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 config = config8888_to_grconfig_and_flags(config8888, &flags); | 416 config = config8888_to_grconfig_and_flags(config8888, &flags); |
417 } else { | 417 } else { |
418 flags = 0; | 418 flags = 0; |
419 config= SkBitmapConfig2GrPixelConfig(bitmap.config()); | 419 config= SkBitmapConfig2GrPixelConfig(bitmap.config()); |
420 } | 420 } |
421 | 421 |
422 fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(), | 422 fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(), |
423 config, bitmap.getPixels(), bitmap.rowBytes(), fl
ags); | 423 config, bitmap.getPixels(), bitmap.rowBytes(), fl
ags); |
424 } | 424 } |
425 | 425 |
| 426 bool SkGpuDevice::onWritePixelsDirect(const SkImageInfo& info, const void* pixel
s, size_t rowBytes, |
| 427 int x, int y) { |
| 428 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p
ixels |
| 429 GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alph
aType()); |
| 430 if (kUnknown_GrPixelConfig == config) { |
| 431 return false; |
| 432 } |
| 433 uint32_t flags = 0; |
| 434 if (kUnpremul_SkAlphaType == info.alphaType()) { |
| 435 flags = GrContext::kUnpremul_PixelOpsFlag; |
| 436 } |
| 437 fRenderTarget->writePixels(x, y, info.width(), info.height(), config, pixels
, rowBytes, flags); |
| 438 return true; |
| 439 } |
| 440 |
426 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { | 441 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { |
427 INHERITED::onAttachToCanvas(canvas); | 442 INHERITED::onAttachToCanvas(canvas); |
428 | 443 |
429 // Canvas promises that this ptr is valid until onDetachFromCanvas is called | 444 // Canvas promises that this ptr is valid until onDetachFromCanvas is called |
430 fClipData.fClipStack = canvas->getClipStack(); | 445 fClipData.fClipStack = canvas->getClipStack(); |
431 } | 446 } |
432 | 447 |
433 void SkGpuDevice::onDetachFromCanvas() { | 448 void SkGpuDevice::onDetachFromCanvas() { |
434 INHERITED::onDetachFromCanvas(); | 449 INHERITED::onDetachFromCanvas(); |
435 fClipData.fClipStack = NULL; | 450 fClipData.fClipStack = NULL; |
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 GrTexture* texture, | 1964 GrTexture* texture, |
1950 bool needClear) | 1965 bool needClear) |
1951 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { | 1966 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { |
1952 | 1967 |
1953 SkASSERT(texture && texture->asRenderTarget()); | 1968 SkASSERT(texture && texture->asRenderTarget()); |
1954 // This constructor is called from onCreateDevice. It has locked the RT in t
he texture | 1969 // This constructor is called from onCreateDevice. It has locked the RT in t
he texture |
1955 // cache. We pass true for the third argument so that it will get unlocked. | 1970 // cache. We pass true for the third argument so that it will get unlocked. |
1956 this->initFromRenderTarget(context, texture->asRenderTarget(), true); | 1971 this->initFromRenderTarget(context, texture->asRenderTarget(), true); |
1957 fNeedClear = needClear; | 1972 fNeedClear = needClear; |
1958 } | 1973 } |
OLD | NEW |