diff options
author | reed <reed@google.com> | 2014-09-21 09:39:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-21 09:39:55 -0700 |
commit | 3716fd067a5621bb94a6cb08d72afec8bf3aceda (patch) | |
tree | cf5ceefd515bee37eec7404e3b86cd18a4d9ee80 /src/gpu | |
parent | 00a138c542bec58cac1a2ecc32b08c8312063ae5 (diff) |
introduce Props to surface (work in progress)
BUG=skia:
R=robertphillips@google.com, bsalomon@google.com, jvanverth@google.com, bungeman@google.com, fmalita@google.com, vangelis@chromium.org, reed@chromium.org
Author: reed@google.com
Review URL: https://codereview.chromium.org/551463004
Diffstat (limited to 'src/gpu')
-rwxr-xr-x | src/gpu/GrDistanceFieldTextContext.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrLayerHoister.cpp | 6 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 18 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 9 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/gpu/GrDistanceFieldTextContext.cpp b/src/gpu/GrDistanceFieldTextContext.cpp index 313c02ac51..df07204fcb 100755 --- a/src/gpu/GrDistanceFieldTextContext.cpp +++ b/src/gpu/GrDistanceFieldTextContext.cpp @@ -131,8 +131,7 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo flags |= fUseLCDText ? kUseLCD_DistanceFieldEffectFlag : 0; flags |= fUseLCDText && fTextMatrix.rectStaysRect() ? kRectToRect_DistanceFieldEffectFlag : 0; - bool useBGR = SkDeviceProperties::Geometry::kBGR_Layout == - fDeviceProperties.fGeometry.getLayout(); + bool useBGR = SkPixelGeometryIsBGR(fDeviceProperties.fPixelGeometry); flags |= fUseLCDText && useBGR ? kBGR_DistanceFieldEffectFlag : 0; // see if we need to create a new effect @@ -149,7 +148,7 @@ void GrDistanceFieldTextContext::setupCoverageEffect(const SkColor& filteredColo flags)); } else { #ifdef SK_GAMMA_APPLY_TO_A8 - U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.fGamma, + U8CPU lum = SkColorSpaceLuminance::computeLuminance(fDeviceProperties.getGamma(), filteredColor); fCachedEffect.reset(GrDistanceFieldTextureEffect::Create(fCurrTexture, params, @@ -502,8 +501,8 @@ static void setup_gamma_texture(GrContext* context, const SkGlyphCache* cache, #else SkScalar contrast = 0.5f; #endif - SkScalar paintGamma = deviceProperties.fGamma; - SkScalar deviceGamma = deviceProperties.fGamma; + SkScalar paintGamma = deviceProperties.getGamma(); + SkScalar deviceGamma = deviceProperties.getGamma(); size = SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamma, &width, &height); diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp index ba431d33e9..165716f82d 100644 --- a/src/gpu/GrLayerHoister.cpp +++ b/src/gpu/GrLayerHoister.cpp @@ -142,8 +142,7 @@ void GrLayerHoister::DrawLayers(const SkPicture* picture, if (atlased.count() > 0) { // All the atlased layers are rendered into the same GrTexture SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( - atlased[0]->texture()->asRenderTarget(), - SkSurface::kStandard_TextRenderMode)); + atlased[0]->texture()->asRenderTarget(), NULL)); SkCanvas* atlasCanvas = surface->getCanvas(); @@ -196,8 +195,7 @@ void GrLayerHoister::DrawLayers(const SkPicture* picture, // Each non-atlased layer has its own GrTexture SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTargetDirect( - layer->texture()->asRenderTarget(), - SkSurface::kStandard_TextRenderMode)); + layer->texture()->asRenderTarget(), NULL)); SkCanvas* layerCanvas = surface->getCanvas(); diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 02dca83ee0..7ce3446b72 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -133,15 +133,15 @@ public: /////////////////////////////////////////////////////////////////////////////// -SkGpuDevice* SkGpuDevice::Create(GrSurface* surface, unsigned flags) { +SkGpuDevice* SkGpuDevice::Create(GrSurface* surface, const SkSurfaceProps& props, unsigned flags) { SkASSERT(surface); if (NULL == surface->asRenderTarget() || surface->wasDestroyed()) { return NULL; } - return SkNEW_ARGS(SkGpuDevice, (surface, flags)); + return SkNEW_ARGS(SkGpuDevice, (surface, props, flags)); } -SkGpuDevice::SkGpuDevice(GrSurface* surface, unsigned flags) { +SkGpuDevice::SkGpuDevice(GrSurface* surface, const SkSurfaceProps& props, unsigned flags) { fDrawProcs = NULL; @@ -156,13 +156,15 @@ SkGpuDevice::SkGpuDevice(GrSurface* surface, unsigned flags) { fLegacyBitmap.setInfo(surface->info()); fLegacyBitmap.setPixelRef(pr)->unref(); + this->setPixelGeometry(props.pixelGeometry()); + bool useDFFonts = !!(flags & kDFFonts_Flag); fMainTextContext = fContext->createTextContext(fRenderTarget, this->getLeakyProperties(), useDFFonts); fFallbackTextContext = SkNEW_ARGS(GrBitmapTextContext, (fContext, this->getLeakyProperties())); } SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo, - int sampleCount) { + const SkSurfaceProps& props, int sampleCount) { if (kUnknown_SkColorType == origInfo.colorType() || origInfo.width() < 0 || origInfo.height() < 0) { return NULL; @@ -194,7 +196,7 @@ SkGpuDevice* SkGpuDevice::Create(GrContext* context, const SkImageInfo& origInfo return NULL; } - return SkNEW_ARGS(SkGpuDevice, (texture.get())); + return SkNEW_ARGS(SkGpuDevice, (texture.get(), props)); } SkGpuDevice::~SkGpuDevice() { @@ -1805,7 +1807,7 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage) texture.reset(fContext->createUncachedTexture(desc, NULL, 0)); #endif if (texture.get()) { - return SkGpuDevice::Create(texture, flags); + return SkGpuDevice::Create(texture, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType), flags); } else { GrPrintf("---- failed to create compatible device texture [%d %d]\n", info.width(), info.height()); @@ -1813,8 +1815,8 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const SkImageInfo& info, Usage usage) } } -SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info) { - return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples()); +SkSurface* SkGpuDevice::newSurface(const SkImageInfo& info, const SkSurfaceProps& props) { + return SkSurface::NewRenderTarget(fContext, info, fRenderTarget->numSamples(), &props); } void SkGpuDevice::EXPERIMENTAL_optimize(const SkPicture* picture) { diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index dc59009dae..41b53b1213 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -43,7 +43,7 @@ public: * the kCached_Flag should be specified to make the device responsible for unlocking * the surface when it is released. */ - static SkGpuDevice* Create(GrSurface* surface, unsigned flags = 0); + static SkGpuDevice* Create(GrSurface* surface, const SkSurfaceProps&, unsigned flags = 0); /** * New device that will create an offscreen renderTarget based on the @@ -51,7 +51,8 @@ public: * count against the GrContext's texture cache budget. The device's pixels * will be uninitialized. On failure, returns NULL. */ - static SkGpuDevice* Create(GrContext*, const SkImageInfo&, int sampleCount); + static SkGpuDevice* Create(GrContext*, const SkImageInfo&, const SkSurfaceProps&, + int sampleCount); virtual ~SkGpuDevice(); @@ -145,11 +146,11 @@ private: // remove when our clients don't rely on accessBitmap() SkBitmap fLegacyBitmap; - SkGpuDevice(GrSurface*, unsigned flags = 0); + SkGpuDevice(GrSurface*, const SkSurfaceProps&, unsigned flags = 0); virtual SkBaseDevice* onCreateDevice(const SkImageInfo&, Usage) SK_OVERRIDE; - virtual SkSurface* newSurface(const SkImageInfo&) SK_OVERRIDE; + virtual SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE; virtual SkImageFilter::Cache* getImageFilterCache() SK_OVERRIDE; |