////////////////////////////////////////////////////////////////////////////////
+bool GrContext::isConfigTexturable(GrPixelConfig config) const {
+ return fGpu->caps()->isConfigTexturable(config);
+}
+
+bool GrContext::npotTextureTileSupport() const {
+ return fGpu->caps()->npotTextureTileSupport();
+}
+
GrTexture* GrContext::createTexture(const GrSurfaceDesc& desc, const void* srcData,
size_t rowBytes) {
return fGpu->createTexture(desc, true, srcData, rowBytes);
GrTexture* GrContext::refScratchTexture(const GrSurfaceDesc& inDesc, ScratchTexMatch match,
bool calledDuringFlush) {
+ // Currently we don't recycle compressed textures as scratch.
+ if (GrPixelConfigIsCompressed(inDesc.fConfig)) {
+ return NULL;
+ }
+
// kNoStencil has no meaning if kRT isn't set.
SkASSERT((inDesc.fFlags & kRenderTarget_GrSurfaceFlag) ||
!(inDesc.fFlags & kNoStencil_GrSurfaceFlag));
return fGpu->wrapBackendRenderTarget(desc);
}
-///////////////////////////////////////////////////////////////////////////////
-
-bool GrContext::supportsIndex8PixelConfig() const {
- const GrDrawTargetCaps* caps = fGpu->caps();
- return caps->isConfigTexturable(kIndex_8_GrPixelConfig);
-}
-
-
////////////////////////////////////////////////////////////////////////////////
void GrContext::clear(const SkIRect* rect,
#include "SkGr.h"
-#include "GrDrawTargetCaps.h"
-#include "GrGpu.h"
-#include "GrGpuResourceCacheAccess.h"
#include "GrXferProcessor.h"
#include "SkColorFilter.h"
#include "SkConfig8888.h"
static Stretch get_stretch_type(const GrContext* ctx, int width, int height,
const GrTextureParams* params) {
if (params && params->isTiled()) {
- const GrDrawTargetCaps* caps = ctx->getGpu()->caps();
- if (!caps->npotTextureTileSupport() && (!SkIsPow2(width) || !SkIsPow2(height))) {
+ if (!ctx->npotTextureTileSupport() && (!SkIsPow2(width) || !SkIsPow2(height))) {
switch(params->filterMode()) {
case GrTextureParams::kNone_FilterMode:
return kNearest_Stretch;
const void* pixels,
size_t rowBytes) {
GrTexture* result;
- if (optionalKey.isValid()) {
+ if (optionalKey.isValid() || GrPixelConfigIsCompressed(desc.fConfig)) {
result = ctx->createTexture(desc, pixels, rowBytes);
if (result) {
SkAssertResult(ctx->addResourceToCache(optionalKey, result));
generate_bitmap_texture_desc(*bitmap, &desc);
if (kIndex_8_SkColorType == bitmap->colorType()) {
- if (ctx->supportsIndex8PixelConfig()) {
+ if (ctx->isConfigTexturable(kIndex_8_GrPixelConfig)) {
size_t imageSize = GrCompressedFormatDataSize(kIndex_8_GrPixelConfig,
bitmap->width(), bitmap->height());
SkAutoMalloc storage(imageSize);
// Is this an ETC1 encoded texture?
#ifndef SK_IGNORE_ETC1_SUPPORT
- else if (
- // We do not support scratch ETC1 textures, hence they should all be at least
- // trying to go to the cache.
- optionalKey.isValid()
- // Make sure that the underlying device supports ETC1 textures before we go ahead
- // and check the data.
- && ctx->getGpu()->caps()->isConfigTexturable(kETC1_GrPixelConfig)
- // If the bitmap had compressed data and was then uncompressed, it'll still return
- // compressed data on 'refEncodedData' and upload it. Probably not good, since if
- // the bitmap has available pixels, then they might not be what the decompressed
- // data is.
- && !(bitmap->readyToDraw())) {
+ // Make sure that the underlying device supports ETC1 textures before we go ahead
+ // and check the data.
+ else if (ctx->isConfigTexturable(kETC1_GrPixelConfig)
+ // If the bitmap had compressed data and was then uncompressed, it'll still return
+ // compressed data on 'refEncodedData' and upload it. Probably not good, since if
+ // the bitmap has available pixels, then they might not be what the decompressed
+ // data is.
+ && !(bitmap->readyToDraw())) {
GrTexture *texture = load_etc1_texture(ctx, optionalKey, *bitmap, desc);
if (texture) {
return texture;
}
#endif // SK_IGNORE_ETC1_SUPPORT
- else {
- GrTexture *texture = load_yuv_texture(ctx, optionalKey, *bitmap, desc);
- if (texture) {
- return texture;
- }
+ GrTexture *texture = load_yuv_texture(ctx, optionalKey, *bitmap, desc);
+ if (texture) {
+ return texture;
}
+
SkAutoLockPixels alp(*bitmap);
if (!bitmap->readyToDraw()) {
return NULL;