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

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 150513005: impl getROPixels for gpu SkImage (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « bench/benchmain.cpp ('k') | no next file » | 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 2012 Google Inc. 2 * Copyright 2012 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 "SkImage_Base.h" 8 #include "SkImage_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "GrContext.h" 12 #include "GrContext.h"
13 #include "GrTexture.h" 13 #include "GrTexture.h"
14 #include "SkGrPixelRef.h" 14 #include "SkGrPixelRef.h"
15 15
16 class SkImage_Gpu : public SkImage_Base { 16 class SkImage_Gpu : public SkImage_Base {
17 public: 17 public:
18 SK_DECLARE_INST_COUNT(SkImage_Gpu) 18 SK_DECLARE_INST_COUNT(SkImage_Gpu)
19 19
20 explicit SkImage_Gpu(const SkBitmap&); 20 explicit SkImage_Gpu(const SkBitmap&);
21 virtual ~SkImage_Gpu(); 21 virtual ~SkImage_Gpu();
22 22
23 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) SK_OV ERRIDE; 23 virtual void onDraw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*) SK_OV ERRIDE;
24 virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, const SkRect& ds t, const SkPaint*) SK_OVERRIDE; 24 virtual void onDrawRectToRect(SkCanvas*, const SkRect* src, const SkRect& ds t, const SkPaint*) SK_OVERRIDE;
25 virtual GrTexture* onGetTexture() SK_OVERRIDE; 25 virtual GrTexture* onGetTexture() SK_OVERRIDE;
26 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE { 26 virtual bool getROPixels(SkBitmap*) const SK_OVERRIDE;
27 // TODO
28 return false;
29 }
30 27
31 GrTexture* getTexture() { return fBitmap.getTexture(); } 28 GrTexture* getTexture() { return fBitmap.getTexture(); }
32 29
33 private: 30 private:
34 SkBitmap fBitmap; 31 SkBitmap fBitmap;
35 32
36 typedef SkImage_Base INHERITED; 33 typedef SkImage_Base INHERITED;
37 }; 34 };
38 35
39 /////////////////////////////////////////////////////////////////////////////// 36 ///////////////////////////////////////////////////////////////////////////////
(...skipping 14 matching lines...) Expand all
54 51
55 void SkImage_Gpu::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const Sk Rect& dst, 52 void SkImage_Gpu::onDrawRectToRect(SkCanvas* canvas, const SkRect* src, const Sk Rect& dst,
56 const SkPaint* paint) { 53 const SkPaint* paint) {
57 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint); 54 canvas->drawBitmapRectToRect(fBitmap, src, dst, paint);
58 } 55 }
59 56
60 GrTexture* SkImage_Gpu::onGetTexture() { 57 GrTexture* SkImage_Gpu::onGetTexture() {
61 return fBitmap.getTexture(); 58 return fBitmap.getTexture();
62 } 59 }
63 60
61 bool SkImage_Gpu::getROPixels(SkBitmap* dst) const {
62 return fBitmap.copyTo(dst, SkBitmap::kARGB_8888_Config);
63 }
64
64 /////////////////////////////////////////////////////////////////////////////// 65 ///////////////////////////////////////////////////////////////////////////////
65 66
66 SkImage* SkImage::NewTexture(const SkBitmap& bitmap) { 67 SkImage* SkImage::NewTexture(const SkBitmap& bitmap) {
67 if (NULL == bitmap.getTexture()) { 68 if (NULL == bitmap.getTexture()) {
68 return NULL; 69 return NULL;
69 } 70 }
70 71
71 return SkNEW_ARGS(SkImage_Gpu, (bitmap)); 72 return SkNEW_ARGS(SkImage_Gpu, (bitmap));
72 } 73 }
73 74
74 GrTexture* SkTextureImageGetTexture(SkImage* image) { 75 GrTexture* SkTextureImageGetTexture(SkImage* image) {
75 return ((SkImage_Gpu*)image)->getTexture(); 76 return ((SkImage_Gpu*)image)->getTexture();
76 } 77 }
OLDNEW
« no previous file with comments | « bench/benchmain.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698