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

Side by Side Diff: skia/ext/vector_canvas_unittest.cc

Issue 7019013: Removal of dependencies on PlatformDevice classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressing comments. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if !defined(OS_WIN) 7 #if !defined(OS_WIN)
8 #include <unistd.h> 8 #include <unistd.h>
9 #endif 9 #endif
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 EXPECT_TRUE(gfx::PNGCodec::Decode( 92 EXPECT_TRUE(gfx::PNGCodec::Decode(
93 reinterpret_cast<const unsigned char*>(compressed.data()), 93 reinterpret_cast<const unsigned char*>(compressed.data()),
94 compressed.size(), &bitmap)); 94 compressed.size(), &bitmap));
95 SetSkBitmap(bitmap); 95 SetSkBitmap(bitmap);
96 } 96 }
97 97
98 // Loads the image from a canvas. 98 // Loads the image from a canvas.
99 Image(const skia::PlatformCanvas& canvas) : ignore_alpha_(true) { 99 Image(const skia::PlatformCanvas& canvas) : ignore_alpha_(true) {
100 // Use a different way to access the bitmap. The normal way would be to 100 // Use a different way to access the bitmap. The normal way would be to
101 // query the SkBitmap. 101 // query the SkBitmap.
102 HDC context = canvas.beginPlatformPaint(); 102 HDC context = skia::BeginPlatformPaint(&canvas);
103 HGDIOBJ bitmap = GetCurrentObject(context, OBJ_BITMAP); 103 HGDIOBJ bitmap = GetCurrentObject(context, OBJ_BITMAP);
104 EXPECT_TRUE(bitmap != NULL); 104 EXPECT_TRUE(bitmap != NULL);
105 // Initialize the clip region to the entire bitmap. 105 // Initialize the clip region to the entire bitmap.
106 BITMAP bitmap_data; 106 BITMAP bitmap_data;
107 EXPECT_EQ(GetObject(bitmap, sizeof(BITMAP), &bitmap_data), sizeof(BITMAP)); 107 EXPECT_EQ(GetObject(bitmap, sizeof(BITMAP), &bitmap_data), sizeof(BITMAP));
108 width_ = bitmap_data.bmWidth; 108 width_ = bitmap_data.bmWidth;
109 height_ = bitmap_data.bmHeight; 109 height_ = bitmap_data.bmHeight;
110 row_length_ = bitmap_data.bmWidthBytes; 110 row_length_ = bitmap_data.bmWidthBytes;
111 size_t size = row_length_ * height_; 111 size_t size = row_length_ * height_;
112 data_.resize(size); 112 data_.resize(size);
113 memcpy(&*data_.begin(), bitmap_data.bmBits, size); 113 memcpy(&*data_.begin(), bitmap_data.bmBits, size);
114 canvas.endPlatformPaint(); 114 skia::EndPlatformPaint(&canvas);
115 } 115 }
116 116
117 // Loads the image from a canvas. 117 // Loads the image from a canvas.
118 Image(const SkBitmap& bitmap) : ignore_alpha_(true) { 118 Image(const SkBitmap& bitmap) : ignore_alpha_(true) {
119 SetSkBitmap(bitmap); 119 SetSkBitmap(bitmap);
120 } 120 }
121 121
122 int width() const { return width_; } 122 int width() const { return width_; }
123 int height() const { return height_; } 123 int height() const { return height_; }
124 int row_length() const { return row_length_; } 124 int row_length() const { return row_length_; }
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 { 970 {
971 vcanvas_->rotate(67); 971 vcanvas_->rotate(67);
972 pcanvas_->rotate(67); 972 pcanvas_->rotate(67);
973 vcanvas_->drawBitmap(bitmap, 20, -50, NULL); 973 vcanvas_->drawBitmap(bitmap, 20, -50, NULL);
974 pcanvas_->drawBitmap(bitmap, 20, -50, NULL); 974 pcanvas_->drawBitmap(bitmap, 20, -50, NULL);
975 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate"))); 975 EXPECT_EQ(0., ProcessImage(FILE_PATH_LITERAL("rotate")));
976 } 976 }
977 } 977 }
978 978
979 } // namespace skia 979 } // namespace skia
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698