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

Side by Side Diff: src/core/SkPictureImageGenerator.cpp

Issue 1404433002: Remove image usage type enum. Use GrTextureParams instead. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix no gpu build Created 5 years, 2 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/core/SkLightingShader.cpp ('k') | src/effects/SkPerlinNoiseShader.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 2015 Google Inc. 2 * Copyright 2015 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 "SkImageGenerator.h" 8 #include "SkImageGenerator.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkMatrix.h" 10 #include "SkMatrix.h"
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkSurface.h" 13 #include "SkSurface.h"
14 #include "SkTLazy.h" 14 #include "SkTLazy.h"
15 15
16 class SkPictureImageGenerator : SkImageGenerator { 16 class SkPictureImageGenerator : SkImageGenerator {
17 public: 17 public:
18 static SkImageGenerator* Create(const SkISize&, const SkPicture*, const SkMa trix*, 18 static SkImageGenerator* Create(const SkISize&, const SkPicture*, const SkMa trix*,
19 const SkPaint*); 19 const SkPaint*);
20 20
21 protected: 21 protected:
22 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkP MColor ctable[], 22 bool onGetPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, SkP MColor ctable[],
23 int* ctableCount) override; 23 int* ctableCount) override;
24 #if SK_SUPPORT_GPU 24 #if SK_SUPPORT_GPU
25 GrTexture* onGenerateTexture(GrContext*, SkImageUsageType, const SkIRect*) o verride; 25 GrTexture* onGenerateTexture(GrContext*, const GrTextureParams&, const SkIRe ct*) override;
26 #endif 26 #endif
27 27
28 private: 28 private:
29 SkPictureImageGenerator(const SkISize&, const SkPicture*, const SkMatrix*, c onst SkPaint*); 29 SkPictureImageGenerator(const SkISize&, const SkPicture*, const SkMatrix*, c onst SkPaint*);
30 30
31 SkAutoTUnref<const SkPicture> fPicture; 31 SkAutoTUnref<const SkPicture> fPicture;
32 SkMatrix fMatrix; 32 SkMatrix fMatrix;
33 SkTLazy<SkPaint> fPaint; 33 SkTLazy<SkPaint> fPaint;
34 34
35 typedef SkImageGenerator INHERITED; 35 typedef SkImageGenerator INHERITED;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 SkImageGenerator* SkImageGenerator::NewFromPicture(const SkISize& size, const Sk Picture* picture, 81 SkImageGenerator* SkImageGenerator::NewFromPicture(const SkISize& size, const Sk Picture* picture,
82 const SkMatrix* matrix, const SkPaint* paint) { 82 const SkMatrix* matrix, const SkPaint* paint) {
83 return SkPictureImageGenerator::Create(size, picture, matrix, paint); 83 return SkPictureImageGenerator::Create(size, picture, matrix, paint);
84 } 84 }
85 85
86 //////////////////////////////////////////////////////////////////////////////// /////////////////// 86 //////////////////////////////////////////////////////////////////////////////// ///////////////////
87 87
88 #if SK_SUPPORT_GPU 88 #if SK_SUPPORT_GPU
89 #include "GrTexture.h" 89 #include "GrTexture.h"
90 90
91 GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, SkImageUsa geType usage, 91 GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const GrTe xtureParams&,
92 const SkIRect* subset) { 92 const SkIRect* subset) {
93 const SkImageInfo& info = this->getInfo(); 93 const SkImageInfo& info = this->getInfo();
94 SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->heig ht()) : info; 94 SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->heig ht()) : info;
95 95
96 // 96 //
97 // TODO: respect the usage, by possibly creating a different (pow2) surface 97 // TODO: respect the usage, by possibly creating a different (pow2) surface
98 // 98 //
99 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, 99 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx,
100 SkSurface::kYes_B udgeted, 100 SkSurface::kYes_B udgeted,
101 surfaceInfo)); 101 surfaceInfo));
102 if (!surface.get()) { 102 if (!surface.get()) {
103 return nullptr; 103 return nullptr;
104 } 104 }
105 105
106 SkMatrix matrix = fMatrix; 106 SkMatrix matrix = fMatrix;
107 if (subset) { 107 if (subset) {
108 matrix.postTranslate(-subset->x(), -subset->y()); 108 matrix.postTranslate(-subset->x(), -subset->y());
109 } 109 }
110 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f or us? 110 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f or us?
111 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull()); 111 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull());
112 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); 112 SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
113 if (!image.get()) { 113 if (!image.get()) {
114 return nullptr; 114 return nullptr;
115 } 115 }
116 return SkSafeRef(image->getTexture()); 116 return SkSafeRef(image->getTexture());
117 } 117 }
118 #endif 118 #endif
OLDNEW
« no previous file with comments | « src/core/SkLightingShader.cpp ('k') | src/effects/SkPerlinNoiseShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698