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

Side by Side Diff: dm/DMGpuGMTask.cpp

Issue 788243008: Sketch DM refactor. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: better failure messages, disable a few things temporarily to try to go green Created 5 years, 11 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 | « dm/DMGpuGMTask.h ('k') | dm/DMImageTask.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "DMGpuGMTask.h"
2 #include "DMUtil.h"
3 #include "DMWriteTask.h"
4 #include "SkCommonFlags.h"
5 #include "SkSurface.h"
6 #include "SkTLS.h"
7
8 namespace DM {
9
10 GpuGMTask::GpuGMTask(const char* config,
11 Reporter* reporter,
12 TaskRunner* taskRunner,
13 skiagm::GMRegistry::Factory gmFactory,
14 GrContextFactory::GLContextType contextType,
15 GrGLStandard gpuAPI,
16 int sampleCount,
17 bool useDFText)
18 : GpuTask(reporter, taskRunner)
19 , fGM(gmFactory(NULL))
20 , fName(UnderJoin(fGM->getName(), config))
21 , fContextType(contextType)
22 , fGpuAPI(gpuAPI)
23 , fSampleCount(sampleCount)
24 , fUseDFText(useDFText)
25 {}
26
27 static bool gAlreadyWarned[GrContextFactory::kGLContextTypeCnt][kGrGLStandardCnt ];
28
29 void GpuGMTask::draw(GrContextFactory* grFactory) {
30 SkImageInfo info = SkImageInfo::Make(SkScalarCeilToInt(fGM->width()),
31 SkScalarCeilToInt(fGM->height()),
32 kN32_SkColorType,
33 kPremul_SkAlphaType);
34 SkAutoTUnref<SkSurface> surface(NewGpuSurface(grFactory, fContextType, fGpuA PI, info,
35 fSampleCount, fUseDFText));
36 if (!surface) {
37 if (!gAlreadyWarned[fContextType][fGpuAPI]) {
38 SkDebugf("FYI: couldn't create GPU context, type %d API %d. Will sk ip.\n",
39 fContextType, fGpuAPI);
40 gAlreadyWarned[fContextType][fGpuAPI] = true;
41 }
42 return;
43 }
44 SkCanvas* canvas = surface->getCanvas();
45 CanvasPreflight(canvas);
46
47 canvas->concat(fGM->getInitialTransform());
48 fGM->draw(canvas);
49 canvas->flush();
50 #if GR_CACHE_STATS && SK_SUPPORT_GPU
51 if (FLAGS_veryVerbose) {
52 grFactory->get(fContextType)->printCacheStats();
53 }
54 #endif
55
56 SkBitmap bitmap;
57 bitmap.setInfo(info);
58 canvas->readPixels(&bitmap, 0, 0);
59
60 this->spawnChild(SkNEW_ARGS(WriteTask, (*this, "GM", bitmap)));
61 }
62
63 bool GpuGMTask::shouldSkip() const {
64 return kGPUDisabled || SkToBool(fGM->getFlags() & skiagm::GM::kSkipGPU_Flag) ;
65 }
66
67 } // namespace DM
OLDNEW
« no previous file with comments | « dm/DMGpuGMTask.h ('k') | dm/DMImageTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698