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

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

Issue 1403313003: Remove params from Cacherator_GrTextureMaker (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: correct_key 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/SkImageGenerator.cpp ('k') | src/utils/SkImageGeneratorUtils.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*, const GrTextureParams&, const SkIRe ct*) override; 25 GrTexture* onGenerateTexture(GrContext*, const SkIRect*) 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, const GrTe xtureParams&, 91 GrTexture* SkPictureImageGenerator::onGenerateTexture(GrContext* ctx, const SkIR ect* subset) {
92 const SkIRect* subset) {
93 const SkImageInfo& info = this->getInfo(); 92 const SkImageInfo& info = this->getInfo();
94 SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->heig ht()) : info; 93 SkImageInfo surfaceInfo = subset ? info.makeWH(subset->width(), subset->heig ht()) : info;
95 94
96 // 95 //
97 // TODO: respect the usage, by possibly creating a different (pow2) surface 96 // TODO: respect the usage, by possibly creating a different (pow2) surface
98 // 97 //
99 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, 98 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx,
100 SkSurface::kYes_B udgeted, 99 SkSurface::kYes_B udgeted,
101 surfaceInfo)); 100 surfaceInfo));
102 if (!surface.get()) { 101 if (!surface.get()) {
103 return nullptr; 102 return nullptr;
104 } 103 }
105 104
106 SkMatrix matrix = fMatrix; 105 SkMatrix matrix = fMatrix;
107 if (subset) { 106 if (subset) {
108 matrix.postTranslate(-subset->x(), -subset->y()); 107 matrix.postTranslate(-subset->x(), -subset->y());
109 } 108 }
110 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f or us? 109 surface->getCanvas()->clear(0); // does NewRenderTarget promise to do this f or us?
111 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull()); 110 surface->getCanvas()->drawPicture(fPicture, &matrix, fPaint.getMaybeNull());
112 SkAutoTUnref<SkImage> image(surface->newImageSnapshot()); 111 SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
113 if (!image.get()) { 112 if (!image.get()) {
114 return nullptr; 113 return nullptr;
115 } 114 }
116 return SkSafeRef(image->getTexture()); 115 return SkSafeRef(image->getTexture());
117 } 116 }
118 #endif 117 #endif
OLDNEW
« no previous file with comments | « src/core/SkImageGenerator.cpp ('k') | src/utils/SkImageGeneratorUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698