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

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

Issue 180113010: Add SkCanvas::writePixels that takes info+pixels directly (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
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | 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 "effects/GrBicubicEffect.h" 10 #include "effects/GrBicubicEffect.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return fContext->readRenderTargetPixels(fRenderTarget, 396 return fContext->readRenderTargetPixels(fRenderTarget,
397 x, y, 397 x, y,
398 bitmap.width(), 398 bitmap.width(),
399 bitmap.height(), 399 bitmap.height(),
400 config, 400 config,
401 bitmap.getPixels(), 401 bitmap.getPixels(),
402 bitmap.rowBytes(), 402 bitmap.rowBytes(),
403 flags); 403 flags);
404 } 404 }
405 405
406 #ifdef SK_SUPPORT_LEGACY_WRITEPIXELSCONFIG
406 void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y, 407 void SkGpuDevice::writePixels(const SkBitmap& bitmap, int x, int y,
407 SkCanvas::Config8888 config8888) { 408 SkCanvas::Config8888 config8888) {
408 SkAutoLockPixels alp(bitmap); 409 SkAutoLockPixels alp(bitmap);
409 if (!bitmap.readyToDraw()) { 410 if (!bitmap.readyToDraw()) {
410 return; 411 return;
411 } 412 }
412 413
413 GrPixelConfig config; 414 GrPixelConfig config;
414 uint32_t flags; 415 uint32_t flags;
415 if (SkBitmap::kARGB_8888_Config == bitmap.config()) { 416 if (SkBitmap::kARGB_8888_Config == bitmap.config()) {
416 config = config8888_to_grconfig_and_flags(config8888, &flags); 417 config = config8888_to_grconfig_and_flags(config8888, &flags);
417 } else { 418 } else {
418 flags = 0; 419 flags = 0;
419 config= SkBitmapConfig2GrPixelConfig(bitmap.config()); 420 config= SkBitmapConfig2GrPixelConfig(bitmap.config());
420 } 421 }
421 422
422 fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(), 423 fRenderTarget->writePixels(x, y, bitmap.width(), bitmap.height(),
423 config, bitmap.getPixels(), bitmap.rowBytes(), fl ags); 424 config, bitmap.getPixels(), bitmap.rowBytes(), fl ags);
424 } 425 }
426 #endif
427
428 bool SkGpuDevice::onWritePixels(const SkImageInfo& info, const void* pixels, siz e_t rowBytes,
429 int x, int y) {
430 // TODO: teach fRenderTarget to take ImageInfo directly to specify the src p ixels
431 GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alph aType());
432 if (kUnknown_GrPixelConfig == config) {
433 return false;
434 }
435 uint32_t flags = 0;
436 if (kUnpremul_SkAlphaType == info.alphaType()) {
437 flags = GrContext::kUnpremul_PixelOpsFlag;
438 }
439 fRenderTarget->writePixels(x, y, info.width(), info.height(), config, pixels , rowBytes, flags);
440
441 // need to bump our genID for compatibility with clients that "know" we have a bitmap
442 this->onAccessBitmap().notifyPixelsChanged();
443
444 return true;
445 }
425 446
426 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) { 447 void SkGpuDevice::onAttachToCanvas(SkCanvas* canvas) {
427 INHERITED::onAttachToCanvas(canvas); 448 INHERITED::onAttachToCanvas(canvas);
428 449
429 // Canvas promises that this ptr is valid until onDetachFromCanvas is called 450 // Canvas promises that this ptr is valid until onDetachFromCanvas is called
430 fClipData.fClipStack = canvas->getClipStack(); 451 fClipData.fClipStack = canvas->getClipStack();
431 } 452 }
432 453
433 void SkGpuDevice::onDetachFromCanvas() { 454 void SkGpuDevice::onDetachFromCanvas() {
434 INHERITED::onDetachFromCanvas(); 455 INHERITED::onDetachFromCanvas();
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 GrTexture* texture, 1970 GrTexture* texture,
1950 bool needClear) 1971 bool needClear)
1951 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) { 1972 : SkBitmapDevice(make_bitmap(context, texture->asRenderTarget())) {
1952 1973
1953 SkASSERT(texture && texture->asRenderTarget()); 1974 SkASSERT(texture && texture->asRenderTarget());
1954 // This constructor is called from onCreateDevice. It has locked the RT in t he texture 1975 // 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. 1976 // cache. We pass true for the third argument so that it will get unlocked.
1956 this->initFromRenderTarget(context, texture->asRenderTarget(), true); 1977 this->initFromRenderTarget(context, texture->asRenderTarget(), true);
1957 fNeedClear = needClear; 1978 fNeedClear = needClear;
1958 } 1979 }
OLDNEW
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/utils/SkDeferredCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698