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

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

Issue 1151283004: Split drawing functionality out of GrContext and into new GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix no-GPU builds Created 5 years, 7 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
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/effects/GrConfigConversionEffect.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 2010 Google Inc. 2 * Copyright 2010 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 "SkGr.h" 8 #include "SkGr.h"
9 9
10 #include "GrDrawContext.h"
10 #include "GrXferProcessor.h" 11 #include "GrXferProcessor.h"
11 #include "SkColorFilter.h" 12 #include "SkColorFilter.h"
12 #include "SkConfig8888.h" 13 #include "SkConfig8888.h"
13 #include "SkData.h" 14 #include "SkData.h"
14 #include "SkErrorInternals.h" 15 #include "SkErrorInternals.h"
15 #include "SkGrPixelRef.h" 16 #include "SkGrPixelRef.h"
16 #include "SkMessageBus.h" 17 #include "SkMessageBus.h"
17 #include "SkPixelRef.h" 18 #include "SkPixelRef.h"
18 #include "SkResourceCache.h" 19 #include "SkResourceCache.h"
19 #include "SkTextureCompressor.h" 20 #include "SkTextureCompressor.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 // If filtering is not desired then we want to ensure all texels in the resa mpled image are 239 // If filtering is not desired then we want to ensure all texels in the resa mpled image are
239 // copies of texels from the original. 240 // copies of texels from the original.
240 GrTextureParams params(SkShader::kClamp_TileMode, 241 GrTextureParams params(SkShader::kClamp_TileMode,
241 kBilerp_Stretch == stretch ? GrTextureParams::kBilerp _FilterMode : 242 kBilerp_Stretch == stretch ? GrTextureParams::kBilerp _FilterMode :
242 GrTextureParams::kNone_F ilterMode); 243 GrTextureParams::kNone_F ilterMode);
243 paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params); 244 paint.addColorTextureProcessor(inputTexture, SkMatrix::I(), params);
244 245
245 SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtD esc.fHeight)); 246 SkRect rect = SkRect::MakeWH(SkIntToScalar(rtDesc.fWidth), SkIntToScalar(rtD esc.fHeight));
246 SkRect localRect = SkRect::MakeWH(1.f, 1.f); 247 SkRect localRect = SkRect::MakeWH(1.f, 1.f);
247 248
248 context->drawNonAARectToRect(stretched->asRenderTarget(), GrClip::WideOpen() , paint, 249 GrDrawContext* drawContext = context->drawContext();
249 SkMatrix::I(), rect, localRect); 250 if (!drawContext) {
251 return NULL;
252 }
253
254 drawContext->drawNonAARectToRect(stretched->asRenderTarget(), GrClip::WideOp en(), paint,
255 SkMatrix::I(), rect, localRect);
250 256
251 return stretched; 257 return stretched;
252 } 258 }
253 259
254 #ifndef SK_IGNORE_ETC1_SUPPORT 260 #ifndef SK_IGNORE_ETC1_SUPPORT
255 static GrTexture *load_etc1_texture(GrContext* ctx, const GrUniqueKey& optionalK ey, 261 static GrTexture *load_etc1_texture(GrContext* ctx, const GrUniqueKey& optionalK ey,
256 const SkBitmap &bm, GrSurfaceDesc desc) { 262 const SkBitmap &bm, GrSurfaceDesc desc) {
257 SkAutoTUnref<SkData> data(bm.pixelRef()->refEncodedData()); 263 SkAutoTUnref<SkData> data(bm.pixelRef()->refEncodedData());
258 264
259 // Is this even encoded data? 265 // Is this even encoded data?
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 SkASSERT(renderTarget); 397 SkASSERT(renderTarget);
392 398
393 SkAutoTUnref<GrFragmentProcessor> 399 SkAutoTUnref<GrFragmentProcessor>
394 yuvToRgbProcessor(GrYUVtoRGBEffect::Create(yuvTextures[0], yuvTextures[1 ], yuvTextures[2], 400 yuvToRgbProcessor(GrYUVtoRGBEffect::Create(yuvTextures[0], yuvTextures[1 ], yuvTextures[2],
395 yuvInfo.fSize, yuvInfo.fColor Space)); 401 yuvInfo.fSize, yuvInfo.fColor Space));
396 GrPaint paint; 402 GrPaint paint;
397 paint.addColorProcessor(yuvToRgbProcessor); 403 paint.addColorProcessor(yuvToRgbProcessor);
398 SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth), 404 SkRect r = SkRect::MakeWH(SkIntToScalar(yuvInfo.fSize[0].fWidth),
399 SkIntToScalar(yuvInfo.fSize[0].fHeight)); 405 SkIntToScalar(yuvInfo.fSize[0].fHeight));
400 406
401 ctx->drawRect(renderTarget, GrClip::WideOpen(), paint, SkMatrix::I(), r); 407 GrDrawContext* drawContext = ctx->drawContext();
408 if (!drawContext) {
409 return NULL;
410 }
411
412 drawContext->drawRect(renderTarget, GrClip::WideOpen(), paint, SkMatrix::I() , r);
402 413
403 return result; 414 return result;
404 } 415 }
405 416
406 static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx, 417 static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx,
407 const SkBitmap& origBitmap, 418 const SkBitmap& origBitmap,
408 const GrUniqueKey& optionalK ey) { 419 const GrUniqueKey& optionalK ey) {
409 SkBitmap tmpBitmap; 420 SkBitmap tmpBitmap;
410 421
411 const SkBitmap* bitmap = &origBitmap; 422 const SkBitmap* bitmap = &origBitmap;
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 } 764 }
754 return SkImageInfo::Make(w, h, ct, at); 765 return SkImageInfo::Make(w, h, ct, at);
755 } 766 }
756 767
757 768
758 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) { 769 void GrWrapTextureInBitmap(GrTexture* src, int w, int h, bool isOpaque, SkBitmap * dst) {
759 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque); 770 const SkImageInfo info = GrMakeInfoFromTexture(src, w, h, isOpaque);
760 dst->setInfo(info); 771 dst->setInfo(info);
761 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref(); 772 dst->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, src)))->unref();
762 } 773 }
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | src/gpu/effects/GrConfigConversionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698